{"slug": "bunnyx-a-bunny-net-elixir-client-library", "title": "bunnyx: a bunny.net Elixir client library", "summary": "**Summary:**  \nThe article introduces *bunnyx*, an open-source Elixir client library for interacting with the bunny.net CDN API. Developed by the author for use in their uptime monitoring project Larm, the library offers comprehensive support for managing CDN pull zones, DNS zones, storage zones, and video libraries, with a focus on flexibility, thorough testing, and adherence to Elixir library conventions.", "body_md": "bunnyx: a bunny.net Elixir client library\nbunny.net is a CDN service provider with lots of extra bells and whistles, most similar to Cloudflare in feature set, but maintained by a European company. Unlike Cloudflare, they’re not free, but they are cheap enough that it doesn’t really matter. Unless you’re making very heavy use of their service, you won’t be paying more than the minimum €1 each month. And as a paying customer, your relationship is a lot different than it is as a non-paying user of Cloudflare.\nI’ve been using bunny.net for a lot of things I’ve been building recently, including the landing page and status page feature for Larm, the uptime monitoring project I’ve been working on. As part of that work, I wanted a feature rich client library for interacting with the extensive bunny.net API.\nIntroducing: bunnyx\nThis is not the first Elixir library for interacting with the bunny API. I ended up rolling my own because I wanted something that was flexible enough to fit into my system design. The version that I built into Larm wasn’t as feature rich as what I’ve ended up open sourcing here, but once I had something going, I just got into the flow of testing through the API endpoints end to end, and documenting and verifying each one. And suddenly I had a whole feature complete library.\nbunnyx is built with a special focus on the Elixir library guidelines. This means that it avoids certain things: there’s no application config and there’s no application supervisor starting automatically. Instead, it follows the design of the excellent Req\nlibrary by Wojtek Mach. Not to mention that it internally makes heavy use of it!\nAdditionally I invested a lot of time and energy into the test suite. Apart from extensive unit test coverage, I built a series of Livebook runbooks that you can feed an API key into and execute each and every request scenario, even running through the whole book to automatically create, read, update, and delete, resources. This means you can easily verify the behavior of bunnyx\nagainst the actual bunny API.\nQuickstart\n# Before running this, you'll need:\n# - A bunny.net account and API key (from the Account API section of the dashboard)\n# - A storage region code — DE, NY, LA, or SG. See:\n# https://docs.bunny.net/reference/storagezonepublic_add\n# - A globally unique storage zone name\n# - A globally unique pull zone name\n# - The file you want to upload\nclient = Bunnyx.new(api_key: \"sk-...\")\n# 1. Create a storage zone to hold the files\n{:ok, storage_zone} = Bunnyx.StorageZone.create(client, name: \"my-assets\", region: \"DE\")\n# 2. Point a pull zone at the storage zone so the files are served from the CDN\n{:ok, pull_zone} = Bunnyx.PullZone.create(client,\nname: \"my-assets-cdn\",\nstorage_zone_id: storage_zone.id\n)\n# 3. Upload a file via the separate storage client (its own auth and base URL)\nstorage = Bunnyx.Storage.new(storage_key: storage_zone.password, zone: storage_zone.name)\n{:ok, nil} = Bunnyx.Storage.put(storage, \"/images/logo.png\", File.read!(\"logo.png\"))\ncdn_url = \"https://#{pull_zone.name}.b-cdn.net/images/logo.png\"\n# Your file is now live at cdn_url\n# 4. Replace the file, then purge so the new version is served immediately\n{:ok, nil} = Bunnyx.Storage.put(storage, \"/images/logo.png\", File.read!(\"new-logo.png\"))\n{:ok, nil} = Bunnyx.Purge.url(client, cdn_url)\nIf you want to wrap things up for convenience, create your own wrapper module.\ndefmodule MyApp.Bunny do\ndef create_pullzone(name, origin_url) do\nclient = Bunnyx.new(api_key: api_key!())\nBunnyx.PullZone.create(client, name: name, origin_url: origin_url)\nend\ndef api_key! do\nApplication.fetch_env!(:my_app, :bunny_api_key)\nend\nend\nFeature set\nMain API (Bunnyx.new/1\n)\n-\nCDN:\nPullZone\n(CRUD, hostnames, SSL, edge rules, referrers, IP blocking, statistics) -\nDNS:\nDnsZone\n(CRUD, DNSSEC, export/import, statistics),DnsRecord\n(add, update, delete) -\nStorage management:\nStorageZone\n(CRUD, statistics, password reset) -\nVideo libraries:\nVideoLibrary\n(CRUD, API keys, watermarks, referrers, DRM stats) -\nCache:\nPurge\n(URL and pull zone purging) -\nSecurity:\nShield\n(zones, WAF rules, rate limiting, access lists, bot detection, metrics, API Guardian) -\nCompute:\nEdgeScript\n(scripts, code, releases, secrets, variables),MagicContainers\n(apps, registries, containers, endpoints, volumes) -\nAccount:\nBilling\n(details, summary, invoices),Account\n(affiliate, audit log, search),ApiKey\n,Logging\n(CDN + origin logs) -\nReference:\nStatistics\n(global),Country\n,Region\nSeparate clients\n-\nEdge storage (\nBunnyx.Storage\n): upload, download, delete, list files -\nS3 (\nBunnyx.S3\n): PUT, GET, DELETE, HEAD, COPY, ListObjectsV2, multipart uploads -\nStream (\nBunnyx.Stream\n): video CRUD, upload, fetch, collections, captions, thumbnails, re-encode, transcription, smart actions, analytics, oEmbed\nWhat next\nFirst of all I want to give a huge shoutout to Wojtek Mach for setting an incredible example for the Elixir community on how to design libraries. Req is one of my favorite reference repos and I keep coming back to it and discovering new gems.\nSecondly, I want to say that Bunny CDN is a great service and I appreciate having a genuinely powerful alternative to Cloudflare, provided by a European company.\nCheck out the repo, try out the library, and let me know how you get on!\nWritten by Johanna Larsson. Thoughts on this post? Find me on Bluesky at @jola.dev. If you like my writing, consider supporting me on Github Sponsors and get a monthly newsletter with content from my blog.\nRelated posts\nHighest Random Weight in Elixir\nA description of HRW/rendezvous hashing and the HRW elixir library.\nBuilding for the joy of building\nMy path into programming and why I've been obsessed for 20 years.\nRunning local models on an M4 with 24GB memory\nExperiments with getting usable outputs out of local models on a standard Macbook", "url": "https://wpnews.pro/news/bunnyx-a-bunny-net-elixir-client-library", "canonical_source": "https://jola.dev/posts/bunnyx-bunny-net-elixir", "published_at": "2026-05-17 00:00:00+00:00", "updated_at": "2026-05-23 15:45:15.694535+00:00", "lang": "en", "topics": ["open-source", "developer-tools", "cloud-computing"], "entities": ["bunny.net", "bunnyx", "Elixir", "Larm", "Cloudflare"], "alternates": {"html": "https://wpnews.pro/news/bunnyx-a-bunny-net-elixir-client-library", "markdown": "https://wpnews.pro/news/bunnyx-a-bunny-net-elixir-client-library.md", "text": "https://wpnews.pro/news/bunnyx-a-bunny-net-elixir-client-library.txt", "jsonld": "https://wpnews.pro/news/bunnyx-a-bunny-net-elixir-client-library.jsonld"}}