
Cloudflare Has a Free API: Here's How to Use It for DNS and CDN Automation
Cloudflare's API gives you full control over DNS records, firewall rules, caching, Workers, and analytics — all on the free plan. You can automate everything you'd normally do in the dashboard. Why Use the Cloudflare API? Automate DNS record management across domains Purge cache programmatically after deployments Manage firewall rules and rate limiting Deploy Cloudflare Workers via API Monitor traffic analytics and security events Getting Started Get your API token from dash.cloudflare.com > My Profile > API Tokens: export CF_TOKEN = "your-api-token" # List zones (domains) curl -s -H "Authorization: Bearer $CF_TOKEN " \ "https://api.cloudflare.com/client/v4/zones" | jq '.result[] | {name: .name, id: .id, status: .status}' # List DNS records curl -s -H "Authorization: Bearer $CF_TOKEN " \ "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" | jq '.result[] | {type: .type, name: .name, content: .content, proxied: .proxied}' Python Client import requests class CloudflareClient
Continue reading on Dev.to DevOps
Opens in a new tab



