Skip to main content
Get started with our JavaScript SDK, bannerify-js, for a more typed and efficient experience. This SDK allows you to interact with our API without having to make HTTP requests directly.

Install

  • npm
  • pnpm
  • yarn
  • bun
 npm install bannerify-js

Instantiate

If you want to use SDK, you will need your api key — you can create a new one in the settings. Afterwards you need to provide it to the client:
import { Bannerify } from "bannerify-js";

const bannerify = new Bannerify('your-api-key');

Response format

Because forgetting to handle thrown errors properly in javascript is often forgotten, we have decided to explicitely return errors to be handled. Fortunately typescript helps us here and everything is typesafe. Every method returns either an error or a result field, never both and never none.
{
  result: T // the result depends on what method you called
}

Checking for errors

To check for errors you use the error property, our errors are easy to read and provide a link to our documentation for more information.
import { Bannerify } from "bannerify-js";

const bannerify = new Bannerify('your-api-key');
const { result, error } = await bannerify.generateImageSignedUrl('your-template-id');

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

// process request
console.log(result);

Options

The constructor accepts some options to customize the behavior:

API key

apiKey
string
required
Your project’s API key
const bannerify = new Bannerify('my-api-key')

Timeout

The timeout for the requests in milliseconds, by default it is 10000ms.
const bannerify = new Bannerify('my-api-key',{
  // ...
  timeout: 10000
})

Fetch

The fetch client to use, by default it uses the global fetch client.
const bannerify = new Bannerify('my-api-key',{
  // ...
  fetch: myFetchClient
})