OpenAPI and Postman
The OpenAPI document and the Postman collection, to generate clients and try calls.
2 min read Updated
The whole API is also a file: an OpenAPI document, which tools read to make a client in your language, check requests or let you try calls. A Postman collection holds every operation, ready to send.
The OpenAPI document
An OpenAPI 3.1 document in JSON, describing every operation open today, with every field, answer and error. It's at two addresses:
- From the API
-
GET https://api.rabbitflare.com/v1/openapi.json, which needs no token: the document the API itself works from. - From these docs
-
/docs/api/openapi.json, the same document, written when the docs are.
What to do with it:
- Make a client in your language with a generator such as OpenAPI Generator, or types for TypeScript with openapi-typescript. Make it again when the changelog shows something new.
- Import it into Postman, Insomnia, Bruno or your API gateway, to browse and try the operations.
- Check your code against it in tests, so a request your code builds is one the API accepts.
Besides the standard parts, each operation carries a few fields of its own:
| Field | What it says |
|---|---|
x-scopes | The scopes the operation needs. |
x-rate-class | Which rate limit it counts against: read, write or heavy. |
x-spends-money | It costs money, and needs an Idempotency-Key. |
x-async | It answers before its work is done. |
x-destructive | What it removes can't be brought back. |
x-code-samples | The reference's samples in cURL, JavaScript, PHP and Python, and with the SDK. |
x-known-values | The values known today of a field that can gain new ones (a status, say). |
The Postman collection
-
Import it
In Postman, choose Import and paste this address (or download the collection and import the file):
https://rabbitflare.com/docs/api/postman.json -
Add your token
Open the collection's Variables, paste your API token into
token, and save. Every request sends it as a bearer token. Don't share or export the collection with your token in it. -
Send a request
Every operation is there, by group, with the reference's example filled in. Requests that spend money make their own
Idempotency-Keyand keep it until the request is settled, so sending one again never pays twice.
The SDK
A JavaScript and TypeScript library for the API, for Node.js 18 or later, with nothing else to install: a method for every operation, typed from the same definition as the OpenAPI document, with paging, retries and webhook checks built in.
npm install @rabbitflare/api
It reads your token from RABBITFLARE_TOKEN. Each method is named after its operation (servers.create is
rf.servers.create) and takes one object, with the path's ids, the query and the body's fields together; it gives back the answer's
data.
import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
for await (const item of rf.servers.list()) {
console.log(item);
} - Lists:
awaitone for its first page, or read it to the end withfor await: the SDK followsnextCursor, with the same filters. - Errors: an error answer throws a
RabbitflareError, with the error'scode,fieldsandrequestId. A lost connection or a timeout throws aRabbitflareConnectionError. - Retries: a request is sent again when that's worth it and can't do it twice, waiting as
Retry-Aftersays, up tomaxRetriestimes. A request that needs anIdempotency-Keygets one, the same on every try. - Waiting:
rf.waitForreads a new server or site until it's done, has failed, or the time is up. - Webhooks:
verifyWebhookchecks a call's signature exactly as the API makes it, and gives back the event.
Still have a question?
Our team answers support tickets about the API, and other developers answer in the community.