Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aggregator-cexio

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aggregator-cexio

nodejs client for aggregator.cex.io

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25
decreased by-13.79%
Maintainers
1
Weekly downloads
 
Created
Source

CEX.IO Aggregator

The official Node.js client for aggregator.cex.io API (https://docs-aggregator.cex.io)

Features

  • Easy to use, requires only key-secret pair to setup
  • Handle all transport work, just call required action
  • Popular protocols supported, REST and WebSocket onboard

Installation

npm install aggregator-cexio

Rest client

const { RestClient } = require('aggregator-cexio')
const defaultClient = new RestClient()
const authenticatedClient = new RestClient(apiKey, apiSecret, options)

Arguments for RestClient are optional. For private actions you need to obtain apiKey + apiSecret pair from your manager.

  • apiKey string - Api key for specific account.
  • apiSecret string - Api secret for specific account.
  • options object - Additional settings for client.

Available client options described below, they all are optional:

  • apiLimit integer - Rate limit value for apiKey, default is 300. Client will check requests count and prevent from spam the server.
  • timeout integer - Request timeout in milliseconds, default is 30000.
  • rejectUnauthorized boolean - This option useful when you test demo env, default: true.
  • apiUrl string - Can be changed to test your bot on dev environment. default is 'https://rest-aggregator.cex.io'

Public actions

To make a public request use async callPublic(action, params) method. This method return Promise which resolves with server response. If some error was occured then method rejects with status code and error description.

For more details check api refference.

const { RestClient } = require('aggregator-cexio')

const client = new RestClient()

client.callPublic('get_demo_order_book')
  .then(res => console.log(res))
  .catch(err => console.error(err))
{ error: 'Bad Request', statusCode: 400 }
{ error: 'Unexpected error', statusCode: 500 }

Private actions

To make private api calls use async callPublic(action, params). It's similar to public method but requires apiKey and apiSecret arguments to client initialization. Each private request is signed with HMAC sha256 so if key is incorrect or signature is wrong client will return rejected promise with error like this { error: 'Authorization Failed', statusCode: 401 }

const { RestClient } = require('aggregator-cexio')

const key = '_account_api_key_'
const secret = '_account_api_secret_'
const action = 'get_my_trading_conditions'
const params = {
  pairs: ['BTC-USD']
}

const client = new RestClient(key, secret)

client.callPrivate(action, params)
  .then(res => console.log(res))
  .catch(err => console.error(err))

Success response example:

{ ok: 'ok', data: { ... } }

WebSocket client

In progress

Keywords

FAQs

Package last updated on 24 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc