Skip to main content

TypeScript/JavaScript

The TypeScript/JavaScript SDK comes in two variants, one for Node.js and one for the browser. They are very similar and mostly differ only in how HTTP requests are made and what errors are thrown when something goes wrong.

Adding the SDK to your project

The SDKs are freely available and are hosted on NPM. The TypeScript definitions are included in the packages.

For Node.js

npm install --save @onslip/onslip-360-node-api

For the browser

npm install --save @onslip/onslip-360-web-api

Initialize the SDK

Before you use the SDK, you need to provide it with a request handler. This should be done only once in your project, before the SDK is used. You can provide your own request handler, or just use the one we provide in the SDK:

import { API, nodeRequestHandler } from '@onslip/onslip-360-node-api';

API.initialize(nodeRequestHandler({ userAgent: `MyAwesomeClient/1.0.0` }));

Create an API instance and make a request

Now, you're ready to start making calls the API server:

const api = new API('https://test.onslip360.com/v1/', '<realm>', 'key:<username>+<keyname>@<realm>', '<key>');

console.log('Me:', await api.getClientInfo());

Don't yet have an API key? Log in to your Onslip 360 Backoffice account at https://test.onslip360.com, go to API Keys via the top-right user menu and create one!

When you are ready to go to production, simply change the API base URL from https://test.onslip360.com/v1/ to https://api.onslip360.com/v1/. You should also use OAuth to promote your work and make it easy for your customers to activate the integration.

Next steps

To learn more about the API, please refer to the Onslip 360 API User Guide.

Download the SDK sample

We provide a small demo on GitHub. Go check it out!

Questions?

Send your questions to api@onslip.com.