Skip to content

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:

FieldWhat 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

  1. Import it

    In Postman, choose Import and paste this address (or download the collection and import the file):

    Collection
    https://rabbitflare.com/docs/api/postman.json
  2. 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.

  3. Send a request

    Every operation is there, by group, with the reference's example filled in. Requests that spend money make their own Idempotency-Key and 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.

Shell
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.

SDK
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: await one for its first page, or read it to the end with for await: the SDK follows nextCursor, with the same filters.
  • Errors: an error answer throws a RabbitflareError, with the error's code, fields and requestId. A lost connection or a timeout throws a RabbitflareConnectionError.
  • Retries: a request is sent again when that's worth it and can't do it twice, waiting as Retry-After says, up to maxRetries times. A request that needs an Idempotency-Key gets one, the same on every try.
  • Waiting: rf.waitFor reads a new server or site until it's done, has failed, or the time is up.
  • Webhooks: verifyWebhook checks 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.

Contact support

Popular

API docs