---
title: Query analytics timeseries
---

[Skip to content](#%5Ftop) 

[API Reference](https://developers.cloudflare.com/api/typescript)

[Analytics Query](https://developers.cloudflare.com/api/typescript/resources/analytics%5Fquery)

Copy Markdown

Open in **Claude**

Open in **ChatGPT**

Open in **Cursor**

---

**Copy Markdown**

**View as Markdown**

# Query analytics timeseries

client.analyticsQuery.timeseries(stringdataset, AnalyticsQueryTimeseriesParams { account\_id, filters, from, 4 more } params, RequestOptionsoptions?): [AnalyticsQueryTimeseriesResponse](https://developers.cloudflare.com/api/typescript/resources/analytics%5Fquery#%28resource%29%20analytics%5Fquery%20%3E%20%28model%29%20analytics%5Fquery%5Ftimeseries%5Fresponse%20%3E%20%28schema%29) { resolution, slots } 

POST/accounts/{account\_id}/analytics/query/{dataset}/timeseries

Returns time-bucketed analytics data for a dataset. Includes time slots, each containing the requested stats, group-by dimensions, and resolution-controlled bucket size (e.g. `hour`, `day`).

##### Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. [Create a token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).

**Example:**`Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY`

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**`X-Auth-Email: user@example.com`

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**`X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194`

##### Accepted Permissions (at least one required)

`Zero Trust Read`

##### ParametersExpand Collapse 

dataset: string

params: AnalyticsQueryTimeseriesParams { account\_id, filters, from, 4 more } 

account\_id: string

Path param: Cloudflare account identifier.

maxLength32

filters: Array<Filter\>

Body param: Filters to apply before aggregating results.

name: string

Specifies the column name to filter on. Requires a valid column for the target dataset (e.g. `country`, `allowed`, `appId`).

op: string

Filter operator. Common values: `eq`, `neq`, `in`, `not_in`, `gt`, `lt`, `gte`, `lte`.

values: Array<string | boolean | number\>

Values to match against. Type depends on the column.

One of the following:

string

boolean

number

from: string

Body param: The start of the query time range (inclusive). RFC3339 format with timezone is required (e.g. `2024-11-05T00:00:00Z`).

formatdate-time

groupBy: Array<string\>

Body param: Specifies the column names to group results by. Requires valid columns for the target dataset.

resolution: string

Body param: Time bucket size for grouping results. Controls the granularity of the returned time slots.

stats: Array<string\>

Body param: Specifies the stat names to include in results. Requires valid stats for the target dataset (e.g. `attemptsTotal`, `bytesTotal`).

to: string

Body param: Specifies the end of the query time range (exclusive). Requires RFC3339 format with timezone.

formatdate-time

##### ReturnsExpand Collapse 

AnalyticsQueryTimeseriesResponse { resolution, slots } 

resolution: string

The resolution used for time bucketing.

slots: Array<Record<string, unknown\>\>

Time-bucketed result rows. Each slot contains a `time_bucket` field plus the requested stats and group-by dimensions.

### Query analytics timeseries

TypeScript

HTTPHTTP

TypeScriptTypeScript

PythonPython

GoGo

TerraformTerraform

```
import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const response = await client.analyticsQuery.timeseries('shadow_it', {
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  filters: [
    {
      name: 'allowed',
      op: 'eq',
      values: [true],
    },
  ],
  from: '2024-11-01T00:00:00Z',
  groupBy: ['country', 'allowed'],
  resolution: 'day',
  stats: ['attemptsTotal'],
  to: '2024-11-08T00:00:00Z',
});

console.log(response.resolution);
```

200 example

400 example

400 example

401 example

403 example

403 example

```
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "API in beta: expect breaking changes."
    }
  ],
  "result": {
    "resolution": "hour",
    "slots": [
      {
        "appName": "Slack",
        "bytesTotal": 1048576,
        "time_bucket": "2024-11-05T00:00:00Z"
      },
      {
        "appName": "Slack",
        "bytesTotal": 2097152,
        "time_bucket": "2024-11-05T01:00:00Z"
      }
    ]
  },
  "success": true
}
```

```
{
  "errors": [
    {
      "code": 11005,
      "message": "art.api.parameter.invalid"
    }
  ],
  "messages": [
    {
      "code": 1002,
      "message": "Parameter 'from' has invalid value '2024-11-05 00:00:00'. Should be of type: 'RFC3339'"
    }
  ],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11005,
      "message": "art.api.parameter.invalid"
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "API in beta: expect breaking changes."
    }
  ],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11003,
      "message": "art.api.resource.insufficient_permissions"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11003,
      "message": "art.api.resource.insufficient_permissions"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11003,
      "message": "art.api.resource.insufficient_permissions"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
```

##### Returns Examples

200 example

400 example

400 example

401 example

403 example

403 example

```
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "API in beta: expect breaking changes."
    }
  ],
  "result": {
    "resolution": "hour",
    "slots": [
      {
        "appName": "Slack",
        "bytesTotal": 1048576,
        "time_bucket": "2024-11-05T00:00:00Z"
      },
      {
        "appName": "Slack",
        "bytesTotal": 2097152,
        "time_bucket": "2024-11-05T01:00:00Z"
      }
    ]
  },
  "success": true
}
```

```
{
  "errors": [
    {
      "code": 11005,
      "message": "art.api.parameter.invalid"
    }
  ],
  "messages": [
    {
      "code": 1002,
      "message": "Parameter 'from' has invalid value '2024-11-05 00:00:00'. Should be of type: 'RFC3339'"
    }
  ],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11005,
      "message": "art.api.parameter.invalid"
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "API in beta: expect breaking changes."
    }
  ],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11003,
      "message": "art.api.resource.insufficient_permissions"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11003,
      "message": "art.api.resource.insufficient_permissions"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
```

```
{
  "errors": [
    {
      "code": 11003,
      "message": "art.api.resource.insufficient_permissions"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
```