
Cloudflare Api
Automate Cloudflare D1, R2, KV, Workers, Vectorize, Queues, and Durable Objects with REST curl patterns wrangler does not cover.
Overview
Cloudflare API is an agent skill most often used in Build (also Operate infra, Ship launch) that documents REST curl patterns for D1, R2, KV, Workers, and related Cloudflare platform APIs beyond wrangler.
Install
npx skills add https://github.com/jezweb/claude-skills --skill cloudflare-apiWhat is this skill?
- Unified base URL: api.cloudflare.com/client/v4/accounts/{account_id}/...
- D1: list databases, parameterized query POST, and batch SQL via API
- Coverage for R2, KV, Workers, Vectorize, Queues, and Durable Objects patterns
- Bearer token auth with jq-friendly list/query examples for scripts
- Explicitly for operations wrangler does not expose—bulk and cross-DB automation
- Seven named platform areas: D1, R2, KV, Workers, Vectorize, Queues, and Durable Objects
Adoption & trust: 647 installs on skills.sh; 841 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You know wrangler but hit limits for bulk D1 queries, cross-service automation, or API-only operations from scripts and agents.
Who is it for?
Indie builders on Cloudflare Workers stack who script D1/R2/KV maintenance, debugging, and bulk data tasks alongside wrangler.
Skip if: Greenfield apps that only need wrangler init and deploy with no custom API automation.
When should I use this skill?
You need REST API patterns for Cloudflare developer platform bulk ops, D1 queries, or automation wrangler does not expose.
What do I get? / Deliverables
You run account-scoped REST calls with correct endpoints, auth, and parameterized SQL patterns ready to paste into automation or agent tasks.
- Ready-to-run curl recipes for list, query, and batch D1 operations
- Account-scoped endpoint patterns for R2, KV, Workers, Vectorize, Queues, and Durable Objects
- Parameterized SQL examples for safer agent-generated queries
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Bulk SQL, cross-database ops, and automation scripts land in Build when you wire platform services—not only at deploy time. Integrations fits because the skill is REST API reference for account-scoped services, complementing wrangler CLI workflows.
Where it fits
POST parameterized SQL to D1 while building the Workers API layer.
Run list-and-query curls for nightly DB size and table checks without the dashboard.
Smoke-test production D1 data via API before switching traffic.
How it compares
Companion to wrangler CLI—use API patterns when wrangler does not expose the operation you need.
Common Questions / FAQ
Who is cloudflare-api for?
Solo builders shipping on Cloudflare who want copy-paste REST examples for D1, R2, KV, Workers, and related services from terminal or agent workflows.
When should I use cloudflare-api?
In Build integrations while wiring edge databases and queues, in Operate infra for scripted maintenance, and at Ship launch when validating data via API before go-live.
Is cloudflare-api safe to install?
The skill describes API calls that use your tokens; store secrets outside the repo and review the Security Audits panel on this Prism page before piping tokens into agents.
SKILL.md
READMESKILL.md - Cloudflare Api
# Developer Platform API Patterns REST API patterns for Cloudflare's developer platform services: D1, R2, KV, Workers, Vectorize, Queues, and Durable Objects. These complement what wrangler does — use the API for bulk operations, cross-database queries, automation scripts, and operations wrangler doesn't expose. All endpoints use: `https://api.cloudflare.com/client/v4/accounts/{account_id}/...` --- ## D1 (SQL Database) ### List Databases ```bash curl -s "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ | jq '.result[] | {uuid, name, num_tables, file_size, version}' ``` ### Query a Database ```bash # Run SQL directly via API (useful for scripts, automation, debugging) curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DB_ID/query" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"sql": "SELECT * FROM users LIMIT 10"}' \ | jq '.result[0].results' # With parameters (prevents SQL injection) curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DB_ID/query" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"sql": "SELECT * FROM users WHERE email = ?1", "params": ["jez@example.com"]}' \ | jq '.result[0].results' ``` ### Raw SQL via API (Batch) ```bash # Run multiple statements in one call curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DB_ID/raw" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "sql": "INSERT INTO users (id, name, email) VALUES (?1, ?2, ?3); INSERT INTO users (id, name, email) VALUES (?4, ?5, ?6);", "params": ["id1", "Alice", "alice@example.com", "id2", "Bob", "bob@example.com"] }' ``` ### Export/Backup a D1 Database ```bash # Export as SQL dump curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DB_ID/export" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"output_format": "file"}' \ | jq '.result' # Then poll for the export to complete and download ``` ### Cross-Database Operations Wrangler can only talk to one database at a time. The API lets you script across multiple: ```python import json, urllib.request def query_d1(db_id, sql, params=None): url = f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/d1/database/{db_id}/query" payload = {"sql": sql} if params: payload["params"] = params req = urllib.request.Request(url, data=json.dumps(payload).encode(), headers={"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) return json.loads(urllib.request.urlopen(req).read())["result"][0]["results"] # Query across multiple D1 databases for db_name, db_id in databases.items(): users = query_d1(db_id, "SELECT COUNT(*) as count FROM users") print(f"{db_name}: {users[0]['count']} users") ``` ### D1 Gotchas via API - Max 100KB per single SQL statement - Max 1000 bound parameters per query - `query` endpoint returns results; `raw` endpoint for DDL/DML without result sets - Export is async — returns a bookmark to poll, not the dump directly --- ## R2 (Object Storage) ### List Buckets ```bash curl -s "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/r2/buckets" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ | jq '.result.buckets[] | {name, creation_date}' ``` ### Create Bucket ```bash curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/r2/buckets" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name": "my-bucket", "locationHint": "apac"}' ``` ### List Objects in a Bucket (S3 API) R2 objects are managed via the S3-compatible API, not the Cloudflare API: ```bash # Using AWS CLI with R2