Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

GraphQL Analytics API Queries, Datasets, Limits, and Schema Discovery

How Cloudflare’s GraphQL Analytics API works: one endpoint, query shape, datasets, auth, limits, errors, and how to explore the schema.

This page summarizes Cloudflare documentation for the GraphQL Analytics API: programmatic access to the same analytics that power many dashboard views across HTTP traffic, security, load balancing, Zero Trust Gateway, Workers, Stream, and other products.

The GraphQL Analytics API provides data regarding HTTP requests passing through Cloudflare’s network, as well as data from specific products, such as Firewall or Load Balancing. Network Analytics users also have access to packet-level data. Use the GraphQL Analytics API to select specific datasets and metrics of interest, filter and aggregate the data along various dimensions, and integrate the results with other applications.

— Cloudflare, GraphQL Analytics API

GraphQL Analytics API endpoint: what you POST and when to use it

Section titled “GraphQL Analytics API endpoint: what you POST and when to use it”

The GraphQL Analytics API answers when you need custom reports, SIEM ingestion, or automation instead of fixed dashboard charts. Cloudflare exposes one HTTPS endpoint for all analytics queries:

https://api.cloudflare.com/client/v4/graphql

GraphQL differs from a traditional API: it has one single endpoint: https://api.cloudflare.com/client/v4/graphql. You pass the query parameters as a JSON object in the payload of a POST request to this endpoint.

— Cloudflare, GraphQL Analytics API

Each request is JSON with query (the GraphQL document, usually as a single-line string) and variables (values for $placeholders). You can call it with curl, a GraphQL client, or the in-browser GraphQL API Explorer described in Cloudflare’s changelog.

Query structure: viewer, zones, accounts, filter, and limit

Section titled “Query structure: viewer, zones, accounts, filter, and limit”

A typical Cloudflare GraphQL analytics query has four layers: root viewer, scope (zones or accounts), a dataset node, and the fields you want back.

A typical query against the Cloudflare GraphQL schema is made up of four main components: viewer - is the root node, zones or accounts - indicate the scope of the query… data node or dataset… fieldset.

— Cloudflare, Querying basics

For nodes such as firewallEventsAdaptive, filter and limit are required; orderBy is optional but typed when used. The Compose a query in GraphiQL guide walks through choosing a dataset via autocomplete and reading required parameters in the Documentation Explorer.

Zone-scoped analytics use zoneTag (your zone ID). Many account-level products (D1, KV, R2, Gateway, Privacy Proxy, Workflows) require accountTag instead—see each product’s metrics page, for example Gateway analytics or D1 metrics.

Example: WAF events from firewallEventsAdaptive

Section titled “Example: WAF events from firewallEventsAdaptive”
query ASingleDatasetExample($zoneTag: string, $start: Time, $end: Time) {
viewer {
zones(filter: { zoneTag: $zoneTag }) {
firewallEventsAdaptive(
filter: { datetime_gt: $start, datetime_lt: $end }
limit: 2
orderBy: [datetime_DESC]
) {
action
datetime
host: clientRequestHTTPHost
}
}
}
}

Variables (UTC, Z suffix):

{
"zoneTag": "<zone-tag>",
"start": "2020-08-03T02:07:05Z",
"end": "2020-08-03T17:07:05Z"
}

Security Events notes that GraphQL uses firewallEventsAdaptive; Security Analytics primarily uses httpRequestsAdaptive / httpRequestsAdaptiveGroups.

Datasets (tables): Adaptive, Groups, and raw nodes

Section titled “Datasets (tables): Adaptive, Groups, and raw nodes”

Dataset names encode sampling and aggregation, which is how you pick the right table for “per-request detail” versus “rolled-up metrics.”

Suffix / pattern Meaning Typical use
Adaptive (no Groups) Raw-ish rows, adaptive sampling Investigate individual events or nested structures
AdaptiveGroups Aggregated adaptive data Dashboards, top-N, time buckets
Product prefix (e.g. loadBalancingRequests*) Product-specific domain Load Balancing, Bot Analytics, etc.

Nodes that represent data acquired using adaptive sampling incorporate the Adaptive suffix… Nodes that represent aggregated data include the Groups suffix… Raw data nodes… do not incorporate the Groups suffix.

— Cloudflare, Datasets (tables)

Load balancing analytics shows both patterns: loadBalancingRequestsAdaptiveGroups for counts per pool and colo, and loadBalancingRequestsAdaptive for per-request pool health and avgRttMs. Cloudflare cautions that avgRttMs is monitor RTT used in steering, not the raw RTT of every user request.

Newer security context on HTTP request datasets includes fields such as securityAction, securitySource on httpRequestsAdaptive / httpRequestsAdaptiveGroups, and description on firewall event datasets (security fields update). API Shield adds webAssetsOperationId and webAssetsLabelsManaged (API Shield changelog).

If you still use deprecated httpRequests1mByColoGroups, migrate to httpRequestsAdaptiveGroups—see HTTP Requests by Colo Groups to HTTP Requests by Adaptive Groups.

Authentication: API token, GraphiQL headers, and permissions

Section titled “Authentication: API token, GraphiQL headers, and permissions”

GraphQL Analytics API authentication is the same as other Cloudflare API access: Bearer token (recommended) or legacy email + global API key headers in clients like GraphiQL.

For GraphiQL, set endpoint https://api.cloudflare.com/client/v4/graphql and header Authorization: Bearer {your-analytics-token} as described in Configure GraphQL client endpoint and HTTP headers.

Product docs repeat permission needs:

Get started links authentication, querying basics, schema exploration, clients, and curl.

Run queries: curl, GraphiQL, GraphQL API Explorer, and dashboard capture

