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 --saveSet 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"
});Install the Bunny SDK via RubyGems
gem install bunnyappUse Rails generator to create initializers/bunny_app.rb
bin/rails g bunny_app:installSet access token
require 'bunny_app'
BunnyApp.config do |c|
c.access_token = 'xxx'
c.base_uri = 'https://<subdomain>.bunny.com'
endOr alternatively use client credentials. This will enable automatic refresh of expired access tokens.
require 'bunny_app'
BunnyApp.config do |c|
c.client_id = 'xxx'
c.client_secret = 'xxx'
c.scope = 'standard:read standard:write'
c.base_uri = 'https://<subdomain>.bunny.com'
endWe 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?
