Kenc.Cloudflare

Active

A modern .NET client library for the Cloudflare API, enabling programmatic management of DNS records, caching rules, and other Cloudflare features.

StatusActive
Last updatedSep 2, 2025
Tech stackC#, .NET, DNS, Cloudflare, API

Code Examples

Basic usage

// Create the client with API token authentication
var client = new CloudflareClient(new ApiTokenAuthentication("your-api-token"));
// Get zones (domains)
var zones = await client.Zones.GetZonesAsync();
foreach (var zone in zones)
{
Console.WriteLine($"Zone: {zone.Name}, Status: {zone.Status}");
}
// Get DNS records for a zone
var dnsRecords = await client.Dns.GetDnsRecordsAsync(zones.First().Id);
foreach (var record in dnsRecords)
{
Console.WriteLine($"Record: {record.Name}, Type: {record.Type}, Content: {record.Content}");
}

Create a DNS record

// Create the client
var client = new CloudflareClient(new ApiTokenAuthentication("your-api-token"));
// Get the zone ID for your domain
var zones = await client.Zones.GetZonesAsync(new ZoneFilter { Name = "example.com" });
var zoneId = zones.First().Id;
// Create a new DNS record
var newRecord = await client.Dns.CreateDnsRecordAsync(
zoneId,
new DnsRecordCreate
{
Type = "A",
Name = "api",
Content = "192.0.2.1",
Ttl = 120,
Proxied = true
});
Console.WriteLine($"Created record: {newRecord.Id}, {newRecord.Name}");

More examples on GitHub →