Analytics Queries API

Query analytics metrics and events from PULSE

Analytics Queries API

Query aggregated metrics and analytics data from PULSE.

Endpoint

GET /api/v1/stats

Authentication

Authorization: Bearer YOUR_API_KEY

Query Parameters

ParameterTypeRequiredDescription
site_idstringSite identifier
metricstringMetric name
start_datenumberStart timestamp (ms)
end_datenumberEnd timestamp (ms)
periodstringTime period: 1h, 24h, 7d, 30d
group_bystringGroup by: hour, day, device_type, country
countrystringFilter by country code
device_typestringFilter by device type

Metrics

Basic Metrics:

MetricDescription
event_countTotal number of events
unique_usersCount of unique users
unique_sessionsCount of unique sessions
avg_session_durationAverage session length in seconds

Custom Metrics:

MetricDescription
event_count_by_typeEvents grouped by type
bounce_ratePercentage of single-event sessions
conversion_ratePercentage of sessions with target event

Response

{
  "success": true,
  "data": {
    "metric": "event_count",
    "value": 1234,
    "period": "24h",
    "site_id": "site_abc123",
    "breakdown": [
      {
        "timestamp": 1703001234567,
        "value": 142
      }
    ]
  },
  "timestamp": 1703001234567
}

Examples

Basic Query

curl "https://api.example.com/api/v1/stats?site_id=site_abc123&metric=event_count" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "success": true,
  "data": {
    "metric": "event_count",
    "value": 1234,
    "timestamp": 1703001234567
  }
}

Time Series Query

curl "https://api.example.com/api/v1/stats?site_id=site_abc123&metric=event_count&group_by=hour&period=24h" \
  -H "Authorization: Bearer YOUR_API_KEY"

Filtered Query

curl "https://api.example.com/api/v1/stats?site_id=site_abc123&metric=event_count&country=US&device_type=mobile" \
  -H "Authorization: Bearer YOUR_API_KEY"

Status Codes

CodeMeaning
200Success
400Bad request (invalid parameters)
401Unauthorized
404Site not found

Next Steps

Last updated: April 3, 2026