cf-box is a comprehensive, production-ready suite of Python tools designed to streamline and automate interactions with the Cloudflare API, enabling efficient management of multiple Cloudflare accounts and their associated resources.
- IP List Manager: Centrally manage multiple IP access rule lists across your Cloudflare accounts using a single, easy-to-maintain YAML configuration. Link
- Data Export: Export detailed data from all your Cloudflare accounts, including zones, DNS records, and settings, to various formats (JSON, CSV, Excel, PDF). Link
- Analytics Export: Fetch and export aggregated analytics data from Cloudflare using GraphQL
- Async/Await Support: Modern async architecture using aiohttp for improved performance
- Structured Logging: Professional logging with structlog for better observability
- Type Safety: Pydantic models for API response validation
- SQLAlchemy Integration: Secure database operations with parameterized queries
git clone https://github.com/fabriziosalmi/cf-box.git
cd cf-box
pip install -e ".[dev]"docker build -t cf-box .
docker run -e CLOUDFLARE_API_TOKEN=your_token cf-boxOr using Docker Compose:
docker-compose up cf-data-export- Set your Cloudflare API token:
export CLOUDFLARE_API_TOKEN=your_api_token_here-
Configure
config.yamlwith your settings -
Run the tools:
# Export Cloudflare data
cf-data-export
# Manage IP lists
cf-ip-manager
# Export analytics
cf-analyticspip install pre-commit
pre-commit installpytest# Format code
black cf_box/
# Lint code
ruff check cf_box/
# Type checking
mypy cf_box/The project follows a modern Python package structure:
cf_box/- Main package directoryclient.py- Async HTTP client for Cloudflare APImodels.py- Pydantic models for type safetydatabase.py- SQLAlchemy database operationspdf_generator.py- Template-based PDF generationlogging_config.py- Structured logging configurationdata_export.py- Data export moduleip_list_manager.py- IP list managementaggregated_analytics.py- Analytics export
- Backup via GitHub Actions: cloudflare-backup-actions
- WAF Control: wafcontrol
- Zone Control: zonecontrol
- mTLS with AWS: mtls-cloudflare-aws
- DNS Redundancy: dnscontrol-actions