# Cloudflare

> Query your Cloudflare accounts, zones, DNS, security, and analytics as SQL tables

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/cloudflare.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `cloudflare`. Release: [v0.2.1](https://github.com/Query-farm/vgi-cloudflare/releases/tag/v0.2.1). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-cloudflare) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=cloudflare). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

Supply your own service credentials or required connection options before querying protected data.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

After installing VGI and attaching the connector, create the required secrets using your own values. Replace placeholders and omit unused optional parameters from the templates below.

### cloudflare

Cloudflare API credentials. Provide either api_token (preferred) or api_key + email (legacy Global API Key).

```json
[
  {
    "name": "api_token",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": null
  },
  {
    "name": "api_key",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": null
  },
  {
    "name": "email",
    "type": "VARCHAR",
    "required": false,
    "redact": false,
    "description": null
  }
]
```

```sql
CREATE SECRET cloudflare (
    TYPE cloudflare,
    api_token '<API_TOKEN>',  -- secret
    api_key   '<CLOUDFLARE_API_KEY>',  -- secret
    email     '<email>'
);
```

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### uvx

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

```sql
ATTACH 'cloudflare' AS cloudflare (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-cloudflare@v0.2.1 vgi-cloudflare'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'cloudflare' AS cloudflare (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-cloudflare:0.2.1'
);
```

## Find DNS records exposing unproxied origins

Service credentials required for this example: yes.

```sql
SELECT z.name AS zone, r.type, r.name AS record, r.content FROM cloudflare.zones.zones z, cloudflare.dns.records(z.id) r WHERE r.type IN ('A', 'AAAA', 'CNAME') AND r.proxiable AND NOT r.proxied ORDER BY zone, record, r.type
```

- [cloudflare.zones.zones — table](https://query.farm/products/orchard/connectors/cloudflare/objects/table.em9uZXM.em9uZXM.md): exact declaration for this example.
- [cloudflare.dns.records — table_function](https://query.farm/products/orchard/connectors/cloudflare/objects/table_function.ZG5z.cmVjb3Jkcw.md): exact declaration for this example.

Execution evidence: **not_captured**.

No executed result is recorded for this exact example. Catalog verification does not establish that this query ran.
Supply the required setup and verify your own execution before claiming success.

## Connector reference

### Cloudflare API for DuckDB

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

- [Cloudflare API reference](https://developers.cloudflare.com/api/) — the REST endpoints behind every table and function
- [GraphQL Analytics API](https://developers.cloudflare.com/analytics/graphql-api/) — the source of `cloudflare.analytics`
- [Cloudflare Radar](https://developers.cloudflare.com/radar/) — the Internet-wide data behind `cloudflare.radar`
- [Create an API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) — how to make the token the `cloudflare` secret holds
- [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) — the OpenAPI spec the worker's resources are generated from


## Find the exact SQL object

[Browse 1691 object declarations](https://query.farm/products/orchard/api/v1/connectors/cloudflare/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=cloudflare&q=cloudflare).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-cloudflare",
  "harvest": {
    "status": "ok",
    "method": "subprocess",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 1,
    "passed": 1,
    "failed": 0,
    "needs_credentials": 0,
    "location": "uvx --from git+https://github.com/Query-farm/vgi-cloudflare@v0.2.1 vgi-cloudflare",
    "transport": "subprocess",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:11:20+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
