Install the SDK

Bunny provides server side libraries that abstract much of the authentication, authorization and request formation boilerplate code required to make API requests.

You can find the source code for the two SDKs here:

Installing the SDKs is straighforward.

Install the Bunny SDK via NPM

npm install @bunnyapp/api-client --save

Set the access token

const Bunny = require("bunny");

const bunny = new Bunny({
  accessToken: "<access-token>",
  baseUrl: "https://<subdomain>.bunny.com"  
});

Or alternatively use client credentials. This will enable automatic refresh of expired access tokens.

const Bunny = require("bunny");

const bunny = new Bunny({
  clientId: "<bunny-client-id>",
  clientSecret: "<bunny-client-secret>",
  scope: "standard:read standard:write",
  baseUrl: "https://<subdomain>.bunny.com"  
});

Source: https://github.com/bunnyapp/bunny-node

We recommend using one of our official SDKs, however if you want to write your own code then you will need to generate an access token and include it in the Authorization header of your GraphQL requests. You should also keep in mind handling access token expiry errors and retries.

Last updated

Was this helpful?