Repository navigation
v0.1.0
First release of vgi-cloudflare, a read-only VGI worker that lets you query the Cloudflare API from DuckDB/Haybarn as ordinary tables. It covers zones, DNS, Zero Trust, Workers, security, traffic analytics and Radar, and every answer comes live from Cloudflare's REST and GraphQL APIs using your own API token.
What's inside
- About 2,000 catalog objects under
cloudflare.<schema>.<object>:- Tables are the unscoped starting points, such as
cloudflare.zones.zonesandcloudflare.accounts.accounts. - List functions take the ids from their URL as arguments, so one statement fans out across every zone. An example is
cloudflare.dns.records(zone_id, type := 'A'). - Lookup functions fetch one object by id. An example is
cloudflare.dns.record(zone_id, id); an unknown id returns no row.
- Tables are the unscoped starting points, such as
- Read-only by construction. The client only sends
GETs and GraphQL queries, and ids that go into URL paths are percent-encoded. - Credentials come from a DuckDB secret:
CREATE SECRET (TYPE cloudflare, api_token '...'). A legacy Global API Key with an email also works.
Composed examples
Each of these is listed on the objects and schemas it uses, and in vgi.example_queries:
- DNS-only proxiable records across every zone combines
zones.zoneswithdns.records. - Zone security posture shows each zone's SSL mode, Always Use HTTPS setting and DNSSEC status. It combines
zones.zones,zones.setting(used twice) anddns.dnssec. - Each zone's DNS record count next to a week of requests and its cache-hit share combines
zones.zones,dns.recordsandanalytics.http_requests_daily.
Quick start
You need a VGI 3 client such as Haybarn 2.0.0rc11 or newer.
LOAD vgi;
ATTACH 'cloudflare' (TYPE vgi,
LOCATION 'launch:uvx --from git+https://github.com/Query-farm/vgi-cloudflare@v0.1.0 vgi-cloudflare');
CREATE SECRET cf (TYPE cloudflare, api_token '<your-api-token>');
SELECT name, status FROM cloudflare.zones.zones;The worker is not published to PyPI. Install it from this repository as shown above.
Known limits
- You need a Cloudflare API token, and every query is a live API call, so Cloudflare's rate limits apply. The "Read all resources" token template covers nearly everything. An object your token can't reach fails with Cloudflare's own permission error.
- It is read-only: there are no writes.
- Some analytics and Radar datasets depend on your plan or entitlements.
- Building the catalog takes a couple of seconds on a cold start. Use
launch:to keep one warm worker that every connection shares.