JS SDK quickstart
This guide describes how to install and use the Rebilly JS SDK. To view the Rebilly JS SDK, see Rebilly JS SDK.
Installation
npm
Install the latest version of the Rebilly JS SDK using npm:
npm install rebilly-js-sdk --save
CDN
Use the Rebilly JS SDK from a CDN:
<script src="https://cdn.rebilly.com/instruments/@latest/core.js"></script>
Obtain API key and organization ID
To authenticate with the Rebilly API, you must provide your secret Rebilly API key and organization ID. Depending on the API operation you are executing, you may also need to provide a website ID.
To obtain them, see Obtain a secret key and Obtain your organization ID and website ID.
Usage
Import the RebillyAPI
method and initialize it with your secret API key. For a list of configuration options, see Configuration options.
Retrieve a customer
This example describes how to initialize the Rebilly JS SDK and retrieve a customer using the Rebilly JS SDK.
import RebillyAPI from 'rebilly-js-sdk';
// Define Rebilly organization ID and API key
const REBILLY_ORGANIZATION_ID = 'REBILLY_ORGANIZATION_ID';
const REBILLY_API_SECRET_KEY = 'REBILLY_API_SECRET_KEY';
// Initialize the Rebilly API client with your API key
const api = RebillyAPI({
sandbox: true,
organizationId: REBILLY_ORGANIZATION_ID,
apiKey: REBILLY_API_SECRET_KEY,
});
try {
// Fetch a specific customer by ID
const customer = await api.customers.get({ id: 'customer-123' });
console.log(customer);
} catch (err) {
// Handle errors
console.error(err);
}
Payment form examples
The following examples use the Rebilly Instruments JavaScript library and the Rebilly JS SDK to set up payment forms:
Build commands
For build commands, see Development.