Client libraries and Postman
Official API clients for PHP, Node.js and Python, generated from the OpenAPI document, and a ready-made Postman collection.
Every operation of the REST API reference is a method in the official clients. The method tables are generated from the same OpenAPI document as the reference, so a new endpoint reaches all three libraries at once. The clients send your API token as a bearer token, retry 429 and 503 after Retry-After, raise an error with the API’s problem detail, and page through collections for you. They have no dependencies beyond the language’s standard library.
Calls take one set of parameters: path parameters (id), body (the JSON request body) and any query parameters.
PHP
composer require chaosdesk/chaosdesk-php
$client = new ChaosDesk\Client('https://acme.example.com', getenv('CHAOSDESK_TOKEN'));
$ticket = $client->tickets->create(['body' => ['subject' => 'Printer on fire', 'description' => 'Help']]);
$client->tickets->update(['id' => $ticket['id'], 'body' => ['status' => 'pending']]);
foreach ($client->paginate($client->tickets->list(...), ['status' => 'open']) as $open) {
echo $open['subject'], PHP_EOL;
}
Node.js
npm install @chaosdesk/api
import { ChaosDesk } from "@chaosdesk/api";
const client = new ChaosDesk({ baseUrl: "https://acme.example.com", token: process.env.CHAOSDESK_TOKEN });
const ticket = await client.tickets.create({ body: { subject: "Printer on fire", description: "Help" } });
await client.tickets.update({ id: ticket.id, body: { status: "pending" } });
for await (const open of client.paginate(client.tickets.list, { status: "open" })) {
console.log(open.subject);
}
TypeScript types for every resource and method ship with the package.
Python
pip install chaosdesk
from chaosdesk import ChaosDesk
client = ChaosDesk("https://acme.example.com", token=os.environ["CHAOSDESK_TOKEN"])
ticket = client.tickets.create(body={"subject": "Printer on fire", "description": "Help"})
client.tickets.update(id=ticket["id"], body={"status": "pending"})
for open_ticket in client.paginate(client.tickets.list, status="open"):
print(open_ticket["subject"])
The Zendesk-compatible API
Every client also has a raw request method for any path, including the Zendesk-compatible API:
await client.request("GET", "/zd/api/v2/tickets.json", { query: { per_page: 100 } });
Postman
Import clients/postman/chaosdesk.postman_collection.json from the repository. Set the collection variables baseUrl (your workspace) and token (an API token from Admin, API). Requests are grouped by resource.
Changes
What changed in the API, version by version, is on the API changelog.