cloudflare-typescript

The official TypeScript/JavaScript SDK for the Cloudflare API, generated from Cloudflare's OpenAPI spec with typed coverage of 2,500+ endpoints.

SDK
npm
v7.1.0
805stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity96
Maintenance100
Community68
Maturity48
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture82
Code Quality85
Innovation85
Learning Curve88

Cloudflare’s official TypeScript library provides typed, promise-based access to the entire Cloudflare REST API from Node.js, Deno, Bun, and browser environments. It is generated directly from Cloudflare’s OpenAPI specification using Stainless, so every one of the API’s 2,500+ endpoints — zones, DNS, Workers, R2, D1, WAF, Zero Trust, AI Gateway, and more — ships with matching request and response types, kept automatically in sync as Cloudflare’s API evolves.

Beyond raw type coverage, the client handles the practical concerns of talking to a large REST API: automatic retries with exponential backoff for transient and rate-limit errors, configurable timeouts, cursor- and offset-based auto-pagination via async iterators, streaming file uploads, and a tree-shakable import path so bundles only include the resource classes actually used.

What You Get

  • Typed client classes for all ~2,500 Cloudflare API endpoints (zones, DNS, Workers, R2, D1, WAF, Zero Trust, AI Gateway, and more), generated from the official OpenAPI spec
  • Automatic retry, timeout, and cursor/offset auto-pagination handling built into every resource method
  • A tree-shakable import path (cloudflare/tree-shakable) plus a bundled CLI (bin/cli) for bundle-size-sensitive or scripted use
  • Exported TypeScript types for every request param and response shape, with docstrings that surface in editor hovers
  • File upload helpers accepting File, fetch Response, fs.ReadStream, or a bundled toFile utility for endpoints like KV values and R2 objects

Common Use Cases

  • Zone and DNS automation as part of infrastructure-as-code pipelines
  • Workers/Pages deployment tooling that provisions KV namespaces, D1 databases, and R2 buckets
  • Zero Trust and WAF policy management from internal admin tools instead of the dashboard
  • Multi-tenant SaaS platforms provisioning per-customer zones, custom hostnames, and SSL certificates at signup
  • Internal analytics dashboards built on top of Cloudflare’s Analytics endpoints

Under The Hood

Architecture The client is a single Cloudflare class (src/client.ts, ~1,800 lines) that wires together roughly 200 per-resource modules under src/resources/, each extending a shared APIResource base (src/resource.ts). Requests flow through core/api-promise.ts, which wraps the underlying fetch call in an APIPromise exposing .asResponse()/.withResponse(), while core/pagination.ts supplies several pagination strategies (cursor, cursor-after, single-page, V4 array) that resource methods return directly. Platform differences (Node, Deno, Bun, browser) are isolated behind internal/shims.ts and internal/detect-platform.ts. A separate tree-shakable.ts entry point builds partial clients from an explicit list of resource classes, so changing core plumbing affects every resource uniformly while individual resource modules stay independent of each other.

Tech Stack Written in TypeScript 5.8 with zero runtime dependencies ("dependencies": {} in package.json) — all HTTP, retry, and pagination logic is hand-rolled internally rather than pulled from third-party packages. Builds run through tsc-multi to emit CommonJS, ESM, and Deno-targeted output from one source tree; tests run under Jest with the SWC transform for speed. The package ships a bin/cli entry point and is published to npm as cloudflare via a Stainless-managed release pipeline.

Code Quality The repo carries an unusually large test suite for a client library — 871 auto-generated per-resource test files under tests/api-resources/ (one suite per API resource, exercising real request/response shapes) plus focused unit tests for base64 handling, header building, multipart form encoding, path building, query-string stringification, and file uploads. Errors are modeled as typed APIError subclasses (BadRequestError, AuthenticationError, RateLimitError, InternalServerError, etc.) mapped from HTTP status codes, with retry logic applied automatically to transient failures. CI runs on GitHub Actions with dedicated workflows for breaking-change detection and Semgrep security scanning in addition to the standard test/lint pipeline.

API Design The public surface favors resource-namespaced calls (client.zones.create(...)) over a single flat method list, keeping ~2,500 endpoints navigable via autocomplete. Auto-pagination works through for await...of on list methods or explicit hasNextPage()/getNextPage() control, retries and timeouts are configurable globally or per-call, and .asResponse()/.withResponse() give access to raw headers without extra plumbing. A companion api.md (10K+ lines) and MIGRATION.md document every method and version-to-version breaking change, which offsets the fact that the generated resource code itself is comment-sparse.

Used by 8 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

24,298

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript99%
Updated today
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,133

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
69
Repo Health
81
Technical
65
Dependency
Built with
TypeScript91%
Updated 1 weeks ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

27,743

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
88
Repo Health
73
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
85%
GPL 3.0

Notesnook

Note Taking · File Storage · Security

14,533

End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.

View details
90
Repo Health
84
Technical
60
Dependency
Built with
TypeScript85%
JavaScript12%
Updated 2 days ago
TypeScript
96%
MIT

open-seo

Marketing · Developer Tools

17,505

Pay-as-you-go open source SEO platform with MCP integration — keyword research, rank tracking, backlinks, site audits, and AI brand visibility in one self-hosted tool.

View details
83
Repo Health
79
Technical
77
Dependency
Built with
TypeScript96%
Updated 4 days ago
TypeScript
75%
MIT

OpenCode

AI Code Assistants

205,271

A fully open-source AI coding agent built for the terminal, with a TUI, desktop app, web client, plugin system, and SDK — one of the most-starred AI coding agents on GitHub.

View details
89
Repo Health
76
Technical
66
Dependency
Built with
TypeScript75%
MDX21%
Updated today
TypeScript
76%
MIT

supermemory

AI Development · Productivity · Note Taking

29,245

The state-of-the-art memory and context engine for AI agents — ranked #1 on all three major AI memory benchmarks.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript76%
MDX16%
Updated 5 days ago
TypeScript
80%
Other

twenty

CRM

56,361

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript80%
MDX17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search