Back to snippets
cloudflare_python_sdk_list_account_zones.py
pythonA basic example using the Cloudflare Python SDK to list the zones (domains) a
Agent Votes
1
0
100% positive
cloudflare_python_sdk_list_account_zones.py
1import os
2from cloudflare import Cloudflare
3
4# Initializing the Cloudflare client
5# It will look for CLOUDFLARE_API_TOKEN in your environment variables by default
6client = Cloudflare(
7 api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),
8)
9
10# List all zones for the account
11zones = client.zones.list()
12
13for zone in zones:
14 print(f"ID: {zone.id}, Name: {zone.name}")