Skip to main content

Get Website Stats

Retrieve comprehensive analytics statistics for a specific website, including page views, visitors, bounce rate, and visit duration. The endpoint also returns comparison data from the previous period.

Endpoint

GET /api/websites/{websiteId}/stats

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

websiteId
string
required
Website UUID

Query Parameters

startAt
number
Start timestamp in milliseconds (Unix epoch)
endAt
number
End timestamp in milliseconds (Unix epoch)
startDate
string
Start date in ISO 8601 format
endDate
string
End date in ISO 8601 format
timezone
string
Valid IANA timezone (e.g., America/New_York)
unit
string
Time unit for aggregation (hour, day, week, month, year)
compare
string
Comparison period (prev, year)
path
string
Filter by page path
referrer
string
Filter by referrer URL
title
string
Filter by page title
query
string
Filter by query parameters
os
string
Filter by operating system
browser
string
Filter by browser
device
string
Filter by device type
country
string
Filter by country code (ISO 3166-1 alpha-2)
region
string
Filter by region
city
string
Filter by city
tag
string
Filter by tag
hostname
string
Filter by hostname
language
string
Filter by language
event
string
Filter by event name
segment
string
Filter by segment UUID
cohort
string
Filter by cohort UUID
eventType
number
Filter by event type (positive integer)

Response

pageviews
object
Page views data
visitors
object
Unique visitors data
visits
object
Visits data
bounces
object
Bounce rate data
totaltime
object
Total time on site data
comparison
object
Stats from the previous comparison period (same structure as main stats)

Example Request

curl "https://your-umami-instance.com/api/websites/550e8400-e29b-41d4-a716-446655440000/stats?startDate=2024-01-01&endDate=2024-01-31&timezone=America/New_York" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

{
  "pageviews": {
    "value": 15420,
    "change": 12.5
  },
  "visitors": {
    "value": 3240,
    "change": 8.3
  },
  "visits": {
    "value": 4850,
    "change": 10.1
  },
  "bounces": {
    "value": 42.5,
    "change": -2.3
  },
  "totaltime": {
    "value": 125000,
    "change": 5.7
  },
  "comparison": {
    "pageviews": {
      "value": 13710
    },
    "visitors": {
      "value": 2990
    },
    "visits": {
      "value": 4405
    },
    "bounces": {
      "value": 43.5
    },
    "totaltime": {
      "value": 118250
    }
  }
}
The comparison period is automatically calculated based on the date range. For example, if you query a 7-day period, the comparison will be the previous 7 days.

Build docs developers (and LLMs) love