---
title: Query analytics summary
---

[Skip to content](#_top)

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

[Analytics Query](https://developers.cloudflare.com/api/go/resources/analytics_query)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Query analytics summary

client.AnalyticsQuery.Summary(ctx, dataset, params) (\*[AnalyticsQuerySummaryResponse](<https://developers.cloudflare.com/api/go/resources/analytics_query#(resource)%20analytics_query%20%3E%20(model)%20AnalyticsQuerySummaryResponse%20%3E%20(schema)>), error)

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

Returns aggregate summary stats for a dataset. Includes current-period and previous-period totals for trend comparison.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



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

**Example:**<code>X-Auth-Email: user@example.com</code>

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

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

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

`Zero Trust Read`

##### ParametersExpand Collapse

dataset string

[Link to this property](<#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20dataset%20%3E%20(schema)>)

<details>

<summary>

params AnalyticsQuerySummaryParams

</summary>

AccountID param.Field\[string]

Path param: Cloudflare account identifier.

maxLength32

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

<details>

<summary>

Filters param.Field\[\[]AnalyticsQuerySummaryParamsFilter]

Body param: Filters to apply before aggregating results.

</summary>

Name string

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

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20name">Link to this property</a>

Op string

Filter operator. Common values: <code>eq</code>, <code>neq</code>, <code>in</code>, <code>not_in</code>, <code>gt</code>, <code>lt</code>, <code>gte</code>, <code>lte</code>.

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20op">Link to this property</a>

<details>

<summary>

Values \[]AnalyticsQuerySummaryParamsFiltersValueUnion

Values to match against. Type depends on the column.

</summary>

One of the following:

UnionString

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%200">Link to this property</a>

UnionBool

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%201">Link to this property</a>

UnionFloat

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%202">Link to this property</a>

</details>

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters%20%3E%20(schema)%20%3E%20(items)%20%3E%20(property)%20values">Link to this property</a>

</details>

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20filters">Link to this property</a>

From param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/analytics_query/methods/summary#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20from%20%3E%20(schema)">Time</a>]

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

formatdate-time

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20from">Link to this property</a>

GroupBy param.Field\[\[]string]

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

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20groupBy">Link to this property</a>

Stats param.Field\[\[]string]

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

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20stats">Link to this property</a>

To param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/analytics_query/methods/summary#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20to%20%3E%20(schema)">Time</a>]

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

formatdate-time

<a href="#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default%20%3E%20(param)%20to">Link to this property</a>

</details>

[Link to this property](<#(resource)%20analytics_query%20%3E%20(method)%20summary%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type AnalyticsQuerySummaryResponse struct{…}

</summary>

CurrentTotal \[]map\[string, unknown]

Aggregated stats for the requested time range.

<a href="#(resource)%20analytics_query%20%3E%20(model)%20AnalyticsQuerySummaryResponse%20%3E%20(schema)%20%3E%20(property)%20currentTotal">Link to this property</a>

PreviousTotal \[]map\[string, unknown]

Aggregated stats for the equivalent preceding time range, for trend comparison.

<a href="#(resource)%20analytics_query%20%3E%20(model)%20AnalyticsQuerySummaryResponse%20%3E%20(schema)%20%3E%20(property)%20previousTotal">Link to this property</a>

</details>

[Link to this property](<#(resource)%20analytics_query%20%3E%20(model)%20AnalyticsQuerySummaryResponse%20%3E%20(schema)>)

### Query analytics summary

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"
  "time"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.AnalyticsQuery.Summary(
    context.TODO(),
    "access-logins",
    cloudflare.AnalyticsQuerySummaryParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      Filters: cloudflare.F([]cloudflare.AnalyticsQuerySummaryParamsFilter{}),
      From: cloudflare.F(time.Now()),
      GroupBy: cloudflare.F([]string{}),
      Stats: cloudflare.F([]string{"attemptsTotal"}),
      To: cloudflare.F(time.Now()),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.CurrentTotal)
}
```

200 example

400 example

400 example

403 example

403 example

```
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "API in beta: expect breaking changes."
    }
  ],
  "result": {
    "currentTotal": [
      {
        "attemptsTotal": 48291
      }
    ],
    "previousTotal": [
      {
        "attemptsTotal": 41033
      }
    ]
  },
  "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": [
    {
      "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
}
```

##### Returns Examples

200 example

400 example

400 example

403 example

403 example

```
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "API in beta: expect breaking changes."
    }
  ],
  "result": {
    "currentTotal": [
      {
        "attemptsTotal": 48291
      }
    ],
    "previousTotal": [
      {
        "attemptsTotal": 41033
      }
    ]
  },
  "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": [
    {
      "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
}
```