Skip to main content
POST
/
analytics
/
query
Query analytics data
curl --request POST \
  --url https://openrouter.ai/api/v1/analytics/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "dimensions": [
    "model"
  ],
  "granularity": "day",
  "limit": 100,
  "metrics": [
    "request_count"
  ],
  "time_range": {
    "end": "2025-01-08T00:00:00Z",
    "start": "2025-01-01T00:00:00Z"
  }
}
'
{
  "data": {
    "data": [
      {
        "date__day": "2025-01-01T00:00:00.000Z",
        "request_count": 1500
      }
    ],
    "metadata": {
      "query_time_ms": 42,
      "row_count": 1,
      "truncated": false
    }
  }
}

Authorizations

Authorization
string
header
required

API key as bearer token in Authorization header

Body

application/json
metrics
string[]
required
Minimum array length: 1

Metric name

dimensions
string[]
Maximum array length: 2

Dimension to group by (up to 2). Use the /meta endpoint for available dimensions.

filters
object[]
Maximum array length: 20
granularity
string

Time granularity

Example:

"day"

group_limit
integer

Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified.

Example:

100

limit
integer

Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations.

order_by
object
time_range
object

Response

Analytics query results

data
object
required