APIの紹介
前書き
BitTrade APIへようこそ。当社のAPIを使用して、取引所、販売所、出金申請など行うことができます。
*現在、レバレッジ取引には未対応です。
下記の2種類のAPIを用意いたします。
- Rest API方式
- Websocket方式
右側のコード領域にはサンプルコードが表示されます。
Rest API共通情報
本APIを使って、取引プログラムの実装ができます。
APIを使えば以下の機能が使用できます。
- 下記のマーケット情報を取得可能
- ローソク足
- 板情報
- BBO
- 約定情報
- 24時間相場情報
- etc,
- 資産参照、出金申請
- 取引所関連、注文、注文取消、注文履歴の参照
- 販売所関連、価格監視、注文
セキュリティ認証
1. APIキーの申請
- APIキーの作成と変更について、 [マイページ > API > APIキーを作成] にて行ってください。
Key | Description |
---|---|
AccessKey | アクセスキー |
SecretKey | 署名時に必要なシークレットキー |
※ シークレットキーは申請時のみ表示されますので、ご注意ください。
2. APIキーの権限設定
Authority | Description |
---|---|
読取 | アカウント情報、取引履歴、入出金履歴の参照ができます |
出金 | 暗号資産の出金申請ができます |
取引 | 取引所、販売所の取引注文、キャンセルができます |
- デフォルトは読取権限になります。
- 他の権限を追加したい場合、権限設定のチェックボックスをチェックしてから作成してください。
3. リクエストの共通仕様
セキュリティ上の理由で、公開API以外のリクエストには全て署名が必要となります。これから署名に関する手順を説明します。
リクエストの例
curl -X GET \
https://api-cloud.bittrade.co.jp/v1/order/orders? \
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx \
&SignatureMethod=HmacSHA256 \
&SignatureVersion=2 \
&Timestamp=2017-05-11T15%3A19%3A30 \
&order-id=1234567890 \
&Signature=$(some calculated value)
HOST
URL: https://api-cloud.bittrade.co.jp
共通仕様
Header | Description |
---|---|
User Agent | User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 |
Language | Accept-Language: ja-JP |
POST Request | Content-Type: application/json |
GET Request | Content-Type: application/x-www-form-urlencoded |
Response Format | json |
認証用共通パラメータ
Parameter | Description |
---|---|
AccessKeyId | アクセスキー |
SignatureMethod | 署名の演算時に用いるハッシュベースプロトコル、ここではHmacSHA256を指定します |
SignatureVersion | 署名プロトコルのバージョン、ここでは2を指定します |
Timestamp | リクエスト時のUnix Timestamp(UTC 時間) 。 Unix Timestampをクエリに含めることで、第三者がリクエストを傍受するのを防ぐことができます。例:2017-05-11T16:22:06。Unix TimestampはUTC 時間であることに注意してください。 |
Signature | 署名に基づいて計算された値。署名が有効で改ざんされていないことを保証するために使用されます。 必須、オプションのパラメーター各メソッドには、API呼び出しを定義するための一連の必須、オプションのパラメーターがあります。これらのパラメータとその意味は、各メソッドの説明で確認できます。 |
※ GETリクエストの場合、URLのパラメータも署名文字列に入れる必要があります。
署名処理
署名処理手順
# 元のリクエスト
https://api-cloud.bittrade.co.jp/v1/order/orders?
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx
&order-id=1234567890
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T15:19:30
# 1. 改行入れる
GET\n
# 2. 改行入れる
api-cloud.bittrade.co.jp\n
# 3. 改行入れる
/v1/order/orders\n
# 4. パラメータソートする
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx
SignatureMethod=HmacSHA256
SignatureVersion=2
Timestamp=2017-05-11T15%3A19%3A30
order-id=1234567890
# 5. '&'で連結
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30&order-id=1234567890
# 6. 署名用文字列
GET\n
api-cloud.bittrade.co.jp\n
/v1/order/orders\n
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30&order-id=1234567890
# 7. 署名処理 - サンプルコードに参照
SecretKey: b0xxxxxx-c6xxxxxx-94xxxxxx-dxxxx
Signature: 4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o=
# 8. 署名後の文字列をURLに付加する
https://api-cloud.bittrade.co.jp/v1/order/orders?AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&order-id=1234567890&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30&Signature=4F65x5A2bLyMWVQj3Aqp%2BB4w%2BivaA7n5Oi2SuYtCJ9o%3D
リクエスト方法(GET 或いは POST)、続けて改行を追加する
小文字のアクセスアドレスに続けて改行を追加する
アクセスメソッドへのパス、続けて改行を追加する
パラメータ名は、ASCIIコードの順にソートし、URLエンコーディングしてください。
上記の順序で、各パラメーターは文字 '&'を使用して連結します。
署名元の文字列は右の通りに示されます。
シークレットキーと変換後のリクエスト文字列を使って、署名処理を行い、その結果はBase64エンコードします。
上記の値をパラメータSignatureの値としてAPIリクエストに追加します。URIエンコードされている必要があります
最終的に、サーバーに送信するAPIリクエストは次のようになります
制限
・公開APIの場合、IP毎に1秒以内に10回に制限されます。
・署名が必要なAPIについて、APIキー毎に1秒以内に10回に制限されています。
・一部のAPIは独自の制限ルールがありますので、そのAPIの詳細に参照してください。
共通のエラーフォーマット
エラー時のレスポンス
{
"ts": 1632970571737,
"status": "error",
"err-code": "invalid-parameter",
"err-msg": "invalid symbol"
}
Field | Required | Type | Description |
---|---|---|---|
ts | true | timestamp | UNIX Timestamp(ミリ秒) |
status | true | string | ステータス, error |
err-code | true | string | エラーコード |
err-msg | true | string | エラーメッセージ |
注: 具体的な原因は、err-msgに記述されていますので、ご参照ください。
システム情報関連
取引ペア情報
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/common/symbols"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": [
{
"base-currency": "btc",
"quote-currency": "jpy",
"price-precision": 0,
"amount-precision": 4,
"symbol-partition": "default",
"symbol": "btcjpy",
"state": "online",
"value-precision": 0,
"min-order-amt": 0.001,
"max-order-amt": 10000,
"min-order-value": 2,
"limit-order-min-order-amt": 0.001,
"limit-order-max-order-amt": 10000,
"limit-order-max-buy-amt": 10000,
"limit-order-max-sell-amt": 10000,
"sell-market-min-order-amt": 0.001,
"sell-market-max-order-amt": 1000,
"buy-market-max-order-value": 10000000,
"api-trading": "enabled",
"tags": ""
},
]
}
このエンドポイントは各取引ペアの精度を返します。
HTTP Request
GET /v1/common/symbols
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
data | true | list | 取引ペアの情報 |
Data Field
Field | Required | Type | Description |
base-currency | true | string | ベース通貨 |
quote-currency | true | string | 見積通貨 |
price-precision | true | integer | 価格の精度 |
amount-precision | true | integer | 数量の精度 |
symbol-partition | true | string | 取引パーティション |
symbol | true | string | 取引ペア |
state | true | string | ステータス[online/offline/suspend] |
min-order-amt | true | float | 最小取引数量 |
max-order-amt | true | float | 最大取引数量 |
limit-order-min-order-amt | true | float | 指値最小注文量 |
limit-order-max-order-amt | true | float | 指値最大注文量 |
limit-order-max-buy-amt | true | float | 指値最大注文量(buy) |
limit-order-max-sell-amt | true | float | 指値最大注文量(sell) |
sell-market-min-order-amt | true | float | 成行最小注文量(sell) |
sell-market-max-order-amt | true | float | 成行最大注文量(sell) |
buy-market-max-order-value | true | float | 成行購入最大金額 |
min-order-value | true | float | 最小注文金額 |
api-trading | true | string | api取引可否 |
対応取引通貨
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/common/currencys"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": [
"jpy",
"btc",
"xrp",
"eth",
"ltc",
"bch",
"mona",
"ht",
"xem",
"xlm",
"lsk",
"bcha",
"etc",
"bat",
"ont",
"qtum",
"trx"
]
}
このエンドポイントは取引できる通貨を返します。
HTTP Request
GET /v1/common/currencys
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
data | true | list | 利用可能な通貨のリスト |
システム時間を調べる
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/common/timestamp"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": 1555667124908
}
このエンドポイントはシステムのUnix Timestamp(ミリ秒)を返します。
HTTP Request
GET /v1/common/timestamp
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
data | true | int | システムのUNIX Timestamp (ミリ秒) |
マーケット関連
ローソク足
curl -X GET \
"https://api-cloud.bittrade.co.jp/market/history/kline?period=1day&size=2&symbol=btcjpy"
上記のコマンドは、次のような構造のJSONを返します。
{
"ch": "market.btcjpy.kline.1day",
"status": "ok",
"ts": 1632969868010,
"data": [
{
"id": 1632931200,
"open": 4663135,
"close": 4815018,
"low": 4580081,
"high": 4830000,
"amount": 6.634525507825414,
"vol": 31208129.2684,
"count": 7534
},
{
"id": 1632844800,
"open": 4621790,
"close": 4662895,
"low": 4550403,
"high": 4763039,
"amount": 32.57668369170352,
"vol": 152697278.3816,
"count": 18230
}
]
}
curl -X GET \
https://api-cloud.bittrade.co.jp/market/history/kline?period=not-exist&size=200&symbol=ethjpy
期間エラーの場合、下記のようなレスポンスを返します。
{
"ts": 1490758171271,
"status": "error",
"err-code": "invalid-parameter",
"err-msg": "invalid period"
}
GET /market/history/kline?period=1day&size=not-exist&symbol=ethjpy
サイズエラーの場合、下記のようなレスポンスを返します。
{
"ts": 1490758221221,
"status": "error",
"err-code": "bad-request",
"err-msg": "invalid size, valid range: [1,2000]"
}
GET /market/history/kline?period=1day&size=200&symbol=not-exist
取引通貨ペアが存在しない場合は、下記のようなレスポンスを返します。
{
"ts": 1490758171271,
"status": "error",
"err-code": "invalid-parameter",
"err-msg": "invalid symbol"
}
URI
GET /market/history/kline
Request Params
Params | Required | Type | Description |
---|---|---|---|
symbol | true | string | 取引ペア |
period | true | string | チャートタイプ |
size | false | int | サイズ[150 ~2000] |
Response Data
Field | Type | Description |
---|---|---|
status | string | リクエスト処理結果 [ok/error] |
ts | number | UNIX Timestamp (ミリ秒) |
tick | object | ローソク足 データ |
ch | string | トピック Example: market.$symbol.kline.$period |
ティッカー
curl -X GET "https://api-cloud.bittrade.co.jp/market/detail/merged?symbol=ethjpy"
上記のコマンドは、次のような構造のJSONを返します。
{
"ch": "market.ethjpy.detail.merged",
"status": "ok",
"ts": 1632981045638,
"tick": {
"id": 201018141213,
"version": 201018141213,
"open": 323786,
"close": 339349,
"low": 312053,
"high": 340294,
"amount": 9.738126685212897,
"vol": 3175875.8505999995,
"count": 2424,
"bid": [
339002,
0.0031
],
"ask": [
339023,
0.0026
]
}
}
このエンドポイントは最近24時間に集約されたティッカー情報を返します。
HTTP Request
GET /market/detail/merged
Query Parameters
Parameter | Required | Description |
---|---|---|
symbol | true | 取引ペア |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
ts | true | number | UNIX Timestamp (ミリ秒) |
ch | true | string | データの所属 |
tick | true | object | ティックデータ |
Tick データの説明
Field | Type | Description |
status | string | リクエスト処理結果[ok/error] |
ch | string | データの所属 |
ts | long | UNIX Timestamp(ミリ秒) |
id | long | ティッカーID |
amount | float | 取引数量 |
count | integer | 取引回数 |
open | float | 開始価格 |
close | float | 最新価格 |
low | float | 最低価格 |
high | float | 最高価格 |
vol | float | 取引量 |
bid | array | 現在の最高買い価格 [price, size] |
ask | array | 現在の最低売り価格 [price, size] |
全取引ペアの相場情報
curl -X GET "https://api-cloud.bittrade.co.jp/market/tickers"
上記のコマンドは、次のような構造のJSONを返します。
{
"data": [
{
"symbol": "btcjpy",
"open": 6461593,
"high": 6519367,
"low": 6233624,
"close": 6287241,
"amount": 117.44015405199148,
"vol": 758503535.8502165,
"count": 25313,
"bid": 6274831,
"bidSize": 0.008,
"ask": 6300013,
"askSize": 0.008
}
]
}
このエンドポイントはすべての取引ペアの最新の取引相場を取得できます。
HTTP Request
GET /market/tickers
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
ts | true | number | UNIX Timestamp (ミリ秒) |
data | true | object | 取引相場のリスト |
板情報
curl -X GET "https://api-cloud.bittrade.co.jp/market/depth?symbol=btcjpy&type=step1"
上記のコマンドは、次のような構造のJSONを返します。
{
"ch": "market.btcjpy.depth.step1",
"status": "ok",
"ts": 1632987521285,
"tick": {
"bids": [
[ 4860380, 0.0001 ],
[ 4860100, 0.0001 ],
[ 4859870, 0.0001 ],
[ 4859760, 0.0001 ],
[ 4849550, 1.0044 ],
[ 4800000, 0.001 ],
[ 4780000, 0.001 ],
[ 4771000, 0.5933 ],
[ 4765400, 1.6756 ],
[ 4759810, 0.8849 ],
[ 4754220, 5 ],
[ 4748620, 0.9396 ],
[ 4700000, 0.005 ],
[ 4600000, 0.0043 ],
[ 4580000, 0.002 ],
[ 4570000, 0.002 ],
[ 4550000, 0.002 ],
[ 4540000, 0.002 ],
[ 4530000, 0.002 ],
[ 4520000, 0.002 ]
],
"asks": [
[ 4860850, 0.0002 ],
[ 4861190, 0.0001 ],
[ 4861380, 0.0001 ],
[ 4861670, 0.0001 ],
[ 4861900, 0.0001 ],
[ 4866190, 0.3783 ],
[ 4879440, 0.0006 ],
[ 4900000, 0.1112 ],
[ 4905000, 0.002 ],
[ 4910000, 0.01 ],
[ 4920000, 0.002 ],
[ 4935000, 0.002 ],
[ 4950000, 0.0122 ],
[ 4960000, 0.01 ],
[ 4970000, 0.01 ],
[ 4978380, 0.001 ],
[ 4980000, 0.0001 ],
[ 4986990, 0.0001 ],
[ 4988450, 0.0001 ],
[ 5000000, 0.1042 ]
],
"version": 100883718161,
"ts": 1632987521070
}
}
GET /market/depth?symbol=btcjpy&type=not-exist
集約レベルがない場合、下記のレスポンスになります
{
"ts": 1490759358099,
"status": "error",
"err-code": "invalid-parameter",
"err-msg": "invalid type"
}
このエンドポイントは板情報を返します。
HTTP Request
GET /market/depth
Query Parameters
Parameter | Required | Description |
---|---|---|
symbol | true | 取引ペア |
type | true | グルーピングレベル[step0~step5] |
Group | 説明 |
---|---|
step0 | グルーピングしない |
step1 | 集約度は価格精度 * 10 |
step2 | 集約度は価格精度 * 100 |
step3 | 集約度は価格精度 * 1000 |
step4 | 集約度は価格精度 * 10000 |
step5 | 集約度は価格精度 * 100000 |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
ts | true | number | UNIX Timestamp(ミリ秒) |
tick | true | object | Tickデータ |
Tick データの説明
Field | Type | Description |
bid | array | 現在の最高買い価格 [price, size] |
ask | array | 現在の最低売り価格 [price, size] |
直近の取引データ
curl -X GET "https://api-cloud.bittrade.co.jp/market/trade?symbol=ethjpy"
上記のコマンドは、次のような構造のJSONを返します。
{
"ch": "market.ethjpy.trade.detail",
"status": "ok",
"ts": 1632988377900,
"tick": {
"id": 100510257146,
"ts": 1632988350412,
"data": [
{
"id": 100510257146375980000000000,
"ts": 1632988350412,
"trade-id": 100030516567,
"amount": 0.0016,
"price": 335385,
"direction": "buy"
},
{
"id": 100510257146375980000000000,
"ts": 1632988350412,
"trade-id": 100030516566,
"amount": 0.0018,
"price": 335331,
"direction": "buy"
},
{
"id": 100510257146375980000000000,
"ts": 1632988350412,
"trade-id": 100030516565,
"amount": 0.0015,
"price": 335307,
"direction": "buy"
},
{
"id": 100510257146375980000000000,
"ts": 1632988350412,
"trade-id": 100030516564,
"amount": 0.0014,
"price": 335256,
"direction": "buy"
},
{
"id": 100510257146375980000000000,
"ts": 1632988350412,
"trade-id": 100030516563,
"amount": 0.0041,
"price": 335221,
"direction": "buy"
}
]
}
}
このエンドポイントは直近の取引履歴を返します。
HTTP Request
GET /market/trade
Query Parameters
Parameter | Required | Description |
---|---|---|
symbol | true | 取引ペア |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
ts | true | number | UNIX Timestamp(ミリ秒) |
tick | true | object | Tickデータ |
tick データの説明
Field | Type | Description |
id | long | Tick ID |
ts | long | UNIX Timestamp(ミリ秒) |
data | array | 取引データ |
dataの説明
Field | Type | Description |
id | long | ID |
ts | long | UNIX Timestamp(ミリ秒) |
trade-id | long | 取引ID |
amount | float | 取引量 |
price | float | 価格 |
direction | string | 方向,["buy","sell"] |
取引履歴の取得
curl -X GET \
"https://api-cloud.bittrade.co.jp/market/history/trade?symbol=ethjpy"
上記のコマンドは、次のような構造のJSONを返します。
{
"ch": "market.ethjpy.trade.detail",
"status": "ok",
"ts": 1632989116305,
"data": [
{
"id": 100510273365,
"ts": 1632989063508,
"data": [
{
"id": 100510273365375970000000000,
"ts": 1632989063508,
"trade-id": 100030516586,
"amount": 0.0013,
"price": 336790,
"direction": "sell"
}
]
}
]
}
このエンドポイントは集約されたチャート情報を返します。
HTTP Request
GET /market/history/trade
Query Parameters
Parameter | Required | Description |
---|---|---|
symbol | true | 取引ペア |
size | false | データサイズ, Range: {1, 2000} |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエスト処理結果 [ok/error] |
ts | true | number | UNIX Timestamp (ミリ秒) |
data | true | object | 約定履歴のリスト |
dataの説明
Field | Type | Description |
id | long | ID |
ts | long | UNIX Timestamp(ミリ秒) |
trade-id | long | 取引ID |
amount | float | 取引数量 |
price | float | 価格 |
direction | string | 方向,["buy","sell"] |
アカウント関連
ユーザアカウント
curl -X GET "https://api-cloud.bittrade.co.jp/v1/account/accounts"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": [
{
"id": 100009,
"type": "spot",
"state": "working",
"user-id": 1000
}
]
}
このエンドポイントはユーザのアカウント情報を返します。
HTTP Request
GET /v1/account/accounts
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
id | true | long | アカウントID |
type | true | string | アカウントタイプ |
state | true | string | アカウントステータス |
user-id | true | int | ユーザID |
残高照合
curl -X GET "https://api-cloud.bittrade.co.jp/v1/account/accounts/{account-id}/balance"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": {
"id": 100009,
"type": "spot",
"state": "working",
"list": [
{
"currency": "jpy",
"type": "trade",
"balance": "500009195917.4362872650"
},
{
"currency": "jpy",
"type": "frozen",
"balance": "328048.1199920000"
},
{
"currency": "etc",
"type": "trade",
"balance": "499999894616.1302471000"
},
{
"currency": "etc",
"type": "frozen",
"balance": "9786.6783000000"
},
{
"currency": "eth",
"type": "trade",
"balance": "499999894616.1302471000"
},
{
"currency": "eth",
"type": "frozen",
"balance": "9786.6783000000"
}
],
"user-id": 1000
}
}
このエンドポイントはユーザの残高情報を返します。
HTTP Request
GET /v1/account/accounts/{account-id}/balance
Query Parameters
Parameter | Required | Description |
---|---|---|
account-id | true | アカウントID |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
id | true | long | アカウントID |
state | true | string | アカウントステータス |
type | true | string | アカウントタイプ |
list | true | list | 残高情報 |
listのデータ構造
フィールド名 | 必須 | データの種類 | 説明 |
balance | true | long | 残高 |
currency | true | string | 暗号資産 |
type | true | string | タイプ, trade: トレード残高,frozen: 凍結残高 |
取引関連
共通定義
注文タイプ
Type | Description |
---|---|
buy-market | 成行買い |
sell-market | 成行売り |
buy-limit | 指値買い |
sell-limit | 指値売り |
buy-ioc | IOC買い注文 |
sell-ioc | IOC売り注文 |
buy-limit-maker | メーカーのみ(買い) |
sell-limit-maker | メーカーのみ(売り) |
注文ステータス
Status | Description |
---|---|
created | 注文作成 |
submitted | 発注済み |
partial-filled | 部分約定 |
partial-canceled | 部分キャンセル |
filled | 全部約定 |
canceled | キャンセル |
canceling | キャンセル中 |
注文実行
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/order/orders/place" \
-d \
{
"account-id": "100009",
"amount": "10.1",
"price": "100.1",
"source": "api",
"symbol": "ethjpy",
"type": "buy-limit"
}
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": "59378"
}
このエンドポイントは注文を出します。
HTTP Request
POST /v1/order/orders/place
Query Parameters
Parameter | Required | Description |
---|---|---|
account-id | true | アカウントID |
amount | true | 取引数量 |
price | false | 指値の注文価格 |
source | false | 注文方法 |
symbol | true | 通貨ペア |
type | true | 注文タイプ buy-market:成行買い sell-market:成行売り buy-limit:指値買い sell-limit:指値売り buy-ioc:IOC買い注文 sell-ioc:IOC売り注文 buy-limit-maker sell-limit-maker |
client-order-id | true | ユーザーが作成した注文番号 (最大長は64文字で、8時間以内に一意である必要があります) |
buy-limit-maker
“注文価格”>=“市場最低売り価格”である場合,注文送信後,システムはこの注文を約定拒否します。
“注文価格”<“市場最低売り価格”である場合,送信成功後,この注文はシステムによって受け入れられます。
sell-limit-maker
“注文価格”<=“市場最高買い入れ価格” である場合,注文送信後,システムはこの注文を受け入れることを拒否します。
“注文価格”>“市場最高買い入れ価格” である場合, 送信成功後,この注文はシステムによって受け入れられます。
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
data | false | string | 注文ID |
未約定注文一覧
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/order/openOrders"
上記のコマンドは、次のような構造のJSONを返します。
{
"data": [
{
"account-id": 12698099,
"amount": "2.000000000000000000",
"client-order-id": "",
"created-at": 1633016858283,
"filled-amount": "0.0",
"filled-cash-amount": "0.0",
"filled-fees": "0.0",
"id": 375977156321165,
"price": "1.000000000000000000",
"source": "api",
"state": "submitted",
"symbol": "xrpjpy",
"type": "buy-limit"
}
],
"status": "ok"
}
このエンドポイントは未約定注文一覧を返します。
HTTP Request
GET /v1/order/openOrders
Query Parameters
Parameter | Required | Description |
---|---|---|
account-id | true | アカウントID |
symbol | true | 通貨ペア |
side | false | 取引方向 [buy/sell] |
size | false | 必要な記録数 |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
id | true | long | 注文ID |
symbol | true | string | 通貨ペア |
price | true | string | 注文価格 |
created-at | true | int | 注文時間(ミリ秒) 部分取引注文でない場合、このフィールドは0 になります |
type | true | string | 注文タイプ |
filled-amount | true | string | 部分約定した数量 |
filled-cash-amount | true | string | 部分約定した金額(=約定された注文の数量x注文の価格) 部分取引注文でない場合、このフィールドは0になります |
filled-fees | true | string | 部分約定の手数料額 部分取引注文でない場合、このフィールドは0 になります |
source | true | string | 注文方法 |
state | true | string | 注文ステータス |
client-order-id | true | string | ユーザ作成された注文ID |
注文キャンセル
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/order/orders/{order-id}/submitcancel"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": 59378
}
本APIはキャンセルリクエストを送信します。実際のキャンセル結果は注文詳細APIにてご確認してください。
HTTP Request
POST /v1/order/orders/{order-id}/submitcancel
Query Parameters
Parameter | Required | Description |
---|---|---|
order-id | true | 注文ID |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエストの状態 |
data | false | string | 注文ID |
注文の一括キャンセル
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/order/orders/batchcancel" \
-d \
{
"order-ids": [
"1",
"2",
"3"
]
}
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": {
"success": [
"1",
"2",
"3"
]
}
}
失敗する場合、下記のようなレスポンスが返します。
{
"status": "error",
"err-code": "order-orderstate-error",
"err-msg": "Incorrect order state",
"data": null,
"order-state": 7
}
本APIは注文の一括キャンセルを実行します。
HTTP Request
POST /v1/order/orders/batchcancel
Query Parameters
Parameter | Required | Description |
---|---|---|
order-ids | false | 注文ID |
client-order-ids | false | ユーザ定義した注文ID |
・order-idsとclient-order-idsから選べる、最大50オーダー
・order-idsの方が安定するので、お勧めします。
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
status | true | string | リクエストの状態 |
data | true | string | キャンセルの結果 |
order-state対応表
order-state | Description |
-1 | closed |
1 | created |
3 | submitted |
4 | partial-filled |
5 | partial-canceled |
6 | filled |
7 | canceled |
10 | cancelling |
条件付き注文の一括キャンセル
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/order/orders/batchCancelOpenOrders"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": {
"success-count": 2,
"failed-count": 0,
"next-id": 5454600
}
}
本APIは条件付き注文を一括でキャンセルする。
HTTP Request
POST /v1/order/orders/batchCancelOpenOrders
Query Parameters
Parameter | Required | Description |
---|---|---|
account-id | true | アカウントID |
symbol | false | 通貨ペア (最大10ペア、複数の取引ペアはコンマで区切られます) |
side | false | 取引方向[buy/sell], デフォルトでは、条件が満たされていない全ての注文が返されます。 |
size | false | 必要な記録数[0〜100] |
types | false | カンマで区切られた注文タイプの組み合わせ |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
success-count | true | int | キャンセル注文成功数 |
failed-count | true | int | キャンセル注文失敗数 |
next-id | true | long | キャンセル基準を満たす次の注文ID |
注文の照会
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/order/orders/{order-id}"
上記のコマンドは、次のような構造のJSONを返します。
{
"data": {
"account-id": 12698099,
"amount": "2.000000000000000000",
"canceled-at": 0,
"client-order-id": "",
"created-at": 1633016858283,
"field-amount": "0.0",
"field-cash-amount": "0.0",
"field-fees": "0.0",
"finished-at": 0,
"id": 375977156321165,
"price": "1.000000000000000000",
"source": "api",
"state": "submitted",
"symbol": "xrpjpy",
"type": "buy-limit"
},
"status": "ok"
}
このエンドポイントは注文の詳細情報を返します。
HTTP Request
GET /v1/order/orders/{order-id}
Query Parameters
Parameter | Required | Description |
---|---|---|
order-id | true | 注文ID |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
account-id | true | long | アカウント ID |
amount | true | string | 注文数量 |
canceled-at | false | long | キャンセル時間 |
created-at | true | long | 注文作成時間 |
field-amount | true | string | 約定数量 |
field-cash-amount | true | string | 約定総額 |
field-fees | true | string | 約定手数料 |
finished-at | false | long | 注文の終了時間は約定した時間ではなく、キャンセル済の時も含みます |
id | true | long | 注文ID |
client-order-id | true | long | クライアント作成した注文ID |
price | true | string | 注文価格 |
source | true | string | 注文方法 |
state | true | string | 注文ステータス |
symbol | true | string | 通貨ペア |
type | true | string | 注文タイプ |
注文の約定詳細
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/order/orders/{order-id}/matchresults"
上記のコマンドは、次のような構造のJSONを返します。
{
"data": [
{
"created-at": 1633018402536,
"fee-currency": "xrp",
"fee-deduct-currency": "",
"fee-deduct-state": "done",
"filled-amount": "0.1",
"filled-fees": "0.00015",
"filled-points": "0.0",
"id": 372969482257005,
"match-id": 100554712526,
"order-id": 375977348044411,
"price": "104.74",
"role": "taker",
"source": "spot-api",
"symbol": "xrpjpy",
"trade-id": 100026336962,
"type": "buy-limit"
}
],
"status": "ok"
}
このエンドポイントは注文の約定詳細情報を返します。
HTTP Request
GET /v1/order/orders/{order-id}/matchresults
Query Parameters
Parameter | Required | Description |
---|---|---|
order-id | true | 注文ID |
Response Data
Field | Type | Description |
---|---|---|
created-at | Long | 注文作成時間 |
fee-currency | String | 手数料単位 |
filled-amount | Float | 約定数量 |
filled-fees | Float | 約定手数料 |
filled-points | Float | 約定Point |
id | Long | 約定ID |
match-id | Long | マッチングID |
order-id | Long | オーダーID |
price | Float | 約定価格 |
role | String | taker or maker |
source | String | 経路 |
symbol | String | 取引ペア |
trade-id | Long | 取引ID |
type | String | 約定方式 |
注文履歴の検索
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/order/orders"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": [
{
"id": 345487249132375,
"symbol": "btcjpy",
"account-id": 13496526,
"client-order-id": "",
"amount": "50.000000000000000000",
"price": "0.0",
"created-at": 1629443051822,
"type": "buy-market",
"field-amount": "147.928994082840236000",
"field-cash-amount": "49.999999999999999768",
"field-fees": "0.295857988165680472",
"finished-at": 1629443051838,
"source": "spot-web",
"state": "filled",
"canceled-at": 0
}
]
}
このエンドポイントは条件にあった注文履歴を返します。
HTTP Request
GET /v1/order/orders
Query Parameters
Parameter | Required | Description |
---|---|---|
symbol | true | 通貨ペア |
types | false | 注文タイプ |
start-time | false | 参照開始日時(ミリ秒) ※default:-48時間。照会できる最大の範囲は過去180日。キャンセル済み注文の照会範囲は過去2時間 |
end-time | false | 参照終了日時(ミリ秒) ※照会できる最大の範囲は過去180日。キャンセル済み注文の照会範囲は過去2時間 |
states | true | 注文ステータス |
from | false | 開始照会ID, 注文約定記録ID(最大值) |
direct | false | 照会方向,約定IDの新着順 default: next, Range: {"prev", "next"} |
size | false | 記録数, default:100, max: 100 |
Response Data
Parameter | Type | Description |
---|---|---|
account-id | long | アカウント ID |
amount | string | 注文数量 |
canceled-at | long | キャンセル受付時間 |
client-order-id | string | 注文時付与された識別ID |
created-at | long | 注文作成時間 |
field-amount | string | 約定数量 |
field-cash-amount | string | 約定金額 |
field-fees | string | 約定済み手数料 |
finished-at | long | 最終的な約定時間 |
id | long | 注文ID |
price | string | 注文価格 |
source | string | 注文方法 |
state | string | 注文ステータス |
symbol | string | 通貨ペア |
type | string | 注文タイプ |
約定履歴の検索
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/order/matchresults"
上記のコマンドは、次のような構造のJSONを返します。
{
"data": [
{
"created-at": 1633018402536,
"fee-currency": "xrp",
"fee-deduct-currency": "",
"fee-deduct-state": "done",
"filled-amount": "0.1",
"filled-fees": "0.00015",
"filled-points": "0.0",
"id": 372969482257005,
"match-id": 100554712526,
"order-id": 375977348044411,
"price": "104.74",
"role": "taker",
"source": "spot-api",
"symbol": "xrpjpy",
"trade-id": 100026336962,
"type": "buy-limit"
}
],
"status": "ok"
}
このエンドポイントは検索条件にあった約定履歴を返します。
HTTP Request
GET /v1/order/matchresults
Query Parameters
Parameter | Required | Description |
---|---|---|
symbol | true | 通貨ペア |
types | false | 注文タイプ |
start-time | false | 参照開始日時(ミリ秒) ※default:-48時間。照会できる最大の範囲は過去120日。 |
end-time | false | 参照終了日時(ミリ秒) ※照会できる最大の範囲は過去 120 日。 |
states | true | 取引ステータス |
from | false | 開始ID |
direct | false | 照会方向,約定IDの新着順 default: next, Range: {"prev", "next"} |
size | false | 記録数, Range: [0, 100] |
Response Data
Field | Type | Description |
---|---|---|
created-at | Long | 注文作成時間 |
fee-currency | String | 手数料単位 |
filled-amount | Float | 約定数量 |
filled-fees | Float | 約定手数料 |
filled-points | Float | 約定Point |
id | Long | 約定ID |
match-id | Long | マッチングID |
order-id | Long | オーダーID |
price | Float | 約定価格 |
role | String | taker or maker |
source | String | 経路 |
symbol | String | 取引ペア |
trade-id | Long | 取引ID |
type | String | 約定方式 |
エラーコード一覧
Code | Description |
---|---|
base-symbol-error | 取引ペアが存在しない |
base-currency-error | 銘柄が存在しない |
base-date-error | 日時フォーマットのエラー |
account-transfer-balance-insufficient-error | 残高不足 |
bad-argument | パラメーターの期限切れ |
api-signature-not-valid | API署名エラー |
gateway-internal-error | システムビジー,少し時間をおいて再度お試しください |
security-require-assets-password | 資金パスワードの入力が必要 |
audit-failed | 注文失敗 |
ad-ethereum-address | 有効なETHのアドレスを入力してください |
order-accountbalance-error | アカウント残高不足 |
order-limitorder-price-error | 指値の注文価格が制限を超えている |
order-limitorder-amount-error | 指値の注文量が制限を超えている |
order-orderprice-precision-error | 注文価格が制限精度を超えている |
order-orderamount-precision-error | 注文量が制限精度を超えている |
order-marketorder-amount-error | 注文量が制限を超えている |
order-queryorder-invalid | この注文を見つけることができない |
order-orderstate-error | 注文ステータスエラー |
order-datelimit-error | 照会時間制限を超えた |
order-update-error | 注文の更新失敗 |
ウォレット関連
ステータス一覧
暗号資産出金ステータスの定義:
Status | Description |
---|---|
submitted | 依頼済み |
reexamine | 審査中 |
canceled | キャンセル済 |
pass | 承認 |
reject | 拒否 |
pre-transfer | 処理中 |
wallet-transfer | 送金済 |
wallet-reject | ウオレットの拒否 |
confirmed | ブロックチェーン上で承認済 |
confirm-error | ブロックチェーン上で承認エラー |
repealed | キャンセル済 |
暗号資産入金ステータスの定義:
ステータス | 説明 |
---|---|
unknown | 不明 |
confirming | 確認中 |
confirmed | 確認済み |
safe | 完了 |
orphan | 独立 |
暗号資産の出金申請
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/dw/withdraw/api/create" \
-d \
{
"address": "0xde709f2102306220921060314715629080e2fb77",
"amount": "0.05",
"currency": "eth",
"fee": "0.01"
}
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": 700
}
本APIは暗号資産の出金申請を送信します。
HTTP Request
POST /v1/dw/withdraw/api/create
Query Parameters
Parameter | Required | Type | Description |
---|---|---|---|
address | true | string | 出金アドレス |
amount | true | string | 出金数量 |
currency | true | string | 通貨種別 |
fee | true | string | 送金手数料 |
addr-tag | false | string | タグ |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
data | false | long | 出金記録ID |
暗号資産の出金のキャンセル
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/dw/withdraw-virtual/{withdraw-id}/cancel"
上記のコマンドは、次のような構造のJSONを返します。
{
"status": "ok",
"data": 700
}
本APIは暗号資産出金のキャンセルリクエストを送信します。
HTTP Request
POST /v1/dw/withdraw-virtual/{withdraw-id}/cancel
Query Parameters
Parameter | Required | Description |
---|---|---|
withdraw-id | true | 出金ID |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
data | false | string | 出金記録ID |
入出金記録
curl -X GET \
"https://api-cloud.bittrade.co.jp/v1/query/deposit-withdraw"
上記のコマンドは、次のような構造のJSONを返します。
{
"data":
[
{
"id": 1171,
"type": "deposit",
"currency": "xrp",
"tx-hash": "ed03094b84eafbe4bc16e7ef766ee959885ee5bcb265872baaa9c64e1cf86c2b",
"amount": 7.457467,
"address": "rae93V8d2mdoUQHwBDBdM4NHCMehRJAsbm",
"address-tag": "100040",
"fee": 0,
"state": "safe",
"created-at": 1510912472199,
"updated-at": 1511145876575
}
]
}
このエンドポイントは入出金記録を返します。
HTTP Request
GET /v1/query/deposit-withdraw?currency=xrp&type=deposit&from=5&size=12
Query Parameters
Parameter | Required | Description |
---|---|---|
currency | true | 銘柄 |
type | true | 'deposit' or 'withdraw' |
from | false | 照会開始 ID |
size | false | 記録数 |
Response Data
Parameter | Required | Type | Description |
---|---|---|---|
id | true | long | 入出金ID |
type | true | long | タイプ 'deposit' 'withdraw' |
currency | true | string | 銘柄 |
tx-hash | true | string | トレードハッシュ |
amount | true | long | 数量 |
address | true | string | アドレス |
address-tag | true | string | アドレスラベル |
fee | true | long | 手数料 |
state | true | string | ステータス |
created-at | true | long | 開始時間 |
updated-at | true | long | 最後に更新した時間 |
販売所関連
販売所のAPIを使って、下記のことができます
- 販売所各通貨のリアルタイム価格の取得
- 販売所の約定履歴の取得
- ID指定で暗号資産の売買
- ユーザの販売履歴の取得
- 販売所のメンテナンス時間の取得
データ購読
$ wscat -P -c wss://api-cloud.bittrade.co.jp/retail/ws
Connected (press CTRL+C to quit)
- url: wss://api-cloud.bittrade.co.jp/retail/ws
Request
接続後、JSON形式でコマンド発行できます。
$ wscat -P -c wss://api-cloud.bittrade.co.jp/retail/ws
Connected (press CTRL+C to quit)
{"action":1,"topic":1} // 各通貨価格を購読
{"action":2,"topic":1} // 価格購読を解除
{"action":1,"topic":2} // 約定履歴を購読
{"action":2,"topic":2} // 約定履歴の購読を解除
{"action":4,"ts":1571388770} // Pingコマンド発行
{"action":5,"ts":1571388770} // Pongコマンド発行
Field | Required | Type | Description |
---|---|---|---|
ts | false | long | timestamp, 10桁 |
action | true | int | アクション, 1: 購読, 2: 購読解除, 4: ping, 5: pong |
topic | false | int | トピック, 1: 販売所価格, 2: 販売所約定履歴 |
Response
Response Data
Field | Type | Description |
---|---|---|
topic | int | リクエストのトピック値 |
action | int | リクエストのアクション値 |
ts | int | Timestamp (秒) |
offer | list | Offer Dataに参照 |
trade | list | Trade Dataに参照 |
Offer Data
購読後、自動的に下記のデータがプッシュされます。
{
"code": 200,
"data": {
"action": 1,
"offer": [
{
"buy_price": "474141.06666666",
"buy_ratio": "0.11",
"id": "26cbe6a90df849bca08c32ba53904bb7",
"market_price": "431035.68333333",
"market_ratio": "0.11",
"sell_price": "387930.30000000",
"sell_ratio": "0.11",
"symbol": "BTCJPY",
"buy_min_amount": "1",
"buy_max_amount": "1000",
"sell_min_amount": "1",
"sell_max_amount": "1000"
},
{
"buy_price": "27.51",
"buy_ratio": "-14.59",
"id": "ec02bbe57f414f0593ff00c21e6b008e",
"market_price": "25.00",
"market_ratio": "-14.56",
"sell_price": "22.48",
"sell_ratio": "-14.59",
"symbol": "XRPJPY",
"buy_min_amount": "1",
"buy_max_amount": "1000",
"sell_min_amount": "1",
"sell_max_amount": "1000"
}
],
"topic": 1,
"ts": 1571388770
},
"success": true
}
Field | Type | Description |
---|---|---|
id | string | 一意識別子 |
symbol | string | 取引通貨 |
sell_price | string | 売値 |
buy_price | string | 買値 |
sell_ratio | string | 売値の騰落率 |
buy_ratio | string | 買値の騰落率 |
market_price | string | 平均価格 |
market_ratio | string | 騰落率 |
sell_min_amount | string | 最小売り数量 |
sell_max_amount | string | 最大売り数量 |
buy_min_amount | string | 最小買い数量 |
buy_max_amount | string | 最大買い数量 |
Trade Data
{
"code": 200,
"success": true,
"data": {
"topic": 2,
"action": 1,
"ts": 1553480751,
"orders": [
{
"gmt_trade": "150004343554",
"symbol": "btcjpy",
"type": 1,
"price": "15.21",
"amount": "3.56",
"cash_amount": "54.1476"
},
{
"gmt_trade": "150004343554",
"symbol": "ethjpy",
"type": 1,
"price": "15.21",
"amount": "3.56",
"cash_amount": "54.1476"
}
]
}
}
Field | Type | Description |
---|---|---|
gmt_trade | long | 取引時刻(timestamp) |
symbol | string | 取引通貨 |
type | int | 取引方向: 1: 買う,2: 売る |
price | string | 価格 |
amount | string | 数量 |
cash_amount | string | 金額 |
販売所での注文
curl -X POST \
-H "Content-Type: application/json" \
"https://api-cloud.bittrade.co.jp/v1/retail/order/place?AccessKeyId={accessKey}&SignatureVersion=2&Signature={計算された署名}&SignatureMethod=HmacSHA256&Timestamp=2019-12-23T03%3A56%3A59" \
-d \
{
"id":"791025bfdc3b45459b96b5d776ede78f",
"symbol": "btcjpy",
"type": 1,
"amount": "10.12",
"price": "34.23",
"source": 1
}
上記のコマンドは、次のような構造のJSONを返します。
{
"code": 200,
"data": 123456978,
"message": null,
"success": true
}
このAPIは、販売所で指定された暗号資産を売買できます。
HTTP Request
POST /v1/retail/order/place
Query Parameters
Parameter | Required | Type | Description |
---|---|---|---|
id | true | string | websocketから取得されたリアルタイム価格のID, 32桁 |
symbol | true | string | 取引ペア |
type | true | int | 注文方向, 1:購入, 2:売却 |
amount | false | double | 取引量, decimal(36,18) |
price | true | string | 取引価格, decimal(36,18) |
source | true | string | 経路, 4:api固定 |
client_order_id | false | string | クライアントカスタマイズID |
cash_amount | false | double | 現金金額, decimal(36,18) |
order-instruction | true | int | 注文種類, 1: FOK |
Response Data
Parameter | Type | Description |
---|---|---|
code | int | Http Status Code |
data | long | 注文ID |
message | string | メッセージ |
success | bool | オペレーション成功か |
販売所注文履歴
curl -X GET "https://api-cloud.bittrade.co.jp/v1/retail/order/list?AccessKeyId={accessKey}&Signature={計算された署名}&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2019-12-23T11%3A44%3A13&direct=1"
上記のコマンドは、次のような構造のJSONを返します。
{
"code": 200,
"data": [
{
"amount": "1",
"base_currency": "BTC",
"cash_amount": "473113.85",
"gmt_traded": 1556078181000,
"id": 1234567951,
"order_type": 1,
"price": "473113.85",
"state": 3,
"symbol": "BTCJPY",
"symbol_name": "BTC/JPY"
},
{
"amount": "1100",
"base_currency": "BTC",
"cash_amount": "425967300",
"gmt_traded": 1555668195000,
"id": 1234567942,
"order_type": 2,
"price": "387243",
"state": 4,
"symbol": "BTCJPY",
"symbol_name": "BTC/JPY"
}
],
"message": null,
"success": true
}
このAPIは、注文履歴を表示することができます。
HTTP Request
GET /v1/retail/order/list
Query Parameters
Parameter | Required | Type | Description |
---|---|---|---|
id | false | long | 注文番号 |
limit | false | int | 表示件数, default=10, max: 100 |
from | false | string | 開始ID, 1ページ以後必要 |
direct | true | int | 注文方向, 1:next, 2:previous |
base_currency | false | string | 基礎通貨 |
quote_currency | false | string | 通貨単位 |
symbol | false | string | 取引ペア |
order_type | false | string | 取引タイプ, 1:buy, 2:sell |
state | true | int | 成約状態, 1: 進行中, 2: 完全約定, 3: 未成約 |
Response Data
Parameter | Type | Description |
---|---|---|
code | int | Http Status Code |
data | list | 注文履歴の内容, Data構造に参照 |
message | string | メッセージ |
success | bool | 成功したか |
DATA構造
Parameter | Type | Description |
---|---|---|
id | long | 注文番号 |
gmt_traded | long | 成約時間, timestamp |
symbol_name | string | 取引通貨名 |
symbol | string | 取引通貨記号 |
base_currency | string | 基礎通貨 |
order_type | int | 注文方向, 1: buy, 2: sell |
price | long | 価格 |
amount | long | 数量 |
cash_amount | long | 金額 |
state | long | 注文状態, 1: 進行中, 2: 完全成約, 3: 部分成約, 4: 未成約 |
client_order_id | long | クライアント側カスタマイズID |
order_source | long | 経路, 1:web, 2:app, 3:mobile, 4:api |
order_instruction | long | 成約ロジック, 1: FOK |
販売所メンテナンス時間
curl -X GET "https://api-cloud.bittrade.co.jp/v1/retail/maintain/time"
上記のコマンドは、次のような構造のJSONを返します。
{
"code": 200,
"data": {
"start_time": "16:30:00",
"end_time": "17:00:00",
"ts": 150004343554,
"state": 0
},
"message": null,
"success": true
}
このAPIは、メンテナンス時刻を表示することができます。
HTTP Request
GET /v1/retail/maintain/time
Query Parameters
- なし
Response Data
Parameter | Type | Description |
---|---|---|
code | int | Http Status Code |
data | data | データクラスを参照 |
message | string | メッセージ |
success | bool | 成功したか |
・データクラス
Parameter | Type | Description |
---|---|---|
start_time | String | メンテナンス開始時間 |
end_time | String | メンテナンス終了時間 |
ts | long | Timestamp(UTC) |
state | int | メンテナンスステータス, 0: 正常,1: メンテナンス中 |
Websocket (Public)
購読・リクエスト
1. アドレス
- URL :
wss://api-cloud.bittrade.co.jp/ws
2. データ圧縮
- WebSocket API 経由で返されるデータはすべてGZIP圧縮されており、データ受信者側のクライアントにて解凍する必要があります。Pakoを使用することをお勧めします。(pako とは圧縮・解凍できるGZIPのリポジトリである)
3. WebSocketライブラリ
- ws のWebSocketライブラリになります。
4. ハートビート
WebSocket Server がpingを送信する
{
"ping": 18212558000
}
WebSocket Client がpongを返信する
{
"pong": 18212558000
}
private websocketの場合
{
"action": "pong",
"data": {
"ts": 1575537778295
}
}
注:"pong"の応答値は受信した"ping" の値と同一の値となります。
WebSocket Client がpingを送信する
{"ping": 18212553000}
private websocketの場合
{
"action": "ping",
"data": {
"ts": 1575537778295
}
}
注:必ずLong型の"ping"を送信しなければなりません。そうでなければ、誤ったデータが返信されます
{
"ts": 1492420473027,
"status": "error",
"err-code": "bad-request",
"err-msg": "invalid ping"
}
WebSocket Server がpongを返信する
{"pong": 18212553000}
注:返信される"pong" の応答値は受信した"ping"` の値と同一の値となります。
エラー時の返信フォーマット
{
"id": "id generate by client",
"status": "error",
"err-code": "err-code",
"err-msg": "err-message",
"ts": 1487152091345
}
WebSocket Client と WebSocket Server との間でコネクション確立後、WebSocket Server は 5s(変更の可能性がある)ごとに WebSocket Client にpingを送信し、WebSocket Client より2回連続Pingへの応答がなければ、WebSocket Server はコネクションを切断します。WebSocket Clientが直近2回のPingのうちの1つのpingに応答すれば、WebSocket Serverはコネクションを維持します。
注:WebSocket Clientが直近2回のmessageのうちの1つのpingを送信すれば、WebSocket Serverはコネクションを維持します。
注:2回連続WebSocket Client からの応答がなければ、WebSocket Server はコネクションを切断します。
6. データリクエスト(req)
データリクエストのフォーマット
{
"req": "topic to req",
"id": "id generate by client"
}
データリクエストの正しい例
{
"req": "market.ethbtc.kline.1min",
"id": "id10"
}
返信データ例
{
"status": "ok",
"rep": "market.btcjpy.kline.1min",
"tick": [
{
"amount": 1.6206,
"count": 3,
"id": 1494465840,
"open": 9887.00,
"close": 9885.00,
"low": 9885.00,
"high": 9887.00,
"vol": 16021.632026
},
{
"amount": 2.2124,
"count": 6,
"id": 1494465900,
"open": 9885.00,
"close": 9880.00,
"low": 9880.00,
"high": 9885.00,
"vol": 21859.023500
}
]
}
データリクエストのエラー例
{
"req": "market.invalidsymbo.kline.1min",
"id": "id10"
}
エラーメッセージ応答例
{
"status": "error",
"id": "id10",
"err-code": "bad-request",
"err-msg": "invalid topic market.invalidsymbol.trade.detail",
"ts": 1494483996521
}
7.データの購読(sub)
- データの購読フォーマット
WebSocket API との接続を行った後、 Serverに以下のフォーマットのデータを送信することにより、データを購読する
{
"id": "id generate by client",
"sub": "topic to sub",
"freq-ms": 1000
}
注:idのパラメータは選択可能です 注:freq-msのパラメータは選択可能であり、選択値は{ 1000, 2000, 3000, 4000, 5000 }になります。freq-ms をアップロードしない限り、デフォルト値は0となり、データが更新される際、直ちにClientにプッシュ配信されることになります。 Server のプッシュ配信の頻度はfreq-msにて調整できます。
購読の正しい例
{
"sub": "market.btcjpy.kline.1min",
"id": "id1"
}
"sub"の値はtopicであり、「5. Topicのフォーマット」のtopic のフォーマット参照
- 購読完了後、データを返信された例
{
"id": "id1",
"status": "ok",
"subbed": "market.btcjpy.kline.1min",
"ts": 1489474081631
}
その後、 KLineが更新されるたびに、clientはデータを受信する
{
"ch": "market.btcjpy.kline.1min",
"ts": 1489474082831,
"tick": {
"id": 1489464480,
"amount": 0.0,
"count": 0,
"open": 7962.62,
"close": 7962.62,
"low": 7962.62,
"high": 7962.62,
"vol": 0.0
}
}
- データの購読(sub)及び購読データ受信の流れ
注: topic の購読完了後、 topicのデータが更新される際、 Server は一定の頻度でtopicの更新データを Clientにプッシュ配信する
- tick の説明
{
"tick": {
"id": "チャートid",
"amount": "取引量",
"count": "約定回数",
"open": "始値",
"close": "終値 最後の一本のローソク足は最新の約定価格である",
"low": "最安値",
"high": "最高値",
"vol": "取引高, 取引価格*約定の量=取引量合計"
}
}
- 誤った購読(誤った symbol)
{
"sub": "market.invalidsymbol.kline.1min",
"id": "id2"
}
購読が失敗した場合、データが返送された例:
{
"id": "id2",
"status": "error",
"err-code": "bad-request",
"err-msg": "invalid topic market.invalidsymbol.kline.1min",
"ts": 1494301904959
}
- 誤った購読(間違った topic):
{
"sub": "market.btcjpy.kline.3min",
"id": "id3"
}
購読が失敗した場合、データが返信された例:
{
"id": "id3",
"status": "error",
"err-code": "bad-request",
"err-msg": "invalid topic market.btcjpy.kline.3min",
"ts": 1494310283622
}
8.購読の停止(unsub)
- 購読の停止フォーマット
購読停止のフォーマットについては以下のとおりになります。
{
"unsub": "topic to unsub",
"id": "id generate by client"
}
購読停止の正しい例。
{
"unsub": "market.btcjpy.trade.detail",
"id": "id4"
}
購読停止完了後、データが返信された例。
{
"id": "id4",
"status": "ok",
"unsubbed": "market.btcjpy.trade.detail",
"ts": 1494326028889
}
購読停止の誤った例(未購読のtopicを中止する)
{
"unsub": "market.btcjpy.trade.detail",
"id": "id5"
}
誤ったデータが返信された例
{
"id": "id5",
"status": "error",
"err-code": "bad-request",
"err-msg": "unsub with not subbed topic market.btcjpy.trade.detail",
"ts": 1494326217428
}
- 購読停止の誤った例(存在しないtopicを中止する)
{
"unsub": "not-exists-topic",
"id": "id5"
}
誤ったデータが返信された例
{
"id": "id5",
"status": "error",
"err-code": "bad-request",
"err-msg": "unsub with not subbed topic not-exists-topic",
"ts": 1494326318809
}
WebSocket Client はデータの購読後、購読を停止することも可能です。停止後は、WebSocket Serverが 当該topicのデータをプッシュしなくなります。
トピックからのデータ受信を停止するには、「unsub」メッセージを送信する必要があります。
トピック一覧
トピック名 | 説明 |
---|---|
market.$symbol.kline.$period | ローソク足 |
market.$symbol.depth.$type | 板情報 (depth) |
market.$symbol.bbo | 板情報(BBO) |
market.$symbol.trade.detail | 通貨ペア |
market.$symbol.detail | マーケット概要 |
ローソク足 データ
購読
{
"sub": "market.ethbtc.kline.1min",
"id": "id1"
}
購読成功のレスポンス
{
"id": "id1",
"status": "ok",
"subbed": "market.ethbtc.kline.1min",
"ts": 1489474081631
}
リクエスト送信
{
"req": "market.$symbol.kline.$period",
"id": "クライアントから生成されたID",
"from": "開始タイムスタンプ",
"to": "終了タイムスタンプ"
}
受信データ
{
"ch": "market.ethbtc.kline.1min",
"ts": 1489474082831,
"tick": {
"id": 1489464480,
"amount": 0.0,
"count": 0,
"open": 7962.62,
"close": 7962.62,
"low": 7962.62,
"high": 7962.62,
"vol": 0.0
}
}
トピック
market.$symbol.kline.$period
key | necessary | type | description | value |
---|---|---|---|---|
symbol | true | string | Pairs | btcjpy、ethjpy... |
period | true | string | KLine period | 1min, 5min, 15min, 30min, 60min, 1day, 1mon, 1week, 1year |
リクエスト方式
key | description |
---|---|
req | market.$symbol.kline.$period |
id | クライアントによって生成されたID |
from | Timestamp (second) |
to | Timestamp (second) |
板情報
購読の場合
{
"sub": "market.ethbtc.depth.step0",
"id": "id1"
}
購読成功のレスポンス
{
"id": "id1",
"status": "ok",
"subbed": "market.ethbtc.depth.step0",
"ts": 1489474081631
}
リクエスト送信
{
"req": "market.ethbtc.depth.step0",
"id": "id10"
}
受信データ
{
"ch": "market.ethbtc.depth.step0",
"ts": 1489474082831,
"data": {
"bids": [
[9999.3900,0.0098],
[9992.5947,0.0560]
],
"asks": [
[10010.9800,0.0099],
[10011.3900,2.0000]
]
}
}
トピック
market.$symbol.depth.$type
変数の説明
key | necessary | type | description | value |
---|---|---|---|---|
symbol | true | string | Pairs | ethbtc, ltcbtc, etcbtc, bccbtc... |
type | true | string | Market depth | step0, step1, step2, step3, step4, step5 |
リクエスト方式
key | description |
---|---|
req | market.$symbol.depth.$period |
id | クライアントによって生成されたID |
BBO
板情報の中に一番近い買い(BID)、売り(ASK)の指値注文になります。
トピック
market.$symbol.bbo
購読送信
{
"sub": "market.btcjpy.bbo",
"id": "id1"
}
パラメータの説明
Param | タイプ | 必須 | デフォルト | 説明 | 範囲 |
---|---|---|---|---|---|
symbol | string | true | NA | 取引ペア |
購読成功のレスポンス
{
"id": "id1",
"status": "ok",
"subbed": "market.btcjpy.bbo",
"ts": 1489474081631
}
受信データ
{
"ch":"market.btcjpy.bbo",
"ts":1630994555540,
"tick":{
"seqId":137005210233,
"ask":52665.02,
"askSize":1.502181,
"bid":52665.01,
"bidSize":0.178567,
"quoteTime":1630994555539,
"symbol":"btcjpy"
}
}
受信データ
フィールド | データ種類 | 説明 |
---|---|---|
ch | string | トピック |
ts | long | システム反映時間 |
data | object | データ |
dataの説明
フィールド | データ種類 | 説明 |
---|---|---|
symbol | string | 取引ペア |
quoteTime | long | 更新時間 |
bid | float | Bid1の注文価格 |
bidSize | float | Bid1の注文量 |
ask | float | Ask1の注文価格 |
askSize | float | Ask1の注文量 |
seqId | int | メッセージシーケンス番号 |
ティッカー
購読
{
"sub": "market.ethbtc.trade.detail",
"id": "id1"
}
購読成功のレスポンス
{
"id": "id1",
"status": "ok",
"subbed": "market.ethbtc.trade.detail",
"ts": 1489474081631
}
リクエスト送信
{
"req": "market.ethbtc.trade.detail",
"id": "id11"
}
受信データ
{
"ch":"market.btcjpy.trade.detail",
"ts":1630994963175,
"tick":{
"id":137005445109,
"ts":1630994963173,
"data":[
{
"id":137005445109359286410323766,
"ts":1630994963173,
"tradeId":102523573486,
"amount":0.006754,
"price":52648.62,
"direction":"buy"
}
]
}
}
トピック
market.$symbol.trade.detail
key | description |
---|---|
req | market.$symbol.trade.detail |
id | クライアントによって生成されたID |
フィールド | データ種類 | 説明 |
ch | string | トピック |
ts | long | タイムスタンプ |
tick | object | |
id | long | 全局成交ID |
ts | long | 最新成交时间 |
- data | object | tickの属性 |
dataの説明
フィールド | データ種類 | 説明 |
---|---|---|
id | integer | 識別ID |
tradeId | integer | 取引ID |
amount | float | 取引量 |
price | float | 価格 |
ts | integer | タイムスタンプ |
direction | string | takerの方向、 'buy' or 'sell' |
マーケット概要
リクエスト送信
{
"req": "market.ethbtc.detail",
"id": "id12"
}
データ受信
{
"rep": "market.ethbtc.detail",
"status": "ok",
"id": "id12",
"tick": {
"amount": 12224.2922,
"open": 9790.52,
"close": 10195.00,
"high": 10300.00,
"ts": 1494496390000,
"id": 1494496390,
"count": 15195,
"low": 9657.00,
"vol": 121906001.754751
}
}
トピック
market.$symbol.detail
key | description |
---|---|
req | market.$symbol.detail" |
id | クライアントによって生成されたID |
受信データ
Field | タイプ | 説明 |
---|---|---|
ch | string | トピック |
ts | long | 更新時間 |
tick | Object | 詳細データ |
tickの構造
Field | タイプ | 説明 |
---|---|---|
id | integer | Unix timestamp |
amount | float | 24Hの取引金額 |
count | integer | 24Hの取引回数 |
open | float | 24Hの始値 |
close | float | 最新価格 |
low | float | 24Hの最低価格 |
high | float | 24Hの最高価格 |
vol | float | 24Hの取引量 |
version | long | バージョン |
Websocket (Private)
概要
API KEYの署名により、顧客の取引情報、資産情報などのデータが購読できます。
署名用リクエスト
{
"action": "req",
"ch": "auth",
"params": {
"authType":"api",
"accessKey": "e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx",
"signatureMethod": "HmacSHA256",
"signatureVersion": "2.1",
"timestamp": "2019-09-01T18:16:16",
"signature": "4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o="
}
}
レスポンス
{
"action": "req",
"code": 200,
"ch": "auth",
"data": {}
}
署名のサンプルコード(golang)
authの結果をシリアライズして、サーバーに送る
func hmac256(base string, key string) string {
h := hmac.New(sha256.New, []byte(key))
h.Write([]byte(base))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
func createAuthJson(accessKey, secretKey string) authJson {
authParams := url.Values{}
utc := time.Now().UTC().Format("2006-01-02T15:04:05")
authParams.Set("accessKey", accessKey)
authParams.Set("signatureMethod", "HmacSHA256")
authParams.Set("signatureVersion", "2.1")
authParams.Set("timestamp", utc)
host := "api-cloud.bittrade.co.jp"
path := "/ws/v2"
s := fmt.Sprintf("GET\n%s\n%s\n%s", host, path, authParams.Encode())
signature := hmac256(s, secretKey)
auth := authJson{
Action: "req",
Ch: "auth",
Params: {
AuthType: "api",
AccessKey: accessKey,
SignatureMethod: "HmacSHA256",
SignatureVersion: "2.1",
Timestamp: utc,
Signature: signature,
},
}
return auth
}
エントリポイント
wss://api-cloud.bittrade.co.jp/ws/v2
制限
・接続及びリクエストを1秒あたり50回に制限されます。この制限を超えると、「リクエストが多すぎます」というエラーメッセージが返されます。
・APIキー毎に、最大10回接続できます。この制限を超えると、「接続が多すぎます」というエラーメッセージが返されます。
・IP毎に確立される接続数が1秒あたり100回に制限されます。この制限を超えると、「リクエストが多すぎます」というエラーメッセージが返されます。
認証ロジック
接続確立された後、署名情報をサーバーに送らなければなりません。認証が通ると、顧客のアカウント・取引データがwebsocket経由で送信されます。
手順
WebSocketの署名は、APIの署名と似ていますが、いくつの違いがあります。
Field | value | 説明 |
---|---|---|
path | /ws/v2 | 固定値 |
action | req | 固定値 |
signatureVersion | 2.1 | 固定値 |
ch | auth | 固定値 |
signatureVersion | HmacSHA256 | 暗号化メソッド |
注: Jsonの中にURLのエンコーディングが不要
トピック一覧
トピック名 | 説明 |
---|---|
orders#${symbol} | 注文データ |
trade.clearing#${symbol}#${mode} | 注文状態変更 |
accounts.update#{mode} | 資産変動 |
注文データ
購読
{
"action": "sub",
"ch": "orders#btcjpy"
}
購読成功のレスポンス
{
"action": "sub",
"code": 200,
"ch": "orders#btcjpy",
"data": {}
}
受信データ
{
"action":"push",
"ch":"orders#btcjpy",
"data":
{
"orderSize":"2.000000000000000000",
"orderCreateTime":1583853365586,
"accountId":992701,
"orderPrice":"77.000000000000000000",
"type":"sell-limit",
"orderId":27163533,
"clientOrderId":"abc123",
"orderSource":"spot-api",
"orderStatus":"submitted",
"symbol":"btcjpy",
"eventType":"creation"
}
}
トピック
orders#${symbol}
パラメータ
Param | Type | Description |
---|---|---|
symbol | string | 取引ペア (ワイルドカード * 使用可) |
受信データ
注文トリガー失敗時
Field | Type | Description |
---|---|---|
eventType | string | イベントタイプ、有効な値:trigger |
symbol | string | 取引ペア |
clientOrderId | string | ユーザー注文番号 |
orderSide | string | 注文方向、実効値:buy,sell |
orderStatus | string | 注文状況、有効な値:rejected |
errCode | int | 注文トリガー失敗エラーコード |
errMessage | string | 注文トリガーに失敗しましたエラーメッセージ |
lastActTime | long | 注文トリガーの失敗時間 |
Update example
{
"action":"push",
"ch":"orders#btcjpy",
"data":
{
"orderSide":"buy",
"lastActTime":1583853365586,
"clientOrderId":"abc123",
"orderStatus":"canceled",
"symbol":"btcjpy",
"eventType":"deletion"
}
}
キャンセル時
Field | Type | Description |
---|---|---|
eventType | string | イベントタイプ、有効な値:delete |
symbol | string | 取引ペア |
clientOrderId | string | ユーザ定義注文ID |
orderSide | string | 注文方向、実効値:buy,sell |
orderStatus | string | 注文状況、有効な値:canceled |
lastActTime | long | 注文キャンセル時間 |
注文作成
{
"action":"push",
"ch":"orders#btcjpy",
"data":
{
"orderSize":"2.000000000000000000",
"orderCreateTime":1583853365586,
"accountId":992701,
"orderPrice":"77.000000000000000000",
"type":"sell-limit",
"orderId":27163533,
"clientOrderId":"abc123",
"orderSource":"spot-api",
"orderStatus":"submitted",
"symbol":"btcjpy",
"eventType":"creation"
}
}
注文レコードの作成
Field | Type | Description |
---|---|---|
eventType | string | イベントタイプ、有効な値:creation |
symbol | string | 取引タイプ |
accountId | long | ユーザ アカウントID |
orderId | long | Order ID |
clientOrderId | string | ユーザーの注文番号(optional) |
orderSource | string | 注文方法 |
orderPrice | string | 注文価格 |
orderSize | string | 注文数量(成行注文には無効) |
orderValue | string | 注文金額(市場価格の買い注文にのみ有効) |
type | string | 注文タイプ |
orderStatus | string | 注文状況、有効な値:submitted |
orderCreateTime | long | 注文作成時間 |
注文状態更新
注文が成約またはキャンセルされたときに通知されます。
注: 順序が依存する場合は、注文データ(orders#${symobl})のトピックを使ってください。
トピック
trade.clearing#${symbol}#${mode}
パラメータ
Param | タイプ | 必須 | 説明 |
---|---|---|---|
symbol | string | TRUE | 取引ペア (ワイルドカード * 使用可) |
mode | int | FALSE | プッシュモード( 0 - 成約時のみ通知 1 - 成約とキャンセル両方プッシュ;デフォルト値:0) |
購読
{
"action": "sub",
"ch": "trade.clearing#trxjpy#1"
}
購読成功時
{
"action": "sub",
"code": 200,
"ch": "trade.clearing#trxjpy#1",
"data": {}
}
受信データ
{
"ch": "trade.clearing#trxjpy#1",
"data": {
"accountId": 5566913,
"aggressor": true,
"eventType": "trade",
"feeCurrency": "trx",
"feeDeduct": "0",
"feeDeductType": "",
"orderCreateTime": 1634275849427,
"orderId": 388370646839430,
"orderPrice": "11.229",
"orderSide": "buy",
"orderSize": "1",
"orderStatus": "filled",
"orderType": "buy-limit",
"source": "web",
"symbol": "trxjpy",
"tradeId": 2516,
"tradePrice": "11.229",
"tradeTime": 1634275849431,
"tradeVolume": "1",
"transactFee": "0.0015"
}
}
約定時のデータフィールド
Field | Type | Description |
---|---|---|
eventType | string | trade |
symbol | string | 取引ペア |
orderId | long | 注文ID |
tradePrice | string | 約定価格 |
tradeVolume | string | 約定量 |
orderSide | string | 取引方向(買・売) |
orderType | string | 注文タイプ |
aggressor | bool | |
tradeId | long | 取引ID |
tradeTime | long | 約定時間(ミリ秒) |
transactFee | string | 取引手数料 |
feeCurrency | string | 取引手数料の通貨 |
feeDeduct | string | 取引手数料割引、手数料の代わりに、htで払うと安くなります |
feeDeductType | string | 取引手数料割引タイプ、有効な値:ht |
accountId | long | アカウントID |
source | string | 注文方法 |
orderPrice | string | 注文価格(成行注文にはこのフィールドがありません) |
orderSize | string | 注文数量(成行買い注文にはこのフィールドがありません) |
orderValue | string | 注文金額(成行買い注文のみ表示される) |
clientOrderId | string | ユーザーが作成した注文番号 |
orderCreateTime | long | 注文作成時間 |
orderStatus | string | 注文状況、有効な値:filled, partial-filled |
キャンセル時のデータ
フィールド | タイプ | 説明 |
---|---|---|
eventType | string | cancellation |
symbol | string | 取引ペア |
orderId | long | 注文ID |
tradePrice | string | 約定価格 |
tradeVolume | string | 約定量 |
orderSide | string | 取引方向(買・売) |
orderType | string | 注文タイプ |
accountId | long | アカウントID |
source | string | 注文方法 |
orderPrice | string | 注文価格(成行注文にはこのフィールドがありません) |
orderSize | string | 注文数量(成行買い注文にはこのフィールドがありません) |
orderValue | string | 注文金額(成行買い注文のみ表示される) |
clientOrderId | string | ユーザーが作成した注文番号 |
orderCreateTime | long | 注文作成時間 |
remainAmt | string | 未成約ボリューム(成行買い注文の場合は未取引金額として定義されます) |
orderStatus | string | 注文ステータス,有効な値:canceled, partial-canceled |
資産変動
購読
{
"action": "sub",
"ch": "accounts.update"
}
購読成功のレスポンス
{
"action": "sub",
"code": 200,
"ch": "accounts.update#0",
"data": {}
}
受信データ
accounts.update#0 の場合
{
"action": "push",
"ch": "accounts.update#0",
"data": {
"accountId": 5566913,
"accountType": "trade",
"available": "0.000051644983883289",
"balance": "0.000051644983883289",
"changeTime": null,
"changeType": null,
"currency": "btc",
"seqNum": 566163
}
}
accounts.update#1 の場合
{
"action": "push",
"ch": "accounts.update#1",
"data": {
"accountId": 5566913,
"accountType": "trade",
"available": "0.001998038941797817",
"balance": "0.001998038941797817",
"changeTime": null,
"changeType": null,
"currency": "bch",
"seqNum": 83
}
}
トピック
accounts.update#{mode}
mode | 説明 |
---|---|
0 | 残高が変動する時のみ通知される |
1 | 使える残高に変更があったとき、別々のデータを受信されます。 |
2 | 使える残高に変更があったとき、同じデータを受信されます。 |
フィールド | タイプ | 説明 |
---|---|---|
currency | string | 通貨 |
accountId | long | アカウントID |
balance | string | 残高(アカウントの残高が変更された場合のみプッシュ) |
available | string | 利用可能残高(利用可能な残高が変更された場合のみプッシュ) |
changeType | string | 変更タイプ,有効値:order-place(注文作成),order-match(注文成約),order-refund(注文取引の払い戻し),order-cancel(注文のキャンセル), deposit (入金), withdraw (出金),other(その他の資産の変更) |
accountType | string | アカウントタイプ,有効値:trade, loan, interest |
changeTime | long | 変更時間,unix time in millisecond |
seqNum | long | アカウント変更のシリアル番号 |
エラーコード
コード | エラー情報 | 説明 |
---|---|---|
200 | 成功 | 正常に処理された |
100 | TimeOut Close | タイムアウトのためにクローズ |
400 | Bad Request | パラメータエラーなど |
404 | Not Found | サービスが見つかりません |
429 | Too Many Requests | 単一サーバーの最大接続数を超えているか、単一IPの最大接続数を超えています。 |
500 | システム異常 | システムエラー |
2000 | invalid.ip | 無効なIP |
2001 | nvalid.json | 無効なリクエストjson |
2001 | invalid.authType | 間違った署名方法 |
2001 | invalid.action | 無効なアクション |
2001 | invalid.symbol | 無効な取引ペア |
2001 | invalid.ch | 無効な購読 |
2001 | invalid.exchange | 無効な取引所コード |
2001 | missing.param.auth | 署名時、パラメータが足りません。 |
2002 | invalid.auth.state | 認証に失敗しました |
2002 | auth.fail | APIキーにバインドされたIPエラーを含め、署名の検証に失敗しました |
2003 | query.account.list.error | アカウントリストのクエリに失敗しました |
4000 | too.many.request | クライアントアップリンク要求の頻度制限(単一インスタンスで1秒あたり50回) |
4000 | too.many.connection | 同じAPIキーとの接続数が、サーバーの単一インスタンスの制限を超えています(単一インスタンスは最大10個まで接続できます) |