Python SDK for the Bunny CDN API
Project description
bunny-cdn-sdk
A typed Python SDK for the Bunny CDN REST API.
This package does not aim to cover every bunny.net API. It currently focuses on a narrow subset of the platform that is useful for CDN, DNS, storage-zone, and basic video-library workflows.
pip install bunny-cdn-sdk
pip install 'bunny-cdn-sdk[cli]' # includes CLI
Table of contents
Scope
Supported today:
- Core Platform API coverage for pull zones, storage zones, DNS zones, purge, regions, countries, statistics, billing, and stream video library CRUD.
- Edge Storage file operations through
StorageClient: upload, download, list, and delete. - Optional CLI coverage for the same implemented SDK operations.
Not supported yet:
- Core Platform API resources outside the current clients, including users, audit logs, search, API keys, and affiliate endpoints.
- Product APIs outside Core + Edge Storage file operations, including Origin Errors, the full Stream API surface beyond video library CRUD, Shield, Edge Scripting, and Magic Containers.
- Advanced Storage API capabilities beyond basic file management if Bunny adds endpoints that are not represented by
upload,download,list, anddelete.
If you need an endpoint that exists in the Bunny docs but not in this SDK, that endpoint is currently omitted rather than wrapped behind a partial or unstable abstraction.
Quick start
from bunny_cdn_sdk import CoreClient, StorageClient
# Core API — pull zones, storage zones, DNS, video libraries
core = CoreClient(api_key="your-api-key")
zones = core.list_pull_zones() # returns a list directly
# Storage API — file operations
storage = StorageClient(
zone_name="my-zone",
password="zone-password",
region="ny", # default: falkenstein
)
storage.upload("path/to/file.txt", b"hello")
storage.download("path/to/file.txt")
storage.list("path/")
storage.delete("path/to/file.txt")
CoreClient
core = CoreClient(api_key="...")
Pull Zones
core.list_pull_zones()
core.get_pull_zone(id)
core.create_pull_zone(**kwargs)
core.update_pull_zone(id, **kwargs)
core.delete_pull_zone(id)
core.purge_pull_zone_cache(id)
core.add_custom_hostname(id, hostname)
core.remove_custom_hostname(id, hostname)
core.add_blocked_ip(id, ip)
core.remove_blocked_ip(id, ip)
Storage Zones
core.list_storage_zones()
core.get_storage_zone(id)
core.create_storage_zone(**kwargs)
core.update_storage_zone(id, **kwargs)
core.delete_storage_zone(id)
DNS Zones
core.list_dns_zones()
core.get_dns_zone(id)
core.create_dns_zone(**kwargs)
core.update_dns_zone(id, **kwargs)
core.delete_dns_zone(id)
core.add_dns_record(zone_id, **kwargs)
core.update_dns_record(zone_id, record_id, **kwargs)
core.delete_dns_record(zone_id, record_id)
Video Libraries
core.list_video_libraries()
core.get_video_library(id)
core.create_video_library(**kwargs)
core.update_video_library(id, **kwargs)
core.delete_video_library(id)
Utilities
core.purge_url(url)
core.get_statistics(**kwargs)
core.get_billing()
core.list_countries()
core.list_regions()
Concurrent batch fetch
# Fetch specific pull zones concurrently by ID
zones = core.get_pull_zones([123, 456, 789])
# Or iterate through all pull zones across pages
for zone in core.iter_pull_zones():
print(zone["Name"])
StorageClient
from bunny_cdn_sdk import StorageClient
storage = StorageClient(
zone_name="my-zone",
password="zone-password",
region="falkenstein", # or: de, ny, la, sg, syd, uk, se, br, jh
)
storage.upload(path: str, data: bytes)
storage.download(path: str) -> bytes
storage.delete(path: str)
storage.list(path: str) -> list[dict]
Retry
from bunny_cdn_sdk import CoreClient, RetryTransport
import httpx
transport = RetryTransport(max_retries=5, backoff_base=0.5)
core = CoreClient(api_key="...", client=httpx.Client(transport=transport))
Or via constructor shorthand:
core = CoreClient(api_key="...", max_retries=5, backoff_base=0.5)
Retries on: 429 Too Many Requests, 5xx server errors, and network failures. Uses exponential backoff with jitter.
Exceptions
BunnySDKError
├── BunnyAPIError
│ ├── BunnyAuthenticationError # 401
│ ├── BunnyNotFoundError # 404
│ ├── BunnyRateLimitError # 429
│ └── BunnyServerError # 5xx
└── BunnyConnectionError
└── BunnyTimeoutError
from bunny_cdn_sdk import BunnyAPIError, BunnyAuthenticationError
try:
core.get_pull_zone(id=99999)
except BunnyAuthenticationError:
print("Invalid API key")
except BunnyAPIError as e:
print(f"API error {e.status_code}: {e}")
CLI
Install with the [cli] extra:
pip install 'bunny-cdn-sdk[cli]'
bunnycdn --api-key KEY COMMAND
Commands:
pull-zone Manage pull zones
storage-zone Manage storage zones
dns-zone Manage DNS zones
video-library Manage video libraries
storage Upload, download, list, delete files
purge Purge a URL from CDN cache
stats CDN statistics per pull zone
billing Account billing summary
Auth via env vars (recommended):
export BUNNY_API_KEY=your-api-key
export BUNNY_STORAGE_KEY=your-storage-password
export BUNNY_STORAGE_ZONE=your-zone-name
export BUNNY_STORAGE_REGION=falkenstein
bunnycdn pull-zone list
bunnycdn storage list path/
bunnycdn --json pull-zone list # raw JSON output
Requirements
- Python 3.12+
- httpx
CLI requirements are optional:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bunny_cdn_sdk-2.2.3.tar.gz.
File metadata
- Download URL: bunny_cdn_sdk-2.2.3.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e665ed7da4bd89babe3652ed4068f5e33d107e484cd73998b6b12bb303c6943c
|
|
| MD5 |
0be7c323a971cc0bb04d62e8fcaa4c99
|
|
| BLAKE2b-256 |
576122cbb2b4dcb9e9ba07a3267991303ea957246419688727b1f61a673025e2
|
Provenance
The following attestation bundles were made for bunny_cdn_sdk-2.2.3.tar.gz:
Publisher:
publish.yml on yolabingo/bunny-cdn-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bunny_cdn_sdk-2.2.3.tar.gz -
Subject digest:
e665ed7da4bd89babe3652ed4068f5e33d107e484cd73998b6b12bb303c6943c - Sigstore transparency entry: 1292639571
- Sigstore integration time:
-
Permalink:
yolabingo/bunny-cdn-python-sdk@1c4eba1d85718ab45ed23b92c7e025e450ebb032 -
Branch / Tag:
refs/tags/v2.2.3 - Owner: https://github.com/yolabingo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1c4eba1d85718ab45ed23b92c7e025e450ebb032 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bunny_cdn_sdk-2.2.3-py3-none-any.whl.
File metadata
- Download URL: bunny_cdn_sdk-2.2.3-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1d48460d621e5d17d058772e07af1af08b432943a801db26b5742838bd9871e
|
|
| MD5 |
401dccf1f27f3867fbffe50d797f5191
|
|
| BLAKE2b-256 |
594c8c42f586fa19e0ca29a2d4148fbb12e37a9ff44d3f4e61f29550f8f6e5ec
|
Provenance
The following attestation bundles were made for bunny_cdn_sdk-2.2.3-py3-none-any.whl:
Publisher:
publish.yml on yolabingo/bunny-cdn-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bunny_cdn_sdk-2.2.3-py3-none-any.whl -
Subject digest:
a1d48460d621e5d17d058772e07af1af08b432943a801db26b5742838bd9871e - Sigstore transparency entry: 1292639629
- Sigstore integration time:
-
Permalink:
yolabingo/bunny-cdn-python-sdk@1c4eba1d85718ab45ed23b92c7e025e450ebb032 -
Branch / Tag:
refs/tags/v2.2.3 - Owner: https://github.com/yolabingo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1c4eba1d85718ab45ed23b92c7e025e450ebb032 -
Trigger Event:
push
-
Statement type: