{"uid":"cap_iOP0ZLKWdyPo22TCZgcWx","slug":"nero-labs-data-aggregate-pivot-4d0b1fe9","name":"Nero Labs Data Aggregate & Pivot","description":"Pay-per-call tools for AI agents, 31 in all: read web pages and RSS feeds, OCR, PDF text, transcription; email, phone and domain checks; UK, Irish and Polish company lookups and UK risk reports; website contacts, tech stack and SEO audits; PageSpeed; AI review, job post and row enrichment; data cleaning, joins, dedupe and diffs; US and EU compliance rules. No account or API key: pay each call in USDC on Base over x402.","url":"https://x402-agent-tools.nerolabs.workers.dev/data/aggregate?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object"},"description":"The records to aggregate, up to 500. Each row is a JSON object; keys may differ between rows."},"topN":{"type":"integer","minimum":1,"description":"After sorting, keep only the first N groups. The totals row still covers every input row."},"sortBy":{"type":"string","description":"An output column to sort by: a group field, an aggregation alias such as \"total_amount\", or a pivot column. Omitted sorts by the group fields."},"pivotField":{"type":"string","description":"Turns this field's distinct values into columns, pivot-table style: group by \"region\" and pivot on \"product\" for one row per region with a column per product. Must not also be a group-by field. At most 50 distinct values."},"aggregations":{"type":"array","items":{"type":"object","required":["function"],"properties":{"alias":{"type":"string","description":"Output column name."},"field":{"type":"string","description":"The field to aggregate. Optional for count, which then counts rows."},"function":{"enum":["count","countDistinct","sum","avg","min","max","median","first","last","list","listDistinct"],"type":"string"}}},"description":"What to compute per group, for example [{\"function\":\"count\",\"alias\":\"orders\"}, {\"field\":\"amount\",\"function\":\"sum\",\"alias\":\"total_amount\"}]. Every function except count needs a field. alias is the output column name (defaults to function_field, or \"count\"). Omitted gives a plain row count per group. Up to 20."},"groupByFields":{"type":"array","items":{"type":"string"},"description":"One output row per distinct combination of these field values, like SQL GROUP BY, for example [\"region\"] or [\"city\", \"category\"]. Dot paths like \"address.city\" work. Empty or omitted aggregates every row into a single row."},"groupMatching":{"enum":["normalized","exact"],"type":"string","description":"normalized (default) ignores letter case and extra whitespace when grouping, so \"South\" and \"south \" are one group. exact requires identical values."},"pivotFunction":{"enum":["count","countDistinct","sum","avg","min","max","median","first","last","list","listDistinct"],"type":"string","description":"How pivot cell values are combined. Defaults to sum when pivotValueField is set; ignored (row count) without one."},"sortDirection":{"enum":["asc","desc"],"type":"string","description":"asc (default) or desc. Use desc with topN for \"top N by\" questions."},"lenientNumbers":{"type":"boolean","description":"On by default: \"$1,234.50\", \"49 USD\", \"12%\" and \"(300)\" count as numbers for sum, avg, min, max and median. Set false to accept only real numbers and plain numeric strings."},"dateBucketField":{"type":"string","description":"A date or timestamp field to group by time period, for example \"orderedAt\". Adds a group column named like \"orderedAt_month\". Unreadable dates land in an \"(invalid date)\" group."},"pivotValueField":{"type":"string","description":"The field whose values fill the pivot cells, for example \"amount\". Omitted fills each cell with a row count."},"includeTotalsRow":{"type":"boolean","description":"Appends a grand-total row labelled \"(total)\" and adds a _rowType column (\"group\" or \"total\")."},"dateBucketGranularity":{"enum":["day","week","month","quarter","year"],"type":"string","description":"Bucket size for dateBucketField: day (2026-08-19), week (2026-W34), month (2026-08, default), quarter (2026-Q3) or year."}}},"responseSchema":{"type":"json","example":{"rows":[{"count":2,"region":"North","sum_sales":180},{"count":1,"region":"South","sum_sales":80}],"summary":{"pivot":null,"columns":["region","sum_sales","count"],"warnings":[],"groupCount":2,"aggregations":[{"alias":"sum_sales","field":"sales","function":"sum"},{"alias":"count","function":"count"}],"droppedByTopN":0,"groupByFields":["region"],"inputRowCount":3,"skippedValues":{},"outputRowCount":2,"totalsRowIncluded":false},"_example_note":"Real output, trimmed: long lists cut to their first items and long text shortened."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_xH9j0nJ22Tpvj8tCS0vUw","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Groups up to 500 JSON rows and computes per-group statistics (count, sum, avg, min, max, median, distinct count, first, last) with date bucketing, pivot tables, sorting, and top-N filtering.","exampleAgentPrompt":"Take these 300 sales records and group them by region and product category, then give me the total revenue, order count, and average order value per group — sort by total revenue descending and only show the top 20 groups.","exampleUseCases":[{"title":"Monthly revenue rollup by region","prompt":"I have 400 transaction records as JSON. Can you group them by region and month, sum up the revenue and count the orders for each group, and sort the results by total revenue descending?"},{"title":"Pivot table for product sales by country","prompt":"Group these 250 sales rows by country, pivot on the product column so each product becomes its own column, and sum the units_sold in each cell — I want a classic pivot table view."},{"title":"Top 10 customers by spend","prompt":"Aggregate these customer order rows by customer_id, compute the total amount spent and number of orders for each, sort by total_amount descending, and keep only the top 10 customers."}],"resultDescription":"Returns one row per distinct group combination containing the requested aggregation columns (e.g. sum_sales, count, avg_price), plus a summary object with groupCount, inputRowCount, outputRowCount, column names, warnings, pivot schema, and how many rows were dropped by topN filtering. Optionally includes a totals row covering all input rows.","failureModes":["More than 500 rows submitted — endpoint enforces a hard cap","More than 20 aggregation functions specified — rejected","pivotField has more than 50 distinct values — rejected","Invalid dot-path in groupByFields — field not found in rows","Aggregation function other than count used without specifying a field — error","Malformed JSON rows array — parse error","Payment not included or insufficient — 402 response"],"whenToPreferThis":"Choose this endpoint when you have a batch of raw JSON records (up to 500) and need grouped summary statistics, pivot tables, or ranked top-N results without setting up a database or writing SQL. Ideal for ad-hoc reporting, enriching agent pipelines with aggregated signals, or preprocessing data before display. It handles mixed-schema rows and supports date bucketing natively, making it more flexible than a SQL query against a rigid schema. Prefer alternatives if your dataset exceeds 500 rows or if you need joins across multiple tables.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-22T12:40:55.905Z","isFirstParty":false,"canonicalSlug":"nero-labs-data-aggregate-pivot-4d0b1fe9"}