Endpoint URL
https://www.btcbox.co.jp/api/v1
At BTCBOX, we have HTTP Private API that need confirmation by an API Key, and HTTP Public API that does not need any confirmation.
API Restriction
HTTP API is being executed as the following API request limit per second
- trade_add (Send Order) : Within 2 times every second
- balance (Balance Confirmation) : Within 2 times every second
- trade_list (Confirmation of Order List) : Within 1 times every second
- order_history(Order history): Within 4 times every second
- trade_view(Order details): Within 1 times every second
There are no other API request upper limits, but in case of the company deems repeated requests with the purpose of loading the system, please note that the company might limit the use of the API.
【Public API】
・Cryptocurrencies Information(tickers)
Request Method:GET
https://www.btcbox.co.jp/api/v1/tickers
Response
- Acquiring Information for all four cryptocurrencies(BTC/JPY、BCH/JPY、LTC/JPY、ETH/JPY、DOGE/JPY、DOT/JPY、TRX/JPY)
Name | Data Type | Description |
---|---|---|
high | NUMBER | 24 H High Price |
low | NUMBER | 24 H Low Price |
buy | NUMBER | Buy Quotation |
sell | NUMBER | Sell Quotation |
last | NUMBER | Latest Execution Price |
vol | NUMBER | 24 H Trading Volume |
Sample
{
"BTC_JPY": {
"high": 2829667,
"low": 2759378,
"buy": 2774453,
"sell": 2777955,
"last": 2774210,
"vol": 566.6947
},
"BCH_JPY": {
"high": 17067,
"low": 16000,
"buy": 16010,
"sell": 16277,
"last": 16242,
"vol": 867.8011
},
"LTC_JPY": {
"high": 7905,
"low": 7501,
"buy": 7500,
"sell": 7550,
"last": 7548,
"vol": 820.1909
},
"ETH_JPY": {
"high": 192570,
"low": 185069,
"buy": 186038,
"sell": 186691,
"last": 186237,
"vol": 231.9109
},
"DOGE_JPY": {
"high": 9.04,
"low": 8.38,
"buy": 8.62,
"sell": 8.63,
"last": 8.62,
"vol": 20925.4521
},
"DOT_JPY": {
"high": 936,
"low": 892,
"buy": 902,
"sell": 902,
"last": 902,
"vol": 21380.8126
},
"TRX_JPY": {
"high": 9.47,
"low": 8.93,
"buy": 8.97,
"sell": 8.97,
"last": 8.97,
"vol": 21140.7387
}
}
・Cryptocurrency Information(ticker)
Request Method:GET
https://www.btcbox.co.jp/api/v1/ticker
ex. ETH/JPY Realtime Rate
https://www.btcbox.co.jp/api/v1/ticker?coin=eth
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth、doge、dot、trx (Default : btc) |
Response
Name | Data Type | Description |
---|---|---|
high | NUMBER | 24 H High Price |
low | NUMBER | 24 H Low Price |
buy | NUMBER | Buy Quotation |
sell | NUMBER | Sell Quotation |
last | NUMBER | Latest Execution Price |
vol | NUMBER | 24 H Trading Volume |
Sample
{
"high":39700,
"low":36300,
"buy":1.879,
"sell":0,
"last":38800,
"vol":283.954
}
・Orderbook Information(depth)
Request Method:GET
https://www.btcbox.co.jp/api/v1/depth
ex. ETH/JPY Realtime Rate
https://www.btcbox.co.jp/api/v1/depth?coin=eth
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | BTC,BCH,LTC, ETH (Default: BTC) |
Response
Name | Data Type | Description |
---|---|---|
asks | Array | Displaying the present “Sell Order Price・Amount” List of Orders are in Price order (High to Low) |
bids | Array | Displaying the present “Buy Order Price・Amount” List of Orders are in Price order (Low to High) |
Sample
{
"asks":[
[
41700,
10
],
[
41300,
6
],
[
40900,
10
],
[
40500,
6
],
[
40125,
10.0277
],
[
40100,
5
],
[
40089,
0.509
],
[
39800,
14.7132
],
[
39799,
0.0695
],
[
39798,
5
],
[
39700,
2.89
],
[
39000,
0.209
]
],
"bids":[
[
38300,
1.879
],
[
38100,
1.0078
],
[
38000,
1.24
],
[
37700,
4.706
],
[
37600,
3.8313
],
[
37001,
0.146
],
[
36999,
5.8
],
[
36400,
5
],
[
36200,
1.3314
],
[
36002,
2
],
[
36000,
1.568
],
[
35501,
0.282
],
[
35500,
9.9
],
[
35200,
5.6
]
]
}
・Execution History(orders)
Acquire the latest 100 cases of execution information in ascending order of execution time.
Request Method:GET
https://www.btcbox.co.jp/api/v1/orders
ex.ETH/JPY Execution History
https://www.btcbox.co.jp/api/v1/orders?coin=eth
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth (Default : btc) |
Response
Name | Data Type | Description |
---|---|---|
date | STRING | Execution Date (UNIX time) |
price | NUMBER | Execution Price |
amount | NUMBER | Execution Amount |
tid | STRING | Order ID |
type | STRING | Trade Type(”buy” “sell”) |
Sample
[
{
"date":"0",
"price":3,
"amount":0.1,
"tid":"1",
"type":"buy"
},
{
"date":"0",
"price":32323,
"amount":2,
"tid":"2",
"type":"sell"
},
{
"date":"0",
"price":32,
"amount":432,
"tid":"3",
"type":"sell"
},
{
"date":"0",
"price":323,
"amount":2,
"tid":"4",
"type":"sell"
},
{
"date":"0",
"price":2100,
"amount":0.3,
"tid":"5",
"type":"buy"
}
]
【Private API】
About confirmation
In order to use Private API, confirmation will be necessary.
NOTE : In case the customer’s Private API is leaked to a third party, and the assets are manipulated・traded without the customer’s designated intent, the customer may suffer loss. Please manage your Private API in a secure way.
Private API Use Order
- Preparing a applicable parameter, and using the private key, conduct the signature (for more detail about signature, refer to the below)
- Every parameter and its signatured character string (signature) will be sent to the server in POST format. Please note that It is necessary for the sent parameter sequence and the disposition sequence of the parameter’s signature time to match.
About Signature
Example of Balance Confirmation API:
- Collecting other Parameters other than Signatures : coin, key, nonce
- Creating a character string as :
key=xxxxxx&coin=btc&nonce=1508482053
- Using the HMacSHA256 function, encrypt the above character string. The encryption key is the Private API Key digested with MD5 Algorithm.
- Signatures and other parameter will be send to API.
About nonce
Usually, there is no problem if it is configured with UNIX timestamp, however, in case of the system check is the same as UID, the nonce must be bigger than the previously requested nonce. Please be careful when Multithreading Programming is carried out.
・Confirmation Balance(balance)
Confirming the BTCBOX Account Balance
Request Method:POST
https://www.btcbox.co.jp/api/v1/balance
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth、doge、dot、trx (Default : btc) |
key | STRING | Yes | Public API Key |
nonce | STRING | Yes | Nonce |
signature | STRING | Yes | Signature |
Response
Name | Data Type | Description |
---|---|---|
uid | NUMBER | User ID Assigned to Every Customer |
nameauth | NUMBER | Personal Verification Status 『0:Non Verified』『1:Verified』 |
moflag | NUMBER | SMS Verification Setting Status 『0:Not Setup』『1:Setup』 |
btc_balance | NUMBER | BTC Balance |
btc_lock | NUMBER | Pending BTC Balance |
bch_balance | NUMBER | BCH Balance |
bch_lock | NUMBER | Pending BCH Balance |
ltc_balance | NUMBER | LTC Balance |
ltc_lock | NUMBER | Pending LTC Balance |
eth_balance | NUMBER | ETH Balance |
eth_lock | NUMBER | Pending ETH Balance |
jpy_balance | NUMBER | JPY Balance |
jpy_lock | NUMBER | Pending JPY Balance |
Sample
{
"uid":8,
"nameauth":0,
"moflag":0,
"btc_balance":4.234234,
"btc_lock":0,
"bch_balance":234,
"bch_lock":15,
"ltc_balance":32429.6,
"ltc_lock":2.4,
"eth_balance":0,
"eth_lock":0,
"doge_balance":0,
"doge_lock":0,
"dot_balance":0,
"dot_lock":0,
"trx_balance":0,
"trx_lock":0,
"jpy_balance":2344581.519,
"jpy_lock":868862.481
}
・Address Confirmation(wallet)
Acquiring the BTCBOX Coin Deposit Address
Request Method:POST
https://www.btcbox.co.jp/api/v1/wallet
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth、doge、dot、trx (Default : btc) |
key | STRING | Yes | API Key |
nonce | STRING | Yes | Nonce |
signature | STRING | Yes | Signature |
Response
Name | Data Type | Description |
---|---|---|
result | BOOL | 『true』『false』 |
address | STRING | Corresponding Coin Deposit Address |
Sample
{
"result":true,
"address":"1xxxxxxxxxxxxxxxxxxxxxxxx"
}
・Order List(trade_list)
Acquire max. 100 order details from latest Orders until the designated date (since) with Array.
Request Method:POST
https://www.btcbox.co.jp/api/v1/trade_list
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth (Default : btc) |
key | STRING | Yes | API Key |
nonce | STRING | Yes | Nonce |
since | NUMBER | No | Designated Date UNIX Timestamp(UTC Time) Default: 0 |
signature | STRING | Yes | Signature |
Response
Name | Data Type | Description |
---|---|---|
id | NUMBER | Order ID |
datetime | STRING (YYYY-MM-DD hh:mm:ss) | Order Date |
type | STRING | Order Type (”buy” “sell”) |
price | NUMBER | Order Price |
amount_original | NUMBER | Order Amount |
amount_outstanding | NUMBER | Pending Amount |
Sample
[
{
"id":"7",
"datetime":"2014-10-20 13:27:38",
"type":"buy",
"price":42750,
"amount_original":0.235,
"amount_outstanding":0.235
},
{
"id":"6",
"datetime":"2014-10-20 13:27:15",
"type":"buy",
"price":43299,
"amount_original":4.789,
"amount_outstanding":4.789
},
{
"id":"5",
"datetime":"2014-10-20 13:26:52",
"type":"buy",
"price":42500,
"amount_original":14,
"amount_outstanding":14
},
{
"id":"4",
"datetime":"2014-10-20 13:26:23",
"type":"buy",
"price":43200,
"amount_original":0.4813,
"amount_outstanding":0.4813
},
{
"id":"3",
"datetime":"2014-10-20 13:25:57",
"type":"buy",
"price":43200,
"amount_original":0.4813,
"amount_outstanding":0.4813
}
]
・Order Details(trade_view)
Acquire the designated order content
Request Method:POST
https://www.btcbox.co.jp/api/v1/trade_view
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth (Default : btc) |
id | STRING | Yes | Order ID |
key | STRING | Yes | API Key |
nonce | STRING | Yes | Nonce |
signature | STRING | Yes | Signature |
Response
Name | Data Type | Description |
---|---|---|
id | NUMBER | Order ID |
datetime | STRING | Order Date (yyyy-mm-dd hh:mm:ss) |
type | STRING | Order Type Buy Order , Sell Order |
price | NUMBER | Order Price |
amount_original | NUMBER | Order Amount |
amount_outstanding | NUMBER | Pending Amount |
status | STRING | Order Status 『wait:Un-Execute』 『Not Executed or Part : Partial Execution』 『cancelled:Cancelation Settled』 『all:All Executions Settled』 |
trades | ARRAY | See the table for details |
Name | Date Type | Description |
---|---|---|
trade_id | NUMBER | Order ID |
amount | NUMBER | Order Amount |
price | NUMBER | Order Price |
datetime | STRING | Order Datetime |
fee | NUMBER | Order Fee |
Sample
{
"id": 11,
"datetime": "2014-10-21 10:47:20",
"type": "buy",
"price": 42000,
"amount_original": 2.4,
"amount_outstanding": 0,
"status": "all",
"trades": [
{
"trade_id": "12",
"amount": 1.1,
"price": 42000,
"datetime": "2014-10-21 10:47:20",
"fee": 0.0001
},
{
"trade_id": "13",
"amount": 1.3,
"price": 42000,
"datetime": "2014-10-21 10:47:20",
"fee": 0.0001
}
]
}
・Cancel an Order(trade_cancel)
Cancel the designated orders.
Request Method:POST
https://www.btcbox.co.jp/api/v1/trade_cancel
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth (Default : btc) |
id | NUMBER | Yes | Order ID |
key | STRING | Yes | Public API Key |
nonce | NUMBER | Yes | Nonce |
signature | STRING | Yes | Signature |
Response
Name | Data Type | Description |
---|---|---|
result | BOOL | Result 『true:Cancelled』 『false:Cancellation Failed』 |
id | NUMBER | Order ID of Cancellation |
Sample
{
result: true,
id: 11
}
・Send Order(trade_add)
Send an order with designated terms
Request Method:POST
https://www.btcbox.co.jp/api/v1/trade_add
Parameter
Name | Data Type | Required | Description |
---|---|---|---|
coin | STRING | No | btc、bch、ltc、eth (Default : btc) |
key | STRING | Yes | Public API Key |
nonce | NUMBER | Yes | Nonce |
amount | NUMBER | Yes | Order Amount |
price | NUNBER | Yes | Order Price |
type | STRING | Yes | Order Type Buy Order, Sell Order |
signature | STRING | Yes | Signature |
Response
Name | Data Type | Description |
---|---|---|
result | BOOL | Result 『true:Settled Order』 『false:Failed Order』 |
id | NUMBER | Generated Order ID |
Sample
{
"result":true,
"id":11
}
Error Code
Error Code | Description |
---|---|
100 | Must input the mandatory parameters. |
101 | Invalid Parameter |
102 | The coin does not exist |
103 | The key does not exist |
104 | Signature is not match |
105 | No authority |
106 | The request is expired. (nonce error) |
107 | The price is less or equal to 0 |
200 | Not enough balance |
201 | The trading number is too small |
202 | The price is 20% more than or less than current price |
203 | The order does not exist |
204 | The order price exceeds the upper limit (10 million JPY for BTC, 1 million JPY for other coins) |
301 | The person identification is not finished |
302 | The identification document is expired |
401 | System Error |
402 | Request is too frequent |
403 | It is a un-open API |
404 | IP limit does not require a source |
900 | The account has been deleted |
901 | Trade has been temporarily suspended. |
【Sample Code】
Python・PHP
<?php
$api = new apidemo('Public Key', 'Private Key', 'btc');
$api->get_balance();
class apidemo
{
/**
* API URL
*
* @var string
*/
private $apiurl = 'https://www.btcbox.co.jp/api/v1/';
/**
* Public Key
* Apply address:https://www.btcbox.co.jp/api/secret/keys/
*
* @var string
*/
private $key;
/**
* Private Key
* Apply address:https://www.btcbox.co.jp/api/secret/keys/
*
* @var string
*/
private $passphrase;
/**
* Coin
*/
public $coin;
/**
* construct
*/
public function __construct($key = false, $passphrase = false, $coin = 'btc')
{
$this->key = $key;
$this->passphrase = $passphrase;
$this->coin = $coin;
}
/**
* Market
*
* @return array
* @access open
*/
public function ticker()
{
return $this->request('ticker', array(), 'GET', false);
}
/**
* Depth
*
* @return array
* @access open
*/
public function get_depth()
{
return $this->request('depth', array(), 'GET', false);
}
/**
* Get Orders
*
* @param $since -1~9999999999
*
* @return array
* @access open
*/
public function get_trades($since = -1)
{
return $this->request('orders', array('since' => $since), 'GET', false);
}
/**
* Account Balance
*
* @return array
* @access readonly
*/
public function get_balance()
{
return $this->request('balance', array(), 'POST');
}
/**
* Wallet Adress
*
* @return array
* @access readonly
*/
public function get_wallet()
{
return $this->request('wallet', array(), 'POST');
}
/**
* Get your recent orders
*
* @param integer $since After a time(Default All)
* @param string open|all $type type
*
* @return array
* @access readonly
*/
public function get_orders($since = 0)
{
return $this->request('trade_list', array('since' => $since), 'POST');
}
/**
* Order Details
*
* @param integer $orderid Orders Id
*
* @return array
* @access readonly
*/
public function fetch_order($orderid)
{
return $this->request('trade_view', array('id' => $orderid), 'POST');
}
/**
* Cancel Order
*
* @param integer $orderid Order ID
*
* @return array
* @access full
*/
public function cancel_order($orderid)
{
return $this->request('trade_cancel', array('id' => $orderid), 'POST');
}
/**
* Trade
*
* @param float $amount number
* @param float $price price
*
* @return array
* @access full
*/
public function add($amount, $price, $type)
{
return $this->request('trade_add', array('amount' => $amount, 'price' => $price, 'type' => $type), 'POST');
}
/**
* Request
*
* @param string $method API Url
* @param array $params Parameters
* @param string GET|POST $http_method Request method
* @param bool $auth is Verify
*
* @return array
*/
protected function request($method, $params = array(), $http_method = 'GET', $auth = true)
{
# coin
$params['coin'] = $this->coin;
if ($auth) {
# Unique number
$mt = explode(' ', microtime());
$params['nonce'] = $mt[1] . substr($mt[0], 2, 2);
# verify information
$params['key'] = $this->key;
$params['signature'] = hash_hmac('sha256', http_build_query($params, '', '&'), md5($this->passphrase));
}
# data string
$data = http_build_query($params, '', '&');
$data = $this->do_curl($method, $data, ($http_method == 'GET' ? 'GET' : 'POST'));
return $data;
}
/**
* Request
*/
private function do_curl($path, $data, $http_method)
{
static $ch = null;
$url = $this->apiurl . $path;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Btcbox PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
}
if ($http_method == 'GET') {
$url .= '?' . $data;
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
if (!$response = curl_exec($ch)) {
throw new Exception('Could not get reply: ' . curl_error($ch));
}
if (!$data = json_decode($response, true)) {
throw new Exception('Invalid data received');
}
return $data;
}
}