Shelf.Network JavaScript SDK

The Shelf.Network JavaScript SDK facilitates client integration with the Shelf.Network auction platform.

Table of content

  1. Javascript SDK

  2. Development Guide

  3. Troubleshooting

JavaScript SDK


npm install -S


If you use webpack as your build system, you'll need to exclude the optional native module ed25519

  plugins: [
    new webpack.IgnorePlugin(/ed25519/)

You can also check out package's webpack config.

Prebuilt Minified Scripts

The package also ships prebuilt minified scripts for browsers in the /dist folder.

<script type="text/javascript" src="https://<sdk-dist-url>"></script>
<script type="text/javascript">
  (async () => {
    let sdk = await Sdk.ShelfNetwork.create({
      gatewayUrl: ''
    // ...

Shelf.Network SDK

To get started, create a Shelf.Network SDK instance:

import { ShelfNetwork } from ''

const sdk = await ShelfNetwork.create({
  gatewayUrl: ''

You can configure different environment setting such as proxy configuration via options.

Response Format

All HTTP responses share the following format:

  httpStatus: 200,

  // Flattened and camel-cased response data
  data: [
      resourceType: 'deposits',
      id: '209529',
      amount: '4267.00',
      currency: 'GEL',
      state: 2,
      stateStr: 'paid'

  // Response headers
  headers: {...},

  // Parsed links and relations
  fetchNext: () => {...},
  fetchPrev: () => {...},
  fetchAccount: () => {...}

The links and relations that are returned with the responses are converted into functions you can call on the returned object. For example you can use them for simple pagination through collections:

const page = await sdk.horizon.balances.getPage()

const prevPage = await page.fetchPrev()
console.log('Previous page',


Common errors

Wrappers for error responses

All the error responses subclass ServerErrorBase and share the following format:

  httpStatus: 403,
  // Human readable title
  title: 'Forbidden',
  // Detailed explanation
  detail: 'Additional factor required.',
  // Additional relevant data
  meta: {
    factorId: 275,
    factorType: 'password',
  // Raw unparsed error
  originalError: {...},
  // Retry request. Handy for 2FA handling
  retryRequest: () => {...}


SDK allows you to use request and response interceptors:

  request => {
    // Track user's actions, transform request data, etc
  err => {
    // Log, handle errors, retry requests, etc

  config => {
    // Parse and transform response data, show notifications, etc
  err => {
    // Track errors, try to retry requests, show 2FA prompts, etc


Each request is authenticated to each service via JWT. A token is represented by the base64 string stored in Authorization header with syntax Bearer {token}.

A client passes his credentials upon registration. Later this credentials will be used to retrieve temporary JWTs.

Retrieve and use the token to authenticate requests

const token = await sdk.auth.getToken('', 'MyPassw0rd', platformId)

Refresh a token

const newToken = await sdk.auth.refreshToken()

Change password

await sdk.auth.changePassword('oldPassword', 'newPassword')

Request password recovery

await sdk.auth.requestRecovery('')

Confirm recovery

// accountId, token are parsed from the recovery link
await sdk.auth.confirmRecovery(accountId, token, 'newPassword')

Services and Resource Groups

Each backend service has an associated object attached to an SDK instance that inherits ServerBase class. It contains methods that encapsulate endpoint calls and may also have some associated resource groups.

List of services and associated resource groups:

Development Guide


As for now, some handy ES7 features need transpiler in both node.js and browser environments, so the babel transpiler is used.

Build for node.js:

npm run build

Build for browsers:

npm run build:browser

Coding Style

SDK follows JavaScript Standard Style.

All public classes and functions must have JSDoc annotations.

Run linter to check for style violations:

npm run lint


Node.js tests:

npm test

Browser tests:

npm tests:browser

Test coverage:

npm run coverage

Generating Docs

npm run docs