Cloudflare D1 API logo

Cloudflare D1 API

Cloudflare D1 API

UnknownFreedeveloper-tools

Cloudflare D1 is Cloudflare globally distributed SQLite — millisecond access within Workers, global read replicas, SQL-compatible, generous free tier.

Use it when

Zero network latency within Workers

Watch for

Optimal only within Cloudflare Workers (external access via HTTP API)

First check

wrangler CLI: wrangler d1 create my-database. Configure D1 binding in wrangler.toml. In Workers: env.DB.prepare("SELECT * FROM users").all()

Auth
api_key
CORS
?
HTTPS
Yes
Signup
?
Protocol
REST, SQL
Pricing
freemium

Uptime · 30-day window

Health history will appear here after the next daily check.
01

About this API

D1 is Cloudflare's globally distributed SQLite database launched 2022, the relational DB part of Cloudflare's full-stack platform (Workers + R2 + KV + Durable Objects + D1 + Queues). Design core: (1) Based on SQLite (small, fast, single file); (2) Global read replicas (writes to primary region, reads distributed globally, app latency follows users); (3) Deep Cloudflare Workers integration (Worker-to-D1 call has no HTTP hop). vs. Turso: D1 is Cloudflare-exclusive (optimal only within Workers), Turso is cross-platform. vs. Vercel Postgres (Neon-based): D1 SQLite vs. Vercel Postgres. Generous free tier (100k reads + 50k writes/day), hobby / small SaaS perfectly sufficient. Cloudflare customers use D1 with Workers to build "zero cold-start + global < 50ms" apps.

02

What you can build

  • 1Cloudflare Workers application DB
  • 2Global users low-latency reads (per-region local replica)
  • 3Small SaaS / blog / SaaS dashboard backend
  • 4Serverless app SQL data storage
03

Strengths & limitations

Strengths

  • Zero network latency within Workers
  • Auto global read replicas
  • Generous free tier (100k reads + 50k writes/day)
  • Familiar SQL (SQLite-compatible)

Limitations

  • Optimal only within Cloudflare Workers (external access via HTTP API)
  • SQLite limitations (not for ultra-high concurrent writes)
  • 10GB per DB limit
04

Example request

Generic template — replace <endpoint> with the real path from the docs.
curl https://developers.cloudflare.com/d1/<endpoint> \
  -H "Authorization: Bearer $API_KEY"
# Some providers use X-Api-Key instead — verify in the docs.
05

Getting started

wrangler CLI: wrangler d1 create my-database. Configure D1 binding in wrangler.toml. In Workers: env.DB.prepare("SELECT * FROM users").all()

06

FAQ

D1 vs. Cloudflare KV?+

KV is simple key-value cache. D1 is real SQL DB (relations, JOINs, transactions).

Can D1 be used outside Workers?+

Yes via HTTP REST API, but latency is an order of magnitude higher than in-Worker direct calls.

07

Technical details

CORS: ?HTTPS: YesSignup: ?Open source: No
Auth type
api_key
Pricing
freemium
Rate limit
免费 100k reads + 50k writes/天
Protocols
REST, SQL
SDKs
javascript, typescript
08

Tags