@setl/api-sdk

Library for interacting with SETL Labs instances.

Usage no npm install needed!

<script type="module">
  import setlApiSdk from 'https://cdn.skypack.dev/@setl/api-sdk';
</script>

README

SETL API SDK

The SETL API Node library provides convenient access to the SETL API from applications written in server-side JavaScript.

Documentation

See the SETL Labs API docs for more information (sign-up required).

Installation

Install the package with:

npm install @setl/api-sdk --save
# or
yarn add @setl/api-sdk

Usage

The package needs to be configured with your SETL Labs's address which is available in your SETL Labs Dashboard.

const { connect } = require('@setl/api-sdk');
const client = connect('example.setllabs.io');

const token = await client.login({
  username: 'username',
  password: 'password'
});

console.log(token);

Or using ES modules and async/await:

import { connect } from '@setl/api-sdk';
const client = connect('example.setllabs.io');

(async () => {
  const token = await client.login({
    username: 'username',
    password: 'password'
  });

  console.log(token);
})();

Usage with TypeScript

Import SetlApiSDK as a named import and instantiate it as new SetlApiSDK(endpoint, options) with the latest API version.

import { connect } from '@setl/api-sdk';
const client = connect('example.setllabs.io');

const getToken = async () => {
  const token = await client.login({
    username: 'username',
    password: 'password'
  });

  console.log(token);
};
getToken();

You can find a full TS server example in SETL API SDK Examples.