Read-only CLI for Cloudflare analytics, logs, security events, DNS, and zone management.
Needs Bun. If you don't have it:
curl -fsSL https://bun.sh/install | bashThen:
git clone git@github.com:CogappLabs/cloudflare-cli.git
cd cloudflare-cli
bun installThen either put cfa on your PATH:
bun linkThis symlinks ~/.bun/bin/cfa to cli.ts in this repo, so edits take effect
on the next run with no build step. The repo is the install: move or delete it
and cfa breaks.
Or skip the link and run it from the repo folder:
bun run cli.ts zones listBoth forms take the same arguments; substitute bun run cli.ts for cfa in
every example below.
-
Click Create Token → Create Custom Token
-
Name it something like "Read analytics and logs"
-
Add these permissions (all Read):
Scope Permission Level Needed by Account Intel Read intel ipZone Zone Read zones list,zones get,intel ipZone DNS Read dns list,dns getZone Analytics Read analytics traffic,analytics top,security allowedZone Zone WAF Read security rulesZone Logs Read logs http,analytics bots,security eventsZone Firewall Services Read security events(see note)auth statuscalls the token-verify endpoint, which any token can call on itself, so it needs no permission of its own.Firewall Services is not used by any REST call here (
security rulesuses the modern Rulesets API, under Zone WAF). Cloudflare's GraphQL gating on thefirewallEventsAdaptivedataset is inconsistent, so it is kept to avoid a confusing 403 onanalytics bots/security events. -
Under Zone Resources, select Include → All zones (or specific zones)
-
Click Continue to summary → Create Token
-
Copy the token and save it:
cfa auth login
The token is stored at
~/.config/cf-cli/token.json. Alternatively, set theCF_API_KEYenvironment variable.
cfa auth login # Save API token
cfa auth status # Verify token
cfa zones list # List all zones
cfa zones get -z ZONE # Zone details
cfa analytics traffic -z ZONE # HTTP request analytics
cfa analytics bots -z ZONE # Bot score distribution
cfa analytics top -z ZONE --by ip # Top N by dimension
cfa logs http -z ZONE # HTTP request logs (Enterprise)
cfa security events -z ZONE # Security/firewall events
cfa security allowed -z ZONE # Allowed-through traffic (high volume first)
cfa security rules -z ZONE # List WAF rulesets
cfa security rules -z ZONE --id RULESET # Show individual rules in a ruleset (rate limit rules include requests, period, characteristics)
cfa intel ip --ip 1.2.3.4 # IP intelligence (threat, ASN, geo)
cfa dns list -z ZONE # List DNS records
cfa dns get -z ZONE --id RECORD_ID # Single record details
All commands support --json / -j for JSON output.