Skip to content

Analytics API

The Analytics API provides programmatic access to your project's analytics data. All endpoints require a token with the analytics:view ability.

GET /v2/analytics/...

Summary

GET /v2/analytics/summary?start=2026-01-01&end=2026-01-31

Returns an overview of key metrics for the given period, including comparison with the previous period.

Response

json
{
  "period": {
    "start": "2026-01-01T00:00:00+00:00",
    "end": "2026-01-31T23:59:59+00:00"
  },
  "live_users": 12,
  "visitors": 1500,
  "sessions": 2100,
  "pageviews": 5400,
  "average_session_duration": "00:03:45",
  "bounce_rate": 42.5,
  "visitors_change": 15.3,
  "sessions_change": 8.7,
  "pageviews_change": 22.1
}

Live users

GET /v2/analytics/live

Returns the number of users currently active on your site (sessions not yet ended or ended within the last 5 minutes).

Visitors

GET /v2/analytics/visitors?start=2026-01-01&end=2026-01-31

Returns the total visitor count for the given period.

GET /v2/analytics/visitors/trends?start=2026-01-01&end=2026-01-31

Returns the current and previous period visitor counts with change percentage and trend direction (up, down, or stable).

Sessions

GET /v2/analytics/sessions?start=2026-01-01&end=2026-01-31

Returns the total session count.

Average duration

GET /v2/analytics/sessions/average-duration?start=2026-01-01&end=2026-01-31

Returns the average session duration formatted as HH:MM:SS.

Pageviews

GET /v2/analytics/pageviews?start=2026-01-01&end=2026-01-31

Returns the total pageview count.

Pages

Top pages

GET /v2/analytics/pages?start=2026-01-01&end=2026-01-31&limit=10

Returns the most viewed pages with view count and unique visitors.

json
[
  { "path": "/", "views": 1200, "visitors": 800 },
  { "path": "/blog", "views": 450, "visitors": 300 }
]

Page detail

GET /v2/analytics/pages/{path}?start=2026-01-01&end=2026-01-31

Returns views and unique visitors for a specific page path.

Referrers

Top referrers

GET /v2/analytics/referrers?start=2026-01-01&end=2026-01-31&limit=10

Returns the top traffic sources.

GET /v2/analytics/referrers/trends?start=2026-01-01&end=2026-01-31

Returns current vs. previous period comparison for referral traffic.

Demographics

Devices

GET /v2/analytics/demographics/devices?start=2026-01-01&end=2026-01-31

Browsers

GET /v2/analytics/demographics/browsers?start=2026-01-01&end=2026-01-31

Countries

GET /v2/analytics/demographics/countries?start=2026-01-01&end=2026-01-31

Each returns a breakdown with count and percentage:

json
[
  { "device": "desktop", "count": 800, "percentage": 61.5 },
  { "device": "mobile", "count": 450, "percentage": 34.6 },
  { "device": "tablet", "count": 50, "percentage": 3.9 }
]

Time series

Get metrics over time, grouped by interval (hour, day, week, or month).

Visitor time series

GET /v2/analytics/timeseries/visitors?start=2026-01-01&end=2026-01-31&interval=day

Pageview time series

GET /v2/analytics/timeseries/pageviews?start=2026-01-01&end=2026-01-31&interval=day

Session time series

GET /v2/analytics/timeseries/sessions?start=2026-01-01&end=2026-01-31&interval=day

All return an array of data points:

json
[
  { "date": "2026-01-01", "value": 120 },
  { "date": "2026-01-02", "value": 135 },
  { "date": "2026-01-03", "value": 98 }
]

Diggama Documentation