Query the Cloudflare API from SQL: zones, DNS, accounts, security, Workers, Zero Trust, and traffic analytics as DuckDB tables and functions.
Read-only SQL access to a Cloudflare account through the Cloudflare REST and GraphQL APIs, fetched live on each query with the caller's API token (a DuckDB secret of TYPE cloudflare). Objects are grouped by product into schemas (dns, zones, accounts, security, workers, zero_trust, analytics, radar, and more). Most data is scoped to an account or zone: start from cloudflare.accounts.accounts or cloudflare.zones.zones to get ids. Scoped lists are functions of those ids β cloudflare.dns.records(zone_id) β taking a literal or, in a lateral join from cloudflare.zones.zones, every zone at once; their API filters are named arguments. Singular functions such as cloudflare.dns.record fetch one object by id. Traffic and security time series are in cloudflare.analytics; Internet-wide trends are in cloudflare.radar.
Getting started
Create a DuckDB secret of type cloudflare holding an API token (api_token), or a legacy global key
(api_key plus email). A read-only token from the "Read all resources" template covers every schema.
Data is fetched from Cloudflare at query time; nothing is cached or stored.
Shapes of object
| Shape |
Naming |
Called how |
| Table |
plural noun, no ids, e.g. cloudflare.zones.zones |
scanned like any table |
| List function |
plural noun, e.g. cloudflare.dns.records |
its URL ids as arguments, literal or per row; API filters as named arguments |
| Lookup function |
singular noun, e.g. cloudflare.dns.record |
path ids as arguments; 0 or 1 row |
| Analytics table |
cloudflare.analytics.* |
GraphQL rollups; the time range comes from the filter |
Notes
- Filters on a table's documented API filter columns are sent to Cloudflare; other filters run in DuckDB.
- Lookup functions return no row for an unknown id instead of failing, so they are safe in joins.
- Requests are retried on rate limiting (HTTP 429). Large analytics windows are split to avoid truncation.
Sources and references