Skip to main content

Get Realtime Data

Retrieve real-time visitor activity for a website, showing current active visitors and recent pageviews.
Realtime data shows activity from the last 5 minutes by default.

Endpoint

GET /api/realtime/{websiteId}

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

websiteId
string
required
Website UUID

Response

pageviews
array
Array of recent pageviews
sessions
array
Array of active sessions
visitors
number
Number of active visitors (unique sessions in the time window)
timestamp
number
Current server timestamp in milliseconds

Example Request

curl https://your-umami-instance.com/api/realtime/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

{
  "pageviews": [
    {
      "__id": "jj0e8400-e29b-41d4-a716-446655440014",
      "sessionId": "ff0e8400-e29b-41d4-a716-446655440010",
      "createdAt": "2024-03-15T14:35:42.000Z",
      "urlPath": "/products",
      "urlQuery": "category=electronics",
      "referrerDomain": "google.com",
      "pageTitle": "Products",
      "country": "US",
      "browser": "Chrome",
      "os": "Windows",
      "device": "desktop"
    },
    {
      "__id": "kk0e8400-e29b-41d4-a716-446655440015",
      "sessionId": "gg0e8400-e29b-41d4-a716-446655440011",
      "createdAt": "2024-03-15T14:36:15.000Z",
      "urlPath": "/",
      "urlQuery": "",
      "referrerDomain": "",
      "pageTitle": "Home",
      "country": "GB",
      "browser": "Safari",
      "os": "Mac OS",
      "device": "desktop"
    }
  ],
  "sessions": [
    {
      "__id": "ll0e8400-e29b-41d4-a716-446655440016",
      "sessionId": "ff0e8400-e29b-41d4-a716-446655440010",
      "createdAt": "2024-03-15T14:30:00.000Z",
      "country": "US",
      "browser": "Chrome",
      "os": "Windows",
      "device": "desktop"
    },
    {
      "__id": "mm0e8400-e29b-41d4-a716-446655440017",
      "sessionId": "gg0e8400-e29b-41d4-a716-446655440011",
      "createdAt": "2024-03-15T14:33:20.000Z",
      "country": "GB",
      "browser": "Safari",
      "os": "Mac OS",
      "device": "desktop"
    }
  ],
  "visitors": 2,
  "timestamp": 1710513400000
}

Polling for Updates

For live dashboards, poll this endpoint at regular intervals:
// Poll every 5 seconds
const websiteId = '550e8400-e29b-41d4-a716-446655440000';

setInterval(async () => {
  const response = await fetch(
    `https://your-umami-instance.com/api/realtime/${websiteId}`,
    {
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
      },
    }
  );
  
  const data = await response.json();
  updateDashboard(data);
}, 5000);

Use Cases

  • Real-time visitor dashboards
  • Live event monitoring
  • Current traffic analysis
  • Active user tracking
  • Live campaign monitoring

Time Window

The endpoint returns data from the last 5 minutes by default (defined by REALTIME_RANGE constant). This includes:
  • All pageviews in the last 5 minutes
  • All sessions with activity in the last 5 minutes
  • Current visitor count (unique sessions)

Error Responses

401
error
Unauthorized - You don’t have permission to view this website’s realtime data
Realtime data is useful for monitoring live traffic and detecting traffic spikes or issues in real-time.

Build docs developers (and LLMs) love