Website statistics

Operations around Website statistics.

Endpoints

GET /api/websites/{websiteId}/active
GET /api/websites/{websiteId}/events
GET /api/websites/{websiteId}/pageviews
GET /api/websites/{websiteId}/metrics
GET /api/websites/{websiteId}/stats

GET /api/websites/{websiteId}/active

Gets the number of active users on a website.

Parameters

None

Sample example

GET from url: https://umami.mydomain.com/api/websites/86d4095c-a2a8-4fc8-9521-103e858e2b41/stats?startAt=1656679719687&endAt=1656766119687

{
  x: 5;
}
  • x: Number of unique visitors within the last 5 minutes

GET /api/websites/{websiteId}/events

Gets events within a given time range.

Parameters

  • startAt: Timestamp (in ms) of starting date.
  • endAt: Timestamp (in ms) of end date.
  • unit: Time unit (year | month | hour | day).
  • timezone: Timezone (ex. America/Los_Angeles).
  • url: (optional) Name of URL.
  • eventName: (optional) Name of event collected.

Sample response

URL: https://umami.mydomain.com/api/websites/86d4095c-a2a8-4fc8-9521-103e858e2b41/events?startAt=1683262800000&endAt=1683349199999&unit=hour&timezone=America%2FLos_Angeles

[
  { "x": "live-demo-button", "t": "2023-04-12 22:00:00", "y": 1 },
  { "x": "get-started-button", "t": "2023-04-12 22:00:00", "y": 5 },
  { "x": "get-started-button", "t": "2023-04-12 23:00:00", "y": 4 },
  { "x": "live-demo-button", "t": "2023-04-12 23:00:00", "y": 4 },
  { "x": "social-Discord", "t": "2023-04-13 00:00:00", "y": 1 }
]
  • x: Event name.
  • t: Timestamp.
  • y: Number of events.

GET /api/websites/{websiteId}/pageviews

Gets pageviews within a given time range.

Parameters

  • startAt: Timestamp (in ms) of starting date.
  • endAt: Timestamp (in ms) of end date.
  • unit: Time unit (year | month | hour | day).
  • timezone: Timezone (ex. America/Los_Angeles).
  • url: (optional) Name of URL.
  • referrer: (optional) Name of referrer.
  • pageTitle: (optional) Name of page title.
  • os: (optional) Name of operating system.
  • browser: (optional) Name of browser.
  • device: (optional) Name of device (ex. Mobile)
  • country: (optional) Name of country.
  • region: (optional) Name of region/state/province.
  • city: (optional) Name of city.

Sample response

{
    pageviews: [
        {x: "2020-04-20 01:00:00", y: 3},
        {x: "2020-04-20 02:00:00", y: 7}
    ],
    sessions: [
        {x: "2020-04-20 01:00:00", y: 2},
        {x: "2020-04-20 02:00:00", y: 4}
    ]
}
  • x: Timestamp.
  • y: Number of visitors.

GET /api/websites/{websiteId}/stats

Gets summarized website statistics.

Query Parameters

  • startAt: Timestamp (in ms) of starting date.
  • endAt: Timestamp (in ms) of end date.
  • url: (optional) Name of URL.
  • referrer: (optional) Name of referrer.
  • title: (optional) Name of page title.
  • os: (optional) Name of operating system.
  • browser: (optional) Name of browser.
  • device: (optional) Name of device (ex. Mobile)
  • country: (optional) Name of country.
  • region: (optional) Name of region/state/province.
  • city: (optional) Name of city.

Sample example

URL: https://umami.mydomain.com/api/websites/86d4095c-a2a8-4fc8-9521-103e858e2b41/stats?startAt=1656679719687&endAt=1656766119687

{
  pageviews: { value: 5, change: 5 },
  uniques: { value: 1, change: 1 },
  bounces: { value: 0, change: 0 },
  totaltime: { value: 4, change: 4 }
}
  • pageviews: Pages hits
  • uniques: Number of unique visitors
  • bounces: Number of returning visitors
  • totaltime: Time spent on the website

GET /api/websites/{websiteId}/metrics

Gets metrics for a given time range.

Parameters

  • startAt: Timestamp (in ms) of starting date.
  • endAt: Timestamp (in ms) of end date.
  • type: Metrics type (url | referrer | browser | os | device | country | event).
  • unit: (optional) Time unit (year | month | hour | day).
  • timezone: (optional) Timezone (ex. America/Los_Angeles).
  • url: (optional) Name of URL.
  • referrer: (optional) Name of referrer.
  • pageTitle: (optional) Name of page title.
  • os: (optional) Name of operating system.
  • browser: (optional) Name of browser.
  • device: (optional) Name of device (ex. Mobile)
  • country: (optional) Name of country.
  • region: (optional) Name of region/state/province.
  • city: (optional) Name of city.

Sample response

[
    {x: "/", y: 46}
    {x: "/docs", y: 17}
    {x: "/download", y: 14}
]
  • x: Unique value, depending on metric type (url | referrer | browser | os | device | country | event).
  • y: Number of visitors.