Skip to main content
POST
Aggregate counts — group by dimension(s) with filters

Authorizations

x-api-key
string
header
required

Your GOI API key. Create one on the GOI dashboard under API keys.

Body

application/json
group_by
string | null

Primary dimension to group by. Omit for a single total COUNT(*). Allowed values — Geographic: continent, country, country_code, state, state_code, region, region_code, district, district_code, municipality, municipality_code. Classification: nace_code, organization_type, organization_size, employee_class, revenue_class. Source: source. Array (unnested per keyword): summary_keywords. Registrations (unnested per registration via the registries jsonb): company_register_court, company_register_date. A company with multiple registrations contributes one row per registration. Date (requires date_trunc): company_register_date, created_at.

group_by_secondary
string | null

Optional second dimension — produces a 2D breakdown. Requires group_by to be set. Allowed values — Geographic: continent, country, country_code, state, state_code, region, region_code, district, district_code, municipality, municipality_code. Classification: nace_code, organization_type, organization_size, employee_class, revenue_class. Source: source. Array (unnested per keyword): summary_keywords. Registrations (unnested per registration via the registries jsonb): company_register_court, company_register_date. A company with multiple registrations contributes one row per registration. Date (requires date_trunc): company_register_date, created_at.

date_trunc
enum<string>
default:month

Truncation unit applied when group_by or group_by_secondary is a date column (company_register_date or created_at). Ignored for non-date columns. Results are ordered chronologically (ASC) when a date dimension is active.

Available options:
year,
month,
week
filters
FiltersInput · object | null

Column filters to narrow the counted population — same fields as /v1/search filters. text_keywords is not supported here (no BM25 in aggregation queries).

date_range
DateRangeFilter · object | null

Optional date range filter on company_register_date or created_at. Can be combined with filters and with a date group_by dimension simultaneously.

limit
integer
default:100

Maximum number of buckets to return, ordered by count DESC (or ASC for date dimensions). Default 100, max 500.

Required range: 1 <= x <= 500
explain
boolean
default:false

Return EXPLAIN ANALYZE plan in metadata. Sets a 120s statement timeout. Not available for customer API keys.

Response

Aggregation buckets with count per group, plus query metadata.

data
Data · object[]
required

List of aggregation buckets. Each bucket contains the grouping column value(s) and a 'count' key. Ordered by count DESC, or chronologically ASC when a date dimension is active. Null values in grouping columns appear as null in the bucket.

elapsed_ms
integer
required

Query execution time in milliseconds.

metadata
StatsMetadata · object
required