Elixir client for the bunny.net API.
Which client do I need?
bunny.net has several services with different authentication and base URLs. Each gets its own client:
| Client | Auth | Use for |
|---|---|---|
Bunnyx.new/1 | Account API key | CDN, DNS, storage zones, video libraries, billing, shield, edge scripting, magic containers |
Bunnyx.Storage.new/1 | Storage zone password | File upload/download/delete in edge storage |
Bunnyx.S3.new/1 | Zone name + password (SigV4) | S3-compatible storage operations |
Bunnyx.Stream.new/1 | Library API key | Video CRUD, upload, collections, captions |
Most users only need Bunnyx.new/1. Use the others when working directly with
files (Storage/S3) or videos (Stream).
Creating a client
client = Bunnyx.new(api_key: "sk-...")The client holds a configured Req.Request struct. Reuse it across calls to
share the connection pool:
{:ok, zones} = Bunnyx.PullZone.list(client)
{:ok, zone} = Bunnyx.PullZone.get(client, 12345)For one-off calls, you can pass options directly — a throwaway client is created:
{:ok, zones} = Bunnyx.PullZone.list(api_key: "sk-...")Error handling
All functions return {:ok, result} or {:error, %Bunnyx.Error{}}. The error
struct includes the HTTP status code (or nil for network errors) and a message.
Main API modules (use Bunnyx.new/1)
Bunnyx.PullZone— CDN pull zones and edge rulesBunnyx.DnsZone— DNS zones, DNSSEC, export/importBunnyx.DnsRecord— DNS records within a zoneBunnyx.StorageZone— storage zone managementBunnyx.VideoLibrary— Stream video library managementBunnyx.Purge— cache invalidationBunnyx.Statistics— account-wide statisticsBunnyx.Shield— WAF, rate limiting, bot detection, access listsBunnyx.EdgeScript— edge scripting (code, releases, secrets, variables)Bunnyx.MagicContainers— containerized apps at the edgeBunnyx.Billing— billing details and invoicesBunnyx.Account— affiliate, audit log, searchBunnyx.Logging— CDN access logs and origin error logsBunnyx.ApiKey— API key listingBunnyx.Country— country list for geo-blockingBunnyx.Region— edge region list
Separate client modules
Bunnyx.Storage— edge storage file operations (own auth + base URL)Bunnyx.S3— S3-compatible storage with AWS SigV4 signingBunnyx.Stream— video CRUD, upload, collections, captions (own auth + base URL)
Summary
Types
@type t() :: %Bunnyx{req: Req.Request.t()}
Functions
Creates a new API client.
Options
:api_key(required) — your bunny.net API key:receive_timeout— default socket receive timeout in milliseconds:finch— a custom Finch pool name:req_opts— additional Req options merged into the request (e.g.[redirect: false])
Examples
client = Bunnyx.new(api_key: "sk-...")
# With custom timeout and Req options
client = Bunnyx.new(api_key: "sk-...", receive_timeout: 30_000, req_opts: [retry: false])