{"uid":"cap_ZUIuASknWMfxCBM2TawKa","slug":"agent402-tools-group-by-aggregation-79d22a2c","name":"agent402.tools Group-By Aggregation","description":"Group an array of objects by one or more keys and aggregate a numeric field — count (default), sum, avg, min, or max. The SQL GROUP BY agents reach for when wrangling JSON. Deterministic (groups in first-seen order).","url":"https://agent402.tools/api/group-by","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"by":{"description":"key name, or array of key names, to group by"},"op":{"type":"string","description":"count (default) | sum | avg | min | max"},"data":{"description":"array of objects (or JSON string)"},"field":{"type":"string","description":"numeric field to aggregate (omit for count only)"}}},"responseSchema":{"type":"json","example":{"count":2,"groups":[{"key":{"city":"NYC"},"sum":5,"count":2},{"key":{"city":"LA"},"sum":5,"count":1}]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_8_TlFaDb_nzw-przzgoY6","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Groups an array of JSON objects by one or more keys and aggregates a numeric field using count, sum, avg, min, or max — like SQL GROUP BY for JSON data.","exampleAgentPrompt":"I have this array of sales records — can you group them by 'region' and 'product_category', then sum the 'revenue' field for each group?","exampleUseCases":null,"resultDescription":"Returns grouped results where each entry corresponds to a unique combination of the specified key(s), with the computed aggregate value (count, sum, avg, min, or max) of the target numeric field for that group, in first-seen order.","failureModes":["Missing or non-array 'data' field returns an error","Specified 'field' does not exist or is non-numeric when using sum/avg/min/max","Invalid 'op' value outside allowed enum","'by' key does not exist on the objects in the array","Payment not processed (x402 payment required, returns 402 if unpaid)"],"whenToPreferThis":"Use this endpoint when you have an in-memory JSON array and need SQL-style GROUP BY aggregation without standing up a database or writing custom reduce logic. It handles multi-key grouping and five aggregation operations in a single call, making it ideal for lightweight ETL, report generation, or ad-hoc data summarization tasks inside an agent workflow.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:48:40.133Z","isFirstParty":false}