Cloudflare.NET SDK

A comprehensive C# client library for the Cloudflare REST API. Cloudflare does not provide an official .NET SDK, this project aims to fill that gap.

Build Status License

Packages

Cloudflare.NET.Api

Core REST API client for Cloudflare services including Zones, DNS, Security, and R2 bucket management.

dotnet add package Cloudflare.NET.Api NuGet

Cloudflare.NET.R2

High-level S3-compatible client for R2 object storage with multipart upload support.

dotnet add package Cloudflare.NET.R2 NuGet

Cloudflare.NET.Analytics

GraphQL client for querying Cloudflare Analytics API datasets.

dotnet add package Cloudflare.NET.Analytics NuGet

Example

// 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);
}

Features

Strongly-typed API

Full IntelliSense support with comprehensive XML documentation for every method, parameter, and model. All Cloudflare API responses are deserialized into rich .NET types with proper nullability annotations.

CI/CD Pipeline

Every commit triggers automated builds and tests. Releases are published automatically to NuGet.

Resilience Built-in

Production-ready resilience via Polly: automatic retries with exponential backoff, circuit breaker for fault tolerance, proactive throttling based on rate limit headers, and configurable timeouts per request.

Multi-account Support

Manage multiple Cloudflare accounts with named clients and keyed services. Perfect for multi-tenant applications or agencies managing client accounts with isolated configuration per client.

S3-Compatible R2

High-level R2 client with intelligent multipart uploads for large files, presigned URLs for direct browser uploads, and automatic retry handling. Compatible with S3 tools and workflows.

Testable by Design

Developed test-first with integration tests running against real Cloudflare APIs and unit tests validating request/response handling. All tests execute on every commit via CI.

Supported Frameworks

Package .NET 8 .NET 9 .NET 10 Strong Named
Cloudflare.NET.Api ✅ ✅ ✅ ✅
Cloudflare.NET.R2 ✅ ✅ ✅ ✅
Cloudflare.NET.Analytics ✅ ✅ ✅ ❌*

* Cloudflare.NET.Analytics cannot be strong-named because its dependency (GraphQL.Client) is not strong-named.

Contributing

We welcome contributions! Whether it's bug reports, feature requests, documentation improvements, or code contributions, we appreciate your help making the SDK better.