Skip to content

Common Recipes

Copyable bearer-token API examples for common GoodMetrics queries.

These examples use https://data.goodmetrics.io, {gmID}, and YOUR_API_KEY.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/realtime/visitors" \
-H "Authorization: Bearer YOUR_API_KEY"

Request a paginated country breakdown for one date range.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&page=1&limit=10&sort_by=uniqueVisitors&dir=desc" \
-H "Authorization: Bearer YOUR_API_KEY"

Filter reports to pages containing /pricing.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/pages/all-pages?start=1771872000&end=1772476799&page_contains=%2Fpricing&sort_by=pageViews&dir=desc" \
-H "Authorization: Bearer YOUR_API_KEY"

Request a daily unique visitor chart.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/charts/overview?start=1771872000&end=1772476799&type=unique_visitors&interval=day" \
-H "Authorization: Bearer YOUR_API_KEY"

Request top events for the signup event.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/custom/top-events?start=1771872000&end=1772476799&event_type_is=signup&page=1&limit=10&sort_by=eventCompletions&dir=desc" \
-H "Authorization: Bearer YOUR_API_KEY"

Add compare_start and compare_end to supported reporting requests.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&compare_start=1771267200&compare_end=1771871999" \
-H "Authorization: Bearer YOUR_API_KEY"

Responses include data.primary, data.secondary, and data.change.

Read meta.cursor from the first table response, then request another page.

Terminal window
curl "https://data.goodmetrics.io/{gmID}/events/audience/countries?start=1771872000&end=1772476799&page=2&limit=10&cursor=cursor-from-first-response" \
-H "Authorization: Bearer YOUR_API_KEY"