Section titled “Run queries: curl, GraphiQL, GraphQL API Explorer, and dashboard capture”

Execute a GraphQL query with curl shows piping a JSON body with query and variables to the endpoint, with newlines stripped from the query string when needed.

echo '{ "query": "{viewer { ... }}", "variables": { "zoneTag": "<zone-tag>" } }' | tr -d '\n' | curl --silent \
https://api.cloudflare.com/client/v4/graphql \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data @-

GraphQL is a self-documenting protocol. You can use any GraphQL client to explore the schema and available fields.

— Cloudflare, GraphQL clients (TURN analytics)

Explore the GraphQL schema documents browsing types, filters, and datasets in GraphiQL’s Documentation Explorer. Introspection notes the schema is dynamic (70+ datasets), query-only (no mutations), and may mark beta nodes in descriptions.

The GraphQL API Explorer (also in product analytics changelog) offers in-browser schema docs, autocomplete, OAuth sign-in, and “Run in GraphQL API Explorer” from doc examples (code block guidelines).

Capture GraphQL queries with Chrome DevTools explains filtering the Network tab for graphql, copying the Payload query, and reusing it after you change dashboard filters—useful when you want parity with Network Analytics or other dashboard views.

Schema discovery and per-dataset limits: introspection and settings

Section titled “Schema discovery and per-dataset limits: introspection and settings”

Beyond introspection, the settings node returns your enabled flag, retention, max time window, page size, and field caps per dataset.

users can use the Settings node that is available for both zones and accounts scopes.

— Cloudflare, Settings node

Example fields: enabled, maxPageSize, maxNumberOfFields, notOlderThan, maxDuration. Querying Firewall Events with GraphQL recommends querying settings.firewallEventsAdaptive before wide time ranges so you avoid errors like cannot request data older than 2678400s.

Limits adds global rules: up to 10 zones per zone-scoped query, one account per account-scoped query, and caps on how many nodes/scopes you combine in one request. Per-plan differences apply to historical range and available datasets; adaptive datasets such as httpRequestsAdaptiveGroups retain at least 31 days on every plan.

Confidence intervals on sampled count and sum

Section titled “Confidence intervals on sampled count and sum”

For adaptive (sampled) datasets, you can request statistical confidence intervals on count and sum fields by passing a confidence level between 0 and 1 (e.g. 0.95). If you omit it, no intervals are returned.

Confidence intervals provide a statistical range around sampled results, helping verify accuracy and quantify uncertainty.

— Cloudflare, New Confidence Intervals in GraphQL Analytics API

Details live under GraphQL Analytics API features (Confidence Intervals).

Pagination is limit + orderBy + filters—there are no cursors. Nested Structures covers array fields in raw datasets (e.g. rule matches) and map fields in aggregated datasets (e.g. countryMap).

Error responses: HTTP status vs GraphQL errors

Section titled “Error responses: HTTP status vs GraphQL errors”

in contrast to the common REST approach, a 200 response can contain an error, conforming to the GraphQL specification.

— Cloudflare, Error responses

Responses include an errors array (message, path, timestamp) that is null on success. A multi-dataset query fails entirely if any sub-query fails (Querying basics).

Customer Metadata Boundary (CMB) and empty results

Section titled “Customer Metadata Boundary (CMB) and empty results”

With Customer Metadata Boundary enabled, some fields and datasets are region-bound. Queries for US-only datasets from an EU CMB configuration can return empty results even when traffic exists.

GraphQL datasets under Metadata Boundary lists which nodes are US and EU vs US only (Load Balancing, Stream, many Workers zone metrics, RUM, etc.). Get started also describes dashboard “data unavailable” messages tied to CMB and region.

Section titled “Related API Shield topic: GraphQL malicious query protection (origin GraphQL, not Analytics API)”

Do not confuse GraphQL Analytics API (read analytics) with API Shield GraphQL protection (inspect your origin’s GraphQL POST traffic). API Shield customers can read apiGatewayGraphqlQueryAnalyticsGroups via the same Analytics API endpoint to size depth/limits, then enforce rules on cf.api_gateway.graphql.query_size, query_depth, and parsed_successfully for paths ending in /graphql (Configure GraphQL malicious query protection via the API, GraphQL malicious query protection).

  • Using analytics counts for billing—totals include traffic excluded from billable usage (e.g. some attack traffic).
  • Wrong scope ID—zoneTag vs accountTag; account products error or return empty when swapped (Email Service metrics is zone-level; D1/KV are account-level).
  • Missing required filter / limit—GraphQL validation errors before any data returns.
  • Time range beyond notOlderThan / maxDuration—query settings first for datasets like firewallEventsAdaptive.
  • Assuming US-only datasets work in EU CMB—check GraphQL datasets.
  • Treating sampled adaptive counts as exact—use confidence intervals when provided, or compare with dashboard views.
  • Multi-dataset requests—one failing node aborts the whole query; split critical pulls if needed.

Further walkthroughs: GraphQL Analytics API tutorials (Firewall events, Workers, Magic Transit/WAN tunnels, Access logins, etc.). Types of analytics positions this API as the replacement for the legacy Zone Analytics API (migration guides).

  1. Create an API token with Analytics Read (or the product-specific permission from your product doc, e.g. Gateway analytics).
  2. In GraphiQL or Explore the GraphQL schema, connect to https://api.cloudflare.com/client/v4/graphql with Authorization: Bearer <token> and confirm introspection returns datasets.
  3. Run a minimal query from Querying basics for your zone or account; verify errors is null and rows match a dashboard view for the same window.
  4. Query settings { <yourDataset> { enabled notOlderThan maxDuration maxPageSize } } per Settings node and confirm your time filter fits maxDuration.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will follow up.