v1

latestOpenAPI 3.1.02026-07-2419603.1 MB
Analytics

Execute Real-time query

API that allows querying the Real-time database directly. Please note that each request must be authenticated.

post/api/analytics/v1/real-time-query/

Request body

website_idstring uuid required

ID of a website or a meta site.

lookback_windowinteger required

Period of time (in minutes) to query. Example: lookback_window=10 means "last 10 minutes of data".

offsetinteger

Number of rows to skip before beginning to return rows.

limitinteger

Number of rows to return.

format'json' | 'json-kv' | 'csv' | 'xml'

Data format of a successful response (error responses are always in json).

column_format'id' | 'name'

Format of the columns header (in CSV responses) and metadata labels (in JSON responses). By default uses identifiers (id option), set to name to use human-readable names.

Example request

{
  "website_id": "70236925-724f-404e-b634-7b5633bc0bcc",
  "columns": [
    {
      "column_id": "device_type"
    },
    {
      "column_id": "revenue",
      "transformation_id": "sum"
    }
  ],
  "lookback_window": 42,
  "filters": {
    "operator": "and",
    "conditions": [
      {
        "column_id": "event_title",
        "condition": {
          "operator": "contains",
          "value": "test"
        }
      }
    ]
  },
  "metric_filters": {
    "operator": "and",
    "conditions": [
      {
        "column_id": "page_views",
        "condition": {
          "operator": "eq",
          "value": 42
        }
      }
    ]
  },
  "offset": 0,
  "limit": 100,
  "order_by": [
    [
      0,
      "desc"
    ],
    [
      1,
      "asc"
    ]
  ],
  "format": "json",
  "options": {
    "sampling": 0.2
  }
}

Response

OK

dataobject[]

Rows with results for the query.

Example response

{
  "data": [
    [
      [
        1,
        "Smartphone"
      ],
      0
    ],
    [
      [
        0,
        "Desktop"
      ],
      0
    ]
  ],
  "meta": {
    "columns": [
      "device_type",
      "revenue__sum"
    ],
    "scope": "Real-time event",
    "blended_datasets": [],
    "count": 2
  }
}