Official SDKs and tools

SDKs, CLI and Terraform

Official libraries are maintained by the team that builds the API. All of them retry 429 and 5xx responses with exponential backoff, send idempotency keys and ship with types.

JavaScript / TypeScript3.4.1

Install
npm install @cachebz/sdk
Example
import { CacheBz } from "@cachebz/sdk";

const cbz = new CacheBz({ token: process.env.CACHEBZ_TOKEN });

const purge = await cbz.purge.create("site_7Hq2xK", { tags: ["catalog"] });
await cbz.purge.wait(purge.id); // resolves when all 52 locations ack

Python2.9.0

Install
pip install cachebz
Example
from cachebz import Client

client = Client()  # reads CACHEBZ_TOKEN from the environment

for site in client.sites.list():
    print(site.id, site.hostname, site.plan)

client.purge.create("site_7Hq2xK", urls=["https://www.example.com/"])

Gov1.12.3

Install
go get github.com/cachebz/cachebz-go
Example
client := cachebz.NewClient(os.Getenv("CACHEBZ_TOKEN"))

dep, err := client.Deploys.Create(ctx, "site_7Hq2xK", cachebz.DeployParams{
    Config:  string(configBytes),
    Message: "release 2291",
})
if err != nil {
    log.Fatal(err)
}
fmt.Println("deployed version", dep.Version)

PHP1.6.2

Install
composer require cachebz/cachebz-php
Example
$cbz = new CacheBz\Client(getenv('CACHEBZ_TOKEN'));

// Purge an article and its listing pages after publishing
$cbz->purge->create('site_7Hq2xK', [
    'tags' => ['article-1842', 'homepage'],
]);

All SDKs are licensed under Apache 2.0. Report problems to support@cache.bz.

CLI

A single static binary for Linux, macOS and Windows. Built for laptops and CI alike: it reads CACHEBZ_TOKEN and exits non-zero on failure.

CLI
curl -fsSL https://get.cache.bz/cli | sh      # Linux, macOS
brew install cachebz/tap/cachebz               # Homebrew
scoop install cachebz                          # Windows

cachebz login
cachebz deploy --message "release 2291"
cachebz purge --tag catalog --wait
cachebz logs tail --filter 'status >= 500'

Terraform provider

Manage sites, certificates, tokens and WAF rules alongside the rest of your infrastructure. Existing sites can be imported.

Deploying from CI

Keep cachebz.toml in your repository and deploy it with your application.

main.tf
terraform {
  required_providers {
    cachebz = { source = "cachebz/cachebz", version = "~> 2.3" }
  }
}

resource "cachebz_site" "www" {
  hostname = "www.example.com"
  origin   = "origin.example.com"
  shield   = "auto"
  config   = file("${path.module}/cachebz.toml")
}

output "edge_target" {
  value = cachebz_site.www.edge_target
}
CI
# .github/workflows/cdn.yml
- name: Deploy CDN config
  run: cachebz deploy --message "${{ github.sha }}"
  env:
    CACHEBZ_TOKEN: ${{ secrets.CACHEBZ_TOKEN }}