Authentication
All requests require an API key in theAuthorization header:
dk_) and Agent keys (dk_agent_) work on all API routes.
Key Types
| Key Type | Prefix | Purpose |
|---|---|---|
| SDK Key | dk_ | Event ingestion, SDK setup, API access |
| Agent Key | dk_agent_ | AI Chat, API access, MCP integrations |
Error Responses
| Status Code | Description |
|---|---|
401 | Missing or invalid API key |
403 | API key valid but feature not available on your plan |
429 | Rate limit exceeded |
Rate Limiting
All API keys are limited to 100 requests per minute. Every response includes rate limit headers:| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window (100) |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when the window resets |
429 status code. Wait until the X-RateLimit-Reset timestamp before retrying.
Base URL
Date/Time Parameters
All datetime parameters use ISO 8601 format:start_date and end_date parameters. Both are inclusive.
Endpoints
GET /api/v1/overview
Returns core dashboard stats: visitors, pageviews, sessions, and custom events over time. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
aggregation | string | No | auto | hour, day, week, or month |
- Same day:
hour - 1-60 days:
day - 61-180 days:
week - 180+ days:
month
GET /api/v1/traffic
Returns traffic sources, campaigns, or top pages. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
type | string | No | referrer | referrer, campaign, or page |
limit | number | No | 20 | Maximum results (1-100) |
GET /api/v1/devices
Returns browser, OS, or device type breakdown. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
type | string | No | browser | browser, os, or deviceType |
limit | number | No | 15 | Maximum results (1-100) |
GET /api/v1/locations
Returns geographic breakdown by country, region, or city. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
type | string | No | country | country, region, or city |
limit | number | No | 15 | Maximum results (1-100) |
GET /api/v1/events
Returns a paginated list of raw events with filtering. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
event_name | string | No | all | Comma-separated event names |
utm_source | string | No | — | Filter by UTM source |
utm_medium | string | No | — | Filter by UTM medium |
utm_campaign | string | No | — | Filter by UTM campaign |
country | string | No | — | Filter by country code |
region | string | No | — | Filter by region |
city | string | No | — | Filter by city |
page_path | string | No | — | Filter by page path |
limit | number | No | 100 | Maximum results (1-1000) |
offset | number | No | 0 | Pagination offset |
offset and limit to paginate through results. The has_more field indicates whether additional results exist beyond the current page.
GET /api/v1/event-names
Returns all distinct event names tracked in your workspace over the last 30 days. Parameters: None required. Response:integrations array lists all connected data sources that have sent events.
GET /api/v1/realtime
Returns live visitor data and real-time metrics. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
time_window | number | No | 30 | Minutes of data to include (1-60) |
visitors array contains individual active visitors with their current session data. The timeline array contains per-minute visitor counts for the specified time window.
GET /api/v1/attribution
Returns campaign attribution and conversion data. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
window_days | number | No | 30 | Attribution window in days (7, 30, or 90) |
window_days parameter controls how far back DATALYR looks for the original attribution touchpoint when linking a conversion to a campaign.
GET /api/v1/users
Returns a paginated list of tracked users and visitors. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
search | string | No | — | Search by visitor ID, user ID, or email |
limit | number | No | 100 | Maximum results (1-1000) |
GET /api/v1/users/:userId
Returns a single user profile with their session history and conversions. URL Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Visitor ID or user ID |
sessions array contains the user’s session history with individual events. The conversions array contains all conversion events associated with this user.
GET /api/v1/ads
Returns ad platform performance data from connected Meta, Google, and TikTok accounts. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
platform | string | No | all | meta, google, or tiktok |
level | string | No | campaign | campaign, adset, or ad |
limit | number | No | 50 | Maximum results (1-200) |
spend— Total ad spend in the platform’s currencyimpressions— Number of ad impressionsclicks— Number of ad clicksconversions— Number of conversion eventsrevenue— Total revenue attributed to conversionsroas— Return on ad spend (revenue / spend)ctr— Click-through rate (clicks / impressions * 100)cpc— Cost per click (spend / clicks)cpm— Cost per thousand impressions (spend / impressions * 1000)
GET /api/v1/tags
Returns tag analytics data. Parameters:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start_date | ISO 8601 | Yes | — | Start of date range |
end_date | ISO 8601 | Yes | — | End of date range |
limit | number | No | 20 | Maximum results (1-100) |
GET /api/v1/workspace
Returns workspace metadata, connected integrations, and plan information. Parameters: None required. Response:GET /api/v1/usage
Returns current billing period usage statistics. Parameters: None required. Response:events_used and postbacks_used values reflect consumption in the current billing period. These reset on period_start each month.
Code Examples
curl
Get overview stats for the last 7 days:JavaScript (fetch)
Get overview stats:Handle Rate Limiting
Next Steps
AI Chat
Query your data with natural language
Web SDK
Install tracking on your website
Attribution Models
Understand how attribution works
Conversion Rules
Configure conversion postbacks