
Cloudflare Has a Free API — DNS, Analytics, and CDN Management Without the Dashboard
Cloudflare API Is Surprisingly Powerful Cloudflare free plan includes API access to DNS management, analytics, cache purging, and more. No paid plan needed for most operations. Setup import requests API_TOKEN = " your_cloudflare_api_token " HEADERS = { " Authorization " : f " Bearer { API_TOKEN } " , " Content-Type " : " application/json " } BASE = " https://api.cloudflare.com/client/v4 " Create a token at dash.cloudflare.com/profile/api-tokens. List All Zones (Domains) def list_zones (): r = requests . get ( f " { BASE } /zones " , headers = HEADERS ) zones = r . json ()[ " result " ] return [{ " name " : z [ " name " ], " id " : z [ " id " ], " status " : z [ " status " ]} for z in zones ] for z in list_zones (): print ( f " { z [ name ] } ( { z [ status ] } ) — { z [ id ] } " ) Manage DNS Records def list_dns ( zone_id ): r = requests . get ( f " { BASE } /zones/ { zone_id } /dns_records " , headers = HEADERS ) return [{ " type " : d [ " type " ], " name " : d [ " name " ], " conten
Continue reading on Dev.to Tutorial
Opens in a new tab




