QueriesExecute public query
Queries

Execute public query

Execute an analytics query using a client's publishable key. Scoped to the client associated with the key. Supports the same query syntax as the admin endpoint but with client-level permissions.

curl -X POST "https://api.mythic-analytics.com/api/v1/public/query" \
  -H "Content-Type: application/json" \
  -H "X-Publishable-Key: YOUR_API_KEY" \
  -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
/public/query
POST
Security Scheme
API Key (header: X-Publishable-Key)
X-Publishable-Keystring
Required

Client publishable key. Format: pk_...

Client publishable key. Format: pk_...
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

PublishableKeyHeader
header
X-Publishable-Keystring
Required

API Key for authentication. Client publishable key. Format: pk_...

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