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.3.0
822 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
82 /100 Excellent
Development Activity 76
Maintenance 92
Community 72
Maturity 48
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 82
Code Quality 85
Innovation 85
Learning Curve 88

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
100%
Other

Activepieces

AI Assistants · Automation · Mcp

25,195

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
TypeScript 100%
Updated yesterday
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

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
74
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated today
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

29,041

"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
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated today
TypeScript
85%
GPL 3.0

Notesnook

File Storage · Note Taking · Security

14,822

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

View details
91
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 85%
JavaScript 12%
Updated today
TypeScript
94%
MIT

open-seo

Developer Tools · Marketing

24,707

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
74
Dependency
Built with
TypeScript 94%
Updated yesterday
TypeScript
81%
MIT

OpenCode

AI Code Assistants

220,711

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
TypeScript 81%
MDX 16%
Updated today
TypeScript
48%
MIT

supermemory

AI Development · AI Memory · Note Taking

31,370

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

View details
88
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 48%
MDX 32%
Python 17%
Updated today
TypeScript
84%
Other

twenty

CRM

59,615

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
TypeScript 84%
MDX 14%
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