Building Custom Dashboards with the Antlytics API
The Antlytics dashboard covers the core use cases: visitors, pageviews, referrers, and top pages. But sometimes you need that data somewhere else — a Notion page, a Slack digest, a custom report for a client, or a monitoring tool you already use.
The Antlytics public API lets you read your analytics data programmatically. This post explains what the API exposes today, how authentication works, and walks through a practical example. For the full endpoint reference, see the API reference docs.
What the API exposes
The current public API provides read access to three data types:
- Summary statistics — visitors, pageviews, bounce rate, and sessions for a site over a date range
- Top pages — pages sorted by pageviews, with configurable limits
- Referrers — traffic sources sorted by visit count
The API is intentionally scoped. It returns aggregate, non-personal data — no individual session records, no IP addresses, no personal identifiers.
Breakdowns by country, device, browser, UTM campaign, and real-time visitor count are available in the dashboard but are not currently part of the public API.
Authentication
All requests require an API token in the Authorization header:
Authorization: Bearer ant_<your-token>
Create tokens in Settings → API tokens. Each token is shown once — copy it to a secure location immediately.
Keep your API token out of client-side code. Make API requests from a server or a serverless function, not from a browser script.
Core endpoint: site stats
The stats endpoint returns the headline numbers for a date range. The site_id is the UUID shown in your dashboard settings.
curl "https://www.antlytics.com/api/v1/stats?site_id=YOUR_SITE_ID&from=2026-04-01T00:00:00Z&to=2026-05-01T00:00:00Z" \
-H "Authorization: Bearer ant_YOUR_TOKEN"
Response:
{
"visitors": 1842,
"pageviews": 3109,
"bounce_rate": 52,
"sessions": 1842
}
Date parameters use ISO 8601 datetime format. Omit them to get all-time stats.
Breakdown endpoints
Top pages
curl "https://www.antlytics.com/api/v1/pages?site_id=YOUR_SITE_ID&from=2026-04-01T00:00:00Z&to=2026-05-01T00:00:00Z&limit=10" \
-H "Authorization: Bearer ant_YOUR_TOKEN"
Response — an array sorted by pageviews descending:
[
{ "path": "/", "pageviews": 1820, "visitors": 940 },
{ "path": "/pricing", "pageviews": 410, "visitors": 310 }
]
The limit parameter accepts 1–100 (default: 10).
Referrers
curl "https://www.antlytics.com/api/v1/referrers?site_id=YOUR_SITE_ID&from=2026-04-01T00:00:00Z&to=2026-05-01T00:00:00Z" \
-H "Authorization: Bearer ant_YOUR_TOKEN"
Response:
[
{ "referrer": "google.com", "visits": 620 },
{ "referrer": "reddit.com", "visits": 180 }
]
Practical example: weekly Slack digest
This Node.js snippet fetches last week's stats and posts a summary to a Slack webhook:
// weekly-digest.js
const SITE_ID = process.env.ANTLYTICS_SITE_ID
const API_TOKEN = process.env.ANTLYTICS_API_TOKEN
const SLACK_WEBHOOK = process.env.SLACK_WEBHOOK_URL
const today = new Date()
const lastWeekEnd = new Date(today)
lastWeekEnd.setDate(today.getDate() - today.getDay()) // last Sunday
const lastWeekStart = new Date(lastWeekEnd)
lastWeekStart.setDate(lastWeekEnd.getDate() - 6) // last Monday
const fmt = (d) => d.toISOString().split('.')[0] + 'Z'
const statsRes = await fetch(
`https://www.antlytics.com/api/v1/stats?site_id=${SITE_ID}&from=${fmt(lastWeekStart)}&to=${fmt(lastWeekEnd)}`,
{ headers: { Authorization: `Bearer ${API_TOKEN}` } }
)
const stats = await statsRes.json()
const pagesRes = await fetch(
`https://www.antlytics.com/api/v1/pages?site_id=${SITE_ID}&from=${fmt(lastWeekStart)}&to=${fmt(lastWeekEnd)}&limit=5`,
{ headers: { Authorization: `Bearer ${API_TOKEN}` } }
)
const pages = await pagesRes.json()
const topPages = pages
.map((p, i) => `${i + 1}. \`${p.path}\` — ${p.pageviews} pageviews`)
.join('\n')
const from = lastWeekStart.toISOString().split('T')[0]
const to = lastWeekEnd.toISOString().split('T')[0]
await fetch(SLACK_WEBHOOK, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: `*Analytics: ${from} – ${to}*\n\nVisitors: ${stats.visitors}\nPageviews: ${stats.pageviews}\n\n*Top pages:*\n${topPages}`,
}),
})
Run this on a cron schedule (e.g. every Monday morning) to get a weekly digest in your Slack channel.
Practical example: custom Notion dashboard
Notion's API lets you write data to a database. Combining that with the Antlytics API, you can maintain a running analytics log in Notion:
- Create a Notion database with columns: Date, Visitors, Pageviews, Bounce Rate, Top Page.
- Use a scheduled function to call the Antlytics stats and pages endpoints each day.
- POST the results to your Notion database via Notion's API.
The Antlytics API returns clean JSON that maps directly to Notion's property types.
Rate limits
The API allows 60 requests per minute per token. Requests beyond this limit receive 429 Too Many Requests with a Retry-After header.
For scheduled batch jobs (e.g. pulling stats for multiple sites), add a short delay between requests to stay within the limit comfortably.
Error responses
All errors return JSON:
{ "error": "Unauthorized" }
| Status | Meaning |
|---|---|
401 | Missing or invalid token |
404 | Site not found or doesn't belong to this token |
422 | Invalid query parameters |
429 | Rate limit exceeded |
When to use the API vs the dashboard
The dashboard is the right tool for exploring data, spotting trends, and answering one-off questions. The API is the right tool when you need:
- Automated reports on a schedule
- Analytics data in another tool (Notion, Airtable, Google Sheets)
- Client-facing reports with your own branding
- Monitoring integrations that alert on traffic drops
- Aggregating data across multiple sites programmatically
FAQ
Do I need to be a developer to use the API? The API requires making HTTP requests, which most developers can do. Non-technical users are better served by the dashboard export feature — see exporting analytics data as CSV for a simpler option.
Can I use the API to write data? No. The public API is read-only. Pageviews are ingested via the tracker script or SDK — the public API only reads aggregated data.
Is there a client library?
The API is straightforward enough to call with fetch or any HTTP client. See the API reference docs for the full endpoint specification.
How far back does the API return data? The Free plan includes basic data retention. Starter includes two years. The API respects your plan's retention window.
Can I query multiple sites in one request?
Not currently. Each request is scoped to one site_id. For multi-site aggregations, make a request per site and combine the results in your code.
Can I get real-time visitor counts via the API? The real-time visitor count is available in the dashboard. It is not currently part of the public API — it uses session-based authentication rather than API tokens.
Related: Exporting analytics data as CSV · Antlytics implementation guides · API reference docs