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

btc-id

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

btc-id

A Node.js-based Implementation of Bitcoin Indonesia's Trade API

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

btc-id

A Node.js-based Implementation of Bitcoin Indonesia's Trade API

Compatibility

This implementation is compatible with Trade API v1.7. All API request methods are implemented using Request and Bluebird.

Important Notes

  • A private and secret key must be set before making private API requests. See this link.
  • Correct order of parallel private API requests cannot be guaranteed because of asynchronous nature of JavaScript and network latency. Some requests will fail because of incorrect nonce. Tell your nice trading bot to handle errors carefully and just don't go too fast.
  • It is recommended to use proven third party library to parse numbers and do arithmetic calculations, such as bignumber.js. You know, JavaScript is bad at math and I am pretty sure you don't want to lose even only a small fraction of your precious digital golds.
  • I am not responsible for any future profits, losses or damages caused by this library. Cryptocurrency trading is always considered to be high-risk activity. By using this library, it is assumed that you know exactly what you are doing.

Usage

const btcid = require('btc-id');
const API = new btcid();

Methods

General

version

Get Trade API compatibility version. Example:

console.log(API.version); // '1.7'
baseUrl

Get/set base URL for API requests. Example:

console.log(API.baseUrl); // 'https://vip.bitcoin.co.id'
API.baseUrl = 'http://a-trading-proxy.com';
console.log(API.baseUrl); // 'http://a-trading-proxy.com'
key

Set API key. Example:

API.key = 'AAAAAAAA-BBBBBBBB-CCCCCCCC-DDDDDDDD-EEEEEEEE';
secret

Set secret key. Example:

API.secret = '1263e5a57b853024509bf94ff466ec6a2a733ad83a2aa6ceb5cc14301713b4a77f2bb154a66cde73';
pair(coinA, coinB)

An easy way to generate coin pair string for use with API requests. Example:

console.log(API.pair('BTC', 'IDR')); // 'btc_idr'

Public API

getTicker(pair)

Example:

API.getTicker(API.pair('BTC','IDR'))
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getTrades(pair)

Example:

API.getTrades(API.pair('BTC','IDR'))
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getDepth(pair)

Example:

API.getDepth(API.pair('BTC','IDR'))
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });

Private

getInfo()

Example:

API.getInfo()
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getTransHistory()

Example:

API.getTransHistory()
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getTradeHistory({pair, [count, from_id, end_id, order, since, end]})

Example:

API.getTradeHistory({pair: API.pair('BTC', 'IDR'), count: 100, order: 'desc'})
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getOpenOrders({[pair]})

Example A (get all open orders of all pairs):

API.getOpenOrders({})
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });

Example B (get open orders of specific pair):

API.getOpenOrders({pair: API.pair('BTC', 'IDR')})
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getOrderHistory({pair, [count, from]})

Example:

API.getOrderHistory({pair: API.pair('BTC', 'IDR'), count: 100})
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });
getOrder({pair, order_id})

Example:

API.getOrder({pair: API.pair('BTC', 'IDR'), order_id: 94428})
    .then(function(response) {
        console.log(response);
    })
    .catch(function(err) {
        console.error(err);
    });

FAQs

Package last updated on 17 Dec 2017

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