Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/graphql-api/api.md
1# GraphQL Analytics API Reference23## Query Root45The schema has a single entry point: `Query.viewer`. Mutations are not supported.67```graphql8{9cost # uint64 -- query cost (returned in response)10viewer {11budget # uint64 -- remaining budget12zones(filter: { zoneTag: "..." }) { ... }13accounts(filter: { accountTag: "..." }) { ... }14}15}16```1718## Aggregation Fields1920Aggregated dataset nodes (`*Groups`) return these field categories. Not every node has all — use introspection to check.2122### count2324Total events in the group. Available on `*Groups` nodes but **not** on raw `*Adaptive` nodes (e.g., `workersInvocationsAdaptive` — use `sum { requests }` instead).2526### sum2728Cumulative metrics. Fields vary by dataset:2930```graphql31# HTTP requests32sum { edgeResponseBytes edgeRequestBytes visits edgeTimeToFirstByteMs originResponseDurationMs }3334# Workers invocations35sum { requests errors subrequests cpuTimeUs wallTime duration responseBodySize clientDisconnects requestDuration }36```3738### quantiles3940Percentile distributions (on datasets like `workersInvocationsAdaptive`). Available percentiles: P25, P50, P75, P90, P95, P99, P999 for `cpuTime`, `wallTime`, `requestDuration`, `duration`, `responseBodySize`.4142```graphql43quantiles { cpuTimeP50 cpuTimeP99 wallTimeP50 wallTimeP99 }44```4546### ratio, avg, uniq, confidence4748```graphql49ratio { status4xx status5xx } # float64 (0 to 1) -- HTTP datasets only50avg { sampleInterval } # useful for understanding sampling resolution51uniq { uniques } # unique IP count -- rollup datasets (*1hGroups, *1dGroups) only52confidence(level: 0.95) { # Adaptive datasets only; works on count and sum fields53count { estimate lower upper sampleSize }54}55```5657## Dimensions5859Dimensions are fields you can group by via the `dimensions` sub-selection.6061### Time Dimensions6263| Dimension | Granularity |64|-----------|------------|65| `date` | Day |66| `datetime` | Exact timestamp |67| `datetimeMinute` | 1 minute |68| `datetimeFiveMinutes` | 5 minutes |69| `datetimeFifteenMinutes` | 15 minutes |70| `datetimeHour` | 1 hour |7172Workers datasets also support `datetimeSixHours`.7374### HTTP Request Dimensions (httpRequestsAdaptiveGroups)757683 dimensions available. Key ones:7778| Dimension | Description |79|-----------|-------------|80| `clientCountryName` | Country of origin |81| `clientRequestHTTPHost` | Requested hostname |82| `clientRequestHTTPMethodName` | HTTP method |83| `clientRequestPath` | URI path |84| `edgeResponseStatus` | Edge HTTP status code |85| `cacheStatus` | Cache status (hit, miss, dynamic, etc.) |86| `coloCode` | Cloudflare datacenter IATA code |87| `clientIP` / `clientAsn` | Client IP address / ASN |88| `botScore` / `botManagementDecision` | Bot management score (0-99) / verdict |89| `wafAttackScore` / `securityAction` | WAF score / firewall action taken |90| `ja3Hash` / `ja4` | TLS fingerprints |91| `sampleInterval` | ABR sample interval |9293### Workers Dimensions (workersInvocationsAdaptive)9495`scriptName`, `scriptTag`, `scriptVersion`, `environmentName`, `status`, `usageModel`, `coloCode`, `dispatchNamespaceName`, `isDispatcher`9697### Firewall Dimensions (firewallEventsAdaptive)9899`action`, `source`, `ruleId`, `clientCountryName`, `clientIP`, `clientAsn`, `userAgent`100101## Filtering102103### Scope Filters104105```graphql106zones(filter: { zoneTag: "ZONE_ID" }) # up to 10 zones107zones(filter: { zoneTag_in: ["Z1", "Z2"] })108accounts(filter: { accountTag: "ACCOUNT_ID" }) # exactly 1 account109```110111### Dataset Filters112113**Always include a time range filter.** Multiple filters at the same level are implicitly AND-ed.114115```graphql116httpRequestsAdaptiveGroups(117filter: { datetime_gt: "2025-01-01T00:00:00Z", datetime_lt: "2025-01-02T00:00:00Z", clientCountryName: "US" }118limit: 1000119)120```121122### Filter Operators123124| Operator | Meaning | Example |125|----------|---------|---------|126| (none) | equals | `clientCountryName: "US"` |127| `_gt` / `_lt` | greater / less than | `datetime_gt: "..."` |128| `_geq` / `_leq` | greater/less or equal | `datetime_geq: "..."` |129| `_neq` | not equal | `cacheStatus_neq: "hit"` |130| `_in` / `_notin` | in / not in list | `clientCountryName_in: ["US", "GB"]` |131| `_like` / `_notlike` | SQL LIKE with `%` | `clientRequestPath_like: "/api/%"` |132| `_has` / `_hasall` / `_hasany` | array contains | `botDetectionIds_has: "abc"` |133134> `_notin` and `_notlike` are in the schema but not in official docs. Confirmed via introspection.135136### Boolean Operators (AND / OR)137138```graphql139# Explicit AND140filter: { AND: [{ datetime_gt: "..." }, { datetime_lt: "..." }, { clientCountryName: "US" }] }141142# Explicit OR143filter: { datetime_gt: "...", OR: [{ edgeResponseStatus: 403 }, { edgeResponseStatus: 429 }] }144```145146## Pagination & Sorting147148No cursor-based pagination. Use `limit`, `orderBy`, and filter-based offsets:149150```graphql151# First page152httpRequestsAdaptiveGroups(filter: { datetime_gt: "..." }, limit: 100, orderBy: [datetime_ASC])153154# Next page: filter by last seen value from previous page155httpRequestsAdaptiveGroups(filter: { datetime_gt: "2025-01-01T01:35:00Z" }, limit: 100, orderBy: [datetime_ASC])156```157158Sort with `orderBy: [field_ASC]` or `[field_DESC]`. Multiple sort fields supported.159160## Settings Node161162Query per-node limits and availability:163164```graphql165viewer { zones(filter: { zoneTag: "..." }) { settings {166httpRequestsAdaptiveGroups { enabled maxDuration maxNumberOfFields maxPageSize notOlderThan }167} } }168```169170## See Also171172- [README.md](README.md) - Overview, decision tree, dataset index173- [configuration.md](configuration.md) - Authentication, client setup, introspection queries174- [patterns.md](patterns.md) - Common query patterns (time-series, top-N, per-product)175- [gotchas.md](gotchas.md) - Rate limits, sampling, troubleshooting176