Last updated
These docs are intended for a developer audience.Dismiss

Usage

Rebilly offers several APIs, each with a specific purpose. In order to perform operations on an API you must instantiate the corresponding API client, as detailed below. Performing API operations is identical across all API clients.

Promise-based

Every resource method returns a chainable Promise.

Rebilly API

This API includes all resources. For more information, see Rebilly API.

Usage with Node.js

Import the RebillyAPI method and initialize it with your secret API key (and optionally organizationId) The full list of configuration options can be found here

ES2016 example:

import RebillyAPI from 'rebilly-js-sdk';

const api = RebillyAPI({ apiKey: 'secret-api-key', organizationId: '11111111-1111-1111-1111-111111111111' });

try {
  const transactions = await api.transactions.getAll();
  transactions.items.forEach((transaction) => {
    //transaction.fields
  });
} catch (err) {
  console.error(err.name);
}

ES5 example:

var RebillyAPI = require('rebilly-js-sdk').default;
var api = RebillyAPI({ apiKey: 'secret-api-key', organizationId: '11111111-1111-1111-1111-111111111111' });

api.transactions
  .getAll()
  .then(function (transactions) {
    transactions.items.forEach(function (transaction) {
      //transaction.fields
    });
  })
  .catch(function (err) {
    console.error(err.name);
  });

RebillyExperimentalAPI

This client includes resources for the experimental Rebilly Reports API. It is used mainly for reporting and requests with heavy computational loads like dashboard statistics.

Versionless API

The experimental API can introduce backward incompatible changes to the API specification. Unlike the main API, it does not support versioning.

Usage with Node.js

Import the RebillyExperimentalAPI method and initialize it with your API key (and optionally organizationId) For a complete list of configuration options, see Configuration options.

import { RebillyExperimentalAPI } from 'rebilly-js-sdk';

const experimentalAPI = RebillyExperimentalAPI({ apiKey: 'secret-api-key', sandbox: true, timeout: 10000 });