Northstake SDK

Introduction

The Northstake SDK offers access to a wide range of services tailored for digital asset management and operations. Central to our SDK's design is its handling of authentication.

Using the Northstake SDK, it is necessary only to pass your api key and private key once when instantiating the SDK, and let the SDK manage the rest. The SDK takes care of dynamically generating a securely signed payload for each API request, ensuring that your integration not only meets security best practices but does so without additional overhead on every call. This approach minimizes boilerplate code and reduces potential points of failure in your application's security.

Installation

npm i @northstake/northstakeapi

Getting Started

To begin, instantiate the NorthstakeApi class with your API key and private key. The constructor sets up all the necessary configurations to communicate securely with our API endpoints:

import { NorthstakeApi } from '@northstake/northstakeapi';

const apiClient = new NorthstakeApi('your_api_key', 'your_private_key');

🚧

Be careful

Be careful not to enter or persist your private key directly in code or commit it to any code repositories. Keeping your private key safe is your responsibility.

Demo #1 - retrieve basic account information.

import { NorthstakeApi } from '@northstake/northstakeapi';

const apiClient = new NorthstakeApi('your_api_key', 'your_private_key');

const getInfo = async () => {
  
 const {body: account}  = await apiClient.account.getAccountInformation()
 console.log(account)
  
}

getInfo()

Demo #2 - create a new managed user

import { NorthstakeApi } from '@northstake/northstakeapi';

const apiClient = new NorthstakeApi('your_api_key', 'your_private_key');

const createManagedUser = async () => {

  const createManagedUserResponse = await apiClient.managedUsers.createManagedUser({
    referenceUserId: 'internal_organization_user_id',
  })

  const managedUserId = createManagedUserResponse.body.userId
  
  console.log("new managed user has id ", managedUserId)
  
}

createManagedUser()

📘

For more examples of how to use the Northstake SDK, see the recipes



Subclass overview

The Northstake SDK wraps the REST API paths, exposing submodules as individual classes with wrappers to POST/GET/DELETE/PATCH data through method calls.

The following pages provide an overview of the SDK subclasses and their methods