@namebasehq/exchange-api

0.0.10 • Public • Published

Namebase Exchange Api

An easy-to-use Node.js package that lets you programmatically interact with the Namebase exchange.

Usage

Here is some sample code demonstrating how to use this package. First, go to https://www.namebase.io/pro and generate an API key.

Note: this is not a comprehensive enumeration of the supported features. Read the source code for a full list. The raw API documentation can be found here: https://github.com/namebasehq/exchange-api-documentation/

const namebase = require('@namebasehq/exchange-api');
const exchange = new namebase.Exchange(
  /* ACCESS KEY */,
  /* SECRET KEY */
);

// get the last trade price
const result1 = await exchange.priceTicker(namebase.HNSBTC);

// place a limit sell order
const quantity = '112.010000'; // units are HNS for the HNSBTC market
const orderPrice = '0.00004321'; // units are BTC for the HNSBTC market
const result2 = await exchange.limitSell(
  namebase.HNSBTC,
  quantity,
  orderPrice
);

// find all open orders
const result3 = await exchange.openOrders(namebase.HNSBTC);

if (result3.length > 0) {
  // pick a random order
  const orderIds = result3.map(order => order.orderId);
  const orderIndex = Math.floor(Math.random() * orderIds.length);

  // cancel the order
  const result4 = await exchange.cancelOrder(
    namebase.HNSBTC,
    orderIds[orderIndex]
  );
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.1058latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.1058

Package Sidebar

Install

npm i @namebasehq/exchange-api

Weekly Downloads

58

Version

0.0.10

License

MIT

Unpacked Size

9.31 kB

Total Files

5

Last publish

Collaborators

  • 0xstefan
  • nodweber