npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-bitbankcc

v4.0.0

Published

node-bitbankcc

Downloads

1,222

Readme

node-bitbankcc

About

node-bitbankccはNode.js用のbitabank.cc APIのSDKです。

How to use

import/require

TypeScriptのimport、JavaScriptのrequireはそれぞれ以下のように行います。

TypeScript

import * as bitbank from 'node-bitbankcc';

また、tscコマンドでのコンパイルの際は以下のように行います。

$ tsc --lib ES2016 app.ts

JavaScript

var bitbank = require("node-bitbankcc");

PublicAPI

PublicApiの初期化にはApiConfigが必要です。

const conf: ApiConfig = {
  endPoint: 'https://public.bitbank.cc',	// required
  keepAlive: false,							// optional, default false
  timeout: 3000,							// optional, default 3000
};

const publicApi =new PublicApi(conf);

また、ApiOptionsとして、APIリクエストのOptionsを受け取れるoptionsCallbackと、レスポンスを受け取れるresponseCallbackにfunctionを指定することもできます。

...

const options: ApiOptions = {
  optionsCallback: function(...) {...},
  responseCallback: function(...) {...},
};

const publicApi = new PublicApi(conf, options);

サンプル実装

以下にPublic APIの呼び出しサンプル実装を記載します。

getTicker
const params: GetTickerRequest = {
  pair: 'btc_jpy', 			// required
};
const res = await publicApi.getTicker(params);
getDepth
const params: GetDepthRequest = {
  pair: 'btc_jpy', 			// required
};
const res = await publicApi.getDepth(params);
getTransactions
const params: GetTransactionsRequest = {
  pair: 'btc_jpy', 			// required
  yyyymmdd: '20180401', 	// optional
};
const res = await publicApi.getTransactions(params);
getCandlestick
const params: GetCandleStickRequest = {
  pair: 'btc_jpy', 			// required
  candleType: '1hour', 		// required
  yyyymmdd: '20180401', 	// required
};
const res = await publicApi.getCandlestick(params);
getCircuitBreakInfo
const params: GetCircuitBreakInfoRequest = {
    pair: 'btc_jpy', 			// required
};
const res = await publicApi.getCircuitBreakInfo(params);

PrivateAPI

PrivateAPIの初期化にはPrivateApiConfigが必要になります。

// # ACCESS-TIME-WINDOW 方式
const conf: PrivateApiConfig = {
  apiKey: 'YOUR_API_KEY',					// required
  apiSecret: 'YOUR_SECRET_KEY',				// required
  endPoint: 'https://api.bitbank.cc/v1',  	// optional, default->'https://api.bitbank.cc/v1'
  keepAlive: false,							// optional, default->false
  timeout: 3000,							// optional, default->3000
  authMethod: 'RequestTime', // optional, default->'RequestTime'
  timeWindow: 5000,         // optional, default->5000
};

// # ACCESS-NONCE 方式
const conf: PrivateApiConfig = {
  apiKey: 'YOUR_API_KEY',					// required
  apiSecret: 'YOUR_SECRET_KEY',				// required
  endPoint: 'https://api.bitbank.cc/v1',  	// optional, default->'https://api.bitbank.cc/v1'
  keepAlive: false,							// optional, default->false
  timeout: 3000,							// optional, default->3000
  authMethod: 'Nonce',        // optional, default->'RequestTime'
};

const privateApi = new PrivateApi(conf);

また、PublicAPIと同様に、ApiOptionsを指定することが可能です。

...

const options: ApiOptions = {
  optionsCallback: function(...) {...},
  responseCallback: function(...) {...},
};

const privateApi = new PrivateApi(conf, options);

サンプル実装

以下にPrivate APIの呼び出しサンプル実装を記載します。

getAssets
const res = await privateApi.getAssets();
assert.equal(res.success, 1);
getOrder
const params: GetOrderRequest = {
  order_id: 14541343,				// required
  pair: 'btc_jpy',					// optional
};
const res = await privateApi.getOrder(params);
postOrder
const params: OrderRequest = {
  pair: 'btc_jpy',					// required
  amount: '0.01',					// required
  price: 1000,						// optional
  side: 'buy',						// required
  type: 'market',					// required
  post_only: false,					// optional. Except for circuit_break_info.mode is NONE, this parm is ignored.
};
const res = await privateApi.postOrder(params);
cancelOrder
const params: CancelOrderRequest = {
  order_id: 14541507,				// required
  pair: 'btc_jpy',					// required
};
const res = await privateApi.cancelOrder(params);
cancelOrders
const params: CancelOrdersRequest = {
  order_ids: [14541370, 14541371],	// required
  pair: 'btc_jpy',					// required
};
const res = await privateApi.cancelOrders(params);
getOrdersInfo
const params: GetOrdersRequest = {
  order_ids: [14541343, 14541344],	// required
  pair: 'btc_jpy',					// optional
};
const res = await privateApi.getOrdersInfo(params);
getActiveOrders
const params: ActiveOrderRequest = {
  pair: 'btc_jpy',					// optional
  count: 1,							// optional
  from_id: 14541346,				// optional
  end_id: 14541343,					// optional
  since: 1523419311277,				// optional
  end: 1523419024484,				// optional
};
const res = await privateApi.getActiveOrders(params);
getTradeHistory
const params: TradeHistoryRequest = {
  pair: 'btc_jpy',					// optional
  count: 1,							// optional
  order_id: 14541370,				// optional
  since: 1523419311277,				// optional
  end: 1523419024484,				// optional
  order: 'asc',						// optional
};
const res = await privateApi.getTradeHistory(params);
getDepositHistory
const params: DepositHistoryRequest = {
  asset: 'btc',						// required
  count: 1,							// optional
  since: 1523419311277,				// optional
  end: 1523419024484,				// optional
  order: 'asc',						// optional
};
const res = await privateApi.getDepositHistory(params);
getWithdrawalAccount
const params: WithdrawalAccountRequest = {
  asset: 'jpy',						// required
};
const res = await privateApi.getWithdrawalAccount(params);
requestWithdrawal
const params: WithdrawalRequest = {
  asset: 'jpy',						// required
  uuid: '00000000-0000-0000-0000-000000000000', // required
  amount: '1000',					// required
  otp_token: '652036',				// optional, sms_tokenとどちらか必須
  sms_token: '******', 				// optional, otp_tokenとどちらか必須
};
const res = await privateApi.requestWithdrawal(params);
getWithdrawalHistory
const params: WithdrawalHistoryRequest = {
  asset: 'btc',						// required
  count: 1,							// optional
  since: 1523419311277,				// optional
  end: 1523419024484,				// optional
  order: 'asc',						// optional
};
const res = await privateApi.getWithdrawalHistory(params);

実装の確認/モックについて

以下のリポジトリのモックサーバーを用いて SDKが正しく実装されているかを確認することができます。 https://github.com/bitbankinc/mock-bitbankcc