QueriesExecute query
Queries

Execute query

Execute an analytics query against a client's data. Supports aggregations, filters, grouping, and time-series analysis. Requires admin authentication.

curl -X POST "https://api.mythic-analytics.com/api/v1/query" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "client_id": "acme-retail",
  "metric": "page_views",
  "dimensions": [
    "day",
    "country"
  ],
  "filters": {
    "url_contains": "/products",
    "country": "US"
  },
  "period": "24h",
  "from": "2024-12-25T10:00:00Z",
  "to": "2024-12-25T10:00:00Z",
  "limit": 42
}'
{
  "success": true,
  "data": {
    "columns": [
      "day",
      "page_views"
    ],
    "rows": [
      [
        "2024-06-15",
        1420
      ],
      [
        "2024-06-16",
        1385
      ]
    ],
    "total": 30
  }
}
POST
/query
POST
Security Scheme
Bearer Tokenstring
Required

Admin API key as bearer token. Format: Bearer YOUR_ADMIN_KEY

Admin API key as bearer token. Format: Bearer YOUR_ADMIN_KEY
Content-Typestring
Required

The media type of the request body

Options: application/json
client_idstring
Required

Client identifier to query data for.

metricstring
Required

Metric to aggregate (e.g., page_views, unique_visitors, events).

dimensionsarray

Dimensions to group results by.

filtersobject

Key-value filters to narrow query scope.

periodstring

Time period. Default: 30d.

Options: 24h, 7d, 30d, 90d, custom
fromstring

Custom period start (required when period is custom).

Format: date-time
tostring

Custom period end (required when period is custom).

Format: date-time
limitinteger

Maximum number of result rows. Default 1000.

Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. Admin API key as bearer token. Format: Bearer YOUR_ADMIN_KEY

Body

application/json
client_idstring
Required

Client identifier to query data for.

metricstring
Required

Metric to aggregate (e.g., page_views, unique_visitors, events).

dimensionsarray

Dimensions to group results by.

filtersobject

Key-value filters to narrow query scope.

periodstring

Time period. Default: 30d.

Allowed values:24h7d30d90dcustom
fromstring

Custom period start (required when period is custom).

tostring

Custom period end (required when period is custom).

limitinteger

Maximum number of result rows. Default 1000.

Responses

successboolean
dataobject