Cloudflare.NET is a comprehensive C# client library for the Cloudflare REST API. It provides strongly-typed access to Cloudflare services including DNS management, Zone configuration, R2 object storage, Workers, WAF rules, and more. Built with testability and maintainability in mind.
Cloudflare does not provide an official .NET SDK or C# library. This project aims to fill that gap with a community-maintained alternative.
Documentation | Getting Started | API Reference
| Package | Description |
|---|---|
| Cloudflare.NET.Api | Core REST API client for Zones, DNS, Security, and R2 bucket management |
| Cloudflare.NET.R2 | High-level S3-compatible client for R2 object storage |
| Cloudflare.NET.Analytics | GraphQL client for Cloudflare Analytics API |
dotnet add package Cloudflare.NET.Api
dotnet add package Cloudflare.NET.R2 # Optional
dotnet add package Cloudflare.NET.Analytics # Optional// Register in Program.cs
builder.Services.AddCloudflareApiClient(builder.Configuration);
builder.Services.AddCloudflareR2Client(builder.Configuration);
// Inject and use
public class MyService(ICloudflareApiClient cf)
{
public async Task<DnsRecord?> FindRecordAsync(string zoneId, string hostname)
=> await cf.Zones.FindDnsRecordByNameAsync(zoneId, hostname);
}-
Strongly-typed API · Full IntelliSense with comprehensive XML documentation and proper nullability annotations
-
CI/CD Pipeline · Every commit triggers automated builds and tests; releases published automatically to NuGet
-
Resilience Built-in · Automatic retries, circuit breaker, rate limiting, and configurable timeouts via Polly
-
Multi-account Support · Named clients and keyed services for managing multiple Cloudflare accounts
-
Dependency Injection · First-class support for
Microsoft.Extensions.DependencyInjectionwithIHttpClientFactory -
S3-Compatible R2 · Intelligent multipart uploads, presigned URLs, and automatic retry handling
-
Testable by Design · Integration tests against real Cloudflare APIs and unit tests for request/response validation
Explore the Full Documentation →
Comprehensive guides, configuration options, multi-account setup, and more.
| API Family | Features |
|---|---|
| Zones | CRUD, Holds, Settings, Subscriptions, Cache Purge, Custom Hostnames (SaaS) |
| DNS | Record CRUD, Batch Operations, Import/Export, Record Scanning |
| Zone Security | IP Access Rules, Zone Lockdown, User-Agent Rules, WAF Rulesets |
| Accounts | Management, Members, Roles, Audit Logs, API Tokens, Subscriptions |
| Account Storage | R2 Buckets, R2 Custom Domains, R2 CORS, R2 Lifecycle Policies |
| Account Security | IP Access Rules, WAF Rulesets |
| Users | Profile Management, Memberships, Invitations, Audit Logs, API Tokens, Subscriptions |
| Workers | Routes (zone-scoped) |
| Turnstile | Widget CRUD, Secret Rotation |
| R2 Client | Upload, Download, Multipart, Presigned URLs, Batch Delete |
| Analytics | GraphQL queries for traffic, security, and R2 metrics |
See API Coverage for full details and roadmap.
| Package | .NET 8 | .NET 9 | .NET 10 | Strong Named |
|---|---|---|---|---|
| Cloudflare.NET.Api | ✅ | ✅ | ✅ | ✅ |
| Cloudflare.NET.R2 | ✅ | ✅ | ✅ | ✅ |
| Cloudflare.NET.Analytics | ✅ | ✅ | ✅ | ❌* |
*
Cloudflare.NET.Analyticscannot be strong-named because its dependency (GraphQL.Client) is not strong-named.
We welcome contributions! Whether it's bug reports, feature requests, or code contributions.
This project is licensed under the Apache 2.0 License.