├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── README.md ├── README_JP.md ├── assets.md ├── errors.md ├── errors_JP.md ├── networks.md ├── package-lock.json ├── package.json ├── pairs.md ├── private-stream.md ├── private-stream_JP.md ├── public-api.md ├── public-api_JP.md ├── public-stream.md ├── public-stream_JP.md ├── rest-api.md └── rest-api_JP.md /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Issue tracker is **ONLY** used for reporting bugs. 2 | 3 | 4 | 5 | ## Expected Behavior 6 | 7 | 8 | ## Current Behavior 9 | 10 | 11 | ## Steps to Reproduce 12 | 13 | 14 | 1. 15 | 2. 16 | 3. 17 | 18 | ## Context (Environment) 19 | 20 | 21 | 22 | 23 | 24 | ## Detailed Description 25 | 26 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | We accept pull-requests for Bug Fixes **ONLY**. 2 | 3 | 4 | 5 | ## Description 6 | 7 | 8 | ## Related Issue 9 | 10 | 11 | 12 | 13 | 14 | ## How Has This Been Tested? 15 | 16 | 17 | 18 | 19 | ## Screenshots (if appropriate): 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | *.swp 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for Bitbank's API (2025-05-13) 2 | 3 | ## 2025-05-13 4 | * Updated docs 5 | * `pairs.md` 6 | * `assets.md` 7 | 8 | --- 9 | ## 2025-04-17 10 | * Updated docs 11 | * `rest-api.md` 12 | * `rest-api_JP.md` 13 | 14 | --- 15 | ## 2025-04-01 16 | * Added new docs 17 | * `private-stream.md` 18 | * `private-stream_JP.md` 19 | * Updated docs 20 | * `rest-api.md` 21 | * `rest-api_JP.md` 22 | 23 | --- 24 | ## 2025-03-04 25 | * Updated docs 26 | * `pairs.md` 27 | * `assets.md` 28 | 29 | --- 30 | ## 2025-02-03 31 | * Updated docs 32 | * `pairs.md` 33 | * `networks.md` 34 | * `assets.md` 35 | 36 | --- 37 | ## 2025-01-16 38 | * Updated docs 39 | * `errors.md` 40 | * `errors_JP.md` 41 | 42 | --- 43 | ## 2024-12-24 44 | * Updated docs 45 | * `public-api.md` 46 | * `public-api_JP.md` 47 | * `public-stream.md` 48 | * `public-stream_JP.md` 49 | * `rest-api.md` 50 | * `rest-api_JP.md` 51 | 52 | --- 53 | ## 2024-12-11 54 | * Added new pairs to 55 | * `pairs.md` 56 | * `assets.md` 57 | 58 | --- 59 | ## 2024-11-21 60 | * Added new pairs to 61 | * `pairs.md` 62 | * `assets.md` 63 | 64 | --- 65 | ## 2024-11-11 66 | * Updated docs 67 | * `rest-api.md` 68 | * `rest-api_JP.md` 69 | * `errors.md` 70 | * `errors_JP.md` 71 | 72 | --- 73 | ## 2024-09-05 74 | * Added new pairs to 75 | * `pairs.md` 76 | * `assets.md` 77 | 78 | ## 2024-08-28 79 | * Updated docs 80 | * `assets.md` 81 | * `public-api.md` 82 | * `public-api_JP.md` 83 | * `public-stream.md` 84 | * `public-stream_JP.md` 85 | * `rest-api.md` 86 | * `rest-api_JP.md` 87 | 88 | ## 2024-08-22 89 | * Updated error codes 90 | * `errors.md` 91 | * `errors_JP.md` 92 | * Updated private REST API docs 93 | * `rest-api.md` 94 | * `rest-api_JP.md` 95 | 96 | ## 2024-05-08 97 | * Updated private REST API docs 98 | * `rest-api.md` 99 | * `rest-api_JP.md` 100 | 101 | ## 2024-05-02 102 | * Updated private REST API docs 103 | * `rest-api.md` 104 | * `rest-api_JP.md` 105 | 106 | ## 2024-04-23 107 | * Updated error codes 108 | * `errors.md` 109 | * `errors_JP.md` 110 | * Updated private REST API docs 111 | * `rest-api.md` 112 | * `rest-api_JP.md` 113 | 114 | --- 115 | ## 2024-02-08 116 | * Added new pairs to 117 | * `pairs.md` 118 | * `assets.md` 119 | 120 | --- 121 | ## 2023-12-14 122 | * Added new pairs to 123 | * `pairs.md` 124 | * `assets.md` 125 | 126 | --- 127 | ## 2023-11-17 128 | * Add new endpoint, room `circuit_break_info` 129 | * `public-api.md` 130 | * `public-api_JP.md` 131 | * `public-stream.md` 132 | * `public-stream_JP.md` 133 | * Cross buy/sell condition can occur 134 | * `public-api.md` 135 | * `public-api_JP.md` 136 | * `public-stream.md` 137 | * `public-stream_JP.md` 138 | * Market order and post only option are restricted in `CIRCUIT_BREAK` mode 139 | * `rest-api.md` 140 | * `rest-api_JP.md` 141 | * Add over/under responses to depth API 142 | * `public-api.md` 143 | * `public-api_JP.md` 144 | * `public-stream.md` 145 | * `public-stream_JP.md` 146 | 147 | --- 148 | ## 2023-11-08 149 | * Added new docs 150 | * `networks.md` 151 | * Added network fields to 152 | * `rest-api.md`. 153 | * `rest-api_JP.md`. 154 | 155 | --- 156 | ## 2023-10-23 157 | * Added new pairs to 158 | * `pairs.md` 159 | * `assets.md` 160 | * Updated error code. 161 | * `errors.md`. 162 | * Fixed curl sample code of withdrawal request. 163 | * `rest-api.md` 164 | * `rest-api_JP.md` 165 | 166 | --- 167 | ## 2023-10-03 168 | * Added address to GET /user/deposit_history response 169 | * `rest-api.md` 170 | * `rest-api_JP.md` 171 | 172 | --- 173 | ## 2023-09-07 174 | * Added new pairs to 175 | * `pairs.md` 176 | * `assets.md` 177 | 178 | --- 179 | ## 2023-07-14 180 | * Updated error codes. 181 | * `errors.md`. 182 | * `errors_JP.md`. 183 | 184 | --- 185 | ## 2023-06-20 186 | * Clarified about the count limitation of order_ids of cancel_orders. 187 | * `rest-api.md` 188 | * `rest-api_JP.md` 189 | 190 | --- 191 | ## 2023-06-15 192 | * Added new pairs to 193 | * `pairs.md` 194 | * `assets.md` 195 | 196 | --- 197 | ## 2023-06-09 198 | * Added error code 50038 to `errors.md` and `errors_JP.md` 199 | 200 | --- 201 | ## 2023-05-09 202 | * Add a new caveat about getting order's info to 203 | * `rest-api.md` 204 | * `rest-api_JP.md` 205 | 206 | --- 207 | ## 2023-04-27 208 | * Fixed discrepancies between docs and reality 209 | * `public-api.md` 210 | * `public-api_JP.md` 211 | * `rest-api.md` 212 | * `rest-api_JP.md` 213 | 214 | --- 215 | ## 2023-04-20 216 | * Added new pairs to 217 | * `pairs.md` 218 | * `assets.md` 219 | 220 | --- 221 | ## 2023-04-10 222 | * New Pair statuses: GET /spot/pairs in `rest-api.md` and `rest-api_JP.md` 223 | * stop_market_order 224 | * stop_stop_order 225 | * stop_stop_limit_order 226 | * stop_buy_order 227 | * stop_sell_order 228 | 229 | --- 230 | ## 2023-04-03 231 | * Added new pairs to 232 | * `pairs.md` 233 | * `assets.md` 234 | 235 | --- 236 | ## 2023-03-13 237 | * Added an error code 60017 to `errors.md` and `errors_JP.md` 238 | 239 | --- 240 | ## 2023-03-08 241 | * Added new pairs to 242 | * `pairs.md` 243 | * `assets.md` 244 | 245 | --- 246 | ## 2023-02-08 247 | * Fixed type of tx_id in deposit history response 248 | * `rest-api.md` 249 | * `rest-api_JP.md` 250 | 251 | --- 252 | ## 2023-02-03 253 | * Some modifications to `rest-api.md` and `rest-api_JP.md`: 254 | * BREAKING: the type of `amount` and `fee` property in the response of withdrawal request has changed from `number` to `string`. 255 | * Fixed withdrawal request response. 256 | 257 | --- 258 | ## 2023-02-01 259 | * Some modifications to `rest-api.md` and `rest-api_JP.md`: 260 | * Added deposit and withdrawal history API 261 | * Fixed a typo, a wrong description, and aligned toc level. 262 | 263 | --- 264 | ## 2023-01-25 265 | * Added new pairs to 266 | * `pairs.md` 267 | * `assets.md` 268 | 269 | --- 270 | ## 2023-01-11 271 | * Added new pairs to 272 | * `pairs.md` 273 | * `assets.md` 274 | 275 | --- 276 | ## 2022-12-15 277 | * Added description about REST API rate limit 278 | * Added sequenceId, applying instruction and caveats about depth to Public Stream 279 | 280 | --- 281 | ## 2022-12-07 282 | * Added new pairs to 283 | * `pairs.md` 284 | * `assets.md` 285 | 286 | --- 287 | ## 2022-12-01 288 | * Added an error code 50037 to `errors.md` and `errors_JP.md` 289 | 290 | --- 291 | ## 2022-11-10 292 | * Auto disconnection is abolished 293 | 294 | --- 295 | ## 2022-11-09 296 | * Added new pairs to 297 | * `pairs.md` 298 | * `assets.md` 299 | 300 | --- 301 | ## 2022-10-03 302 | * Added new pairs to 303 | * `pairs.md` 304 | * `assets.md` 305 | 306 | --- 307 | ## 2022-09-29 308 | * Added new error codes to 309 | * `errors.md`. 310 | * `errors_JP.md`. 311 | 312 | --- 313 | ## 2022-09-26 314 | * Added new pairs to 315 | * `pairs.md` 316 | * `assets.md` 317 | 318 | --- 319 | ## 2022-09-15 320 | * Termination of Crypto Pairs with BTC, excluding BTC/JPY 321 | 322 | --- 323 | ## 2022-08-08 324 | * Socket.io version up from v2 to v4 325 | 326 | --- 327 | ## 2022-08-03 328 | * Added new pairs to 329 | * `pairs.md` 330 | * `assets.md` 331 | 332 | --- 333 | ## 2022-06-21 334 | * Added new pairs to 335 | * `pairs.md` 336 | * `assets.md` 337 | 338 | --- 339 | ## 2022-04-26 340 | * Added new docs 341 | * `pairs.md` 342 | * `assets.md` 343 | * Fixed docs according to the above 344 | * `public-api.md`. 345 | * `public-api_JP.md`. 346 | * `public-stream.md`. 347 | * `public-stream_JP.md`. 348 | * `rest-api.md`. 349 | * `rest-api_JP.md`. 350 | 351 | --- 352 | ## 2022-04-26 353 | * Added new pairs to 354 | * `public-api.md`. 355 | * `public-api_JP.md`. 356 | * `public-stream.md`. 357 | * `public-stream_JP.md`. 358 | * `rest-api.md`. 359 | * `rest-api_JP.md`. 360 | 361 | --- 362 | ## 2022-03-29 363 | * Added new pairs to 364 | * `errors.md`. 365 | * `errors_JP.md`. 366 | 367 | --- 368 | ## 2022-03-14 369 | * Added new pairs to 370 | * `public-api.md`. 371 | * `public-api_JP.md`. 372 | * `public-stream.md`. 373 | * `public-stream_JP.md`. 374 | * `rest-api.md`. 375 | * `rest-api_JP.md`. 376 | 377 | --- 378 | ## 2022-02-07 379 | * Added some error codes to `errors.md` and `errors_JP.md`. 380 | * Fixed a typo in `rest-api_JP.md`. 381 | 382 | --- 383 | ## 2022-01-25 384 | * Added new pairs to 385 | * `public-api.md`. 386 | * `public-api_JP.md`. 387 | * `public-stream.md`. 388 | * `public-stream_JP.md`. 389 | * `rest-api.md`. 390 | * `rest-api_JP.md`. 391 | 392 | --- 393 | ## 2021-12-03 394 | * Added new pairs to 395 | * `public-api.md`. 396 | * `public-api_JP.md`. 397 | * `public-stream.md`. 398 | * `public-stream_JP.md`. 399 | * `rest-api.md`. 400 | * `rest-api_JP.md`. 401 | 402 | --- 403 | ## 2021-10-05 404 | * Added new pairs to 405 | * `public-api.md`. 406 | * `public-api_JP.md`. 407 | * `public-stream.md`. 408 | * `public-stream_JP.md`. 409 | * `rest-api.md`. 410 | * `rest-api_JP.md`. 411 | 412 | --- 413 | ## 2021-09-27 414 | * Added parameters and fields about Stop order to 415 | * `rest-api.md`. 416 | * `rest-api_JP.md`. 417 | * Added some Stop order error codes to `errors.md` and `errors_JP.md` 418 | 419 | --- 420 | ## 2021-07-13 421 | * Added new pairs to 422 | * `public-api.md`. 423 | * `public-api_JP.md`. 424 | 425 | --- 426 | ## 2021-07-01 427 | * Added new pairs to 428 | * `public-api.md`. 429 | * `public-api_JP.md`. 430 | * `public-stream.md`. 431 | * `public-stream_JP.md`. 432 | * `rest-api.md`. 433 | * `rest-api_JP.md`. 434 | 435 | --- 436 | ## 2021-05-21 437 | * Added a field to public-api and public-stream 438 | * open (response only) 439 | 440 | --- 441 | ## 2021-04-02 442 | * fix style 443 | 444 | --- 445 | ## 2021-04-01 446 | * Added some fields to rest-api 447 | * post_only (request and response) 448 | * expire_at (response only) 449 | * Added some new error codes to `errors.md` and `errors_JP.md` 450 | 451 | --- 452 | ## 2021-03-17 453 | * Added new pairs to 454 | * `public-api.md`. 455 | * `public-api_JP.md`. 456 | * `public-stream.md`. 457 | * `public-stream_JP.md`. 458 | * `rest-api.md`. 459 | * `rest-api_JP.md`. 460 | 461 | --- 462 | ## 2021-01-27 463 | * Added new pairs to 464 | * `public-api.md`. 465 | * `public-api_JP.md`. 466 | * `public-stream.md`. 467 | * `public-stream_JP.md`. 468 | * `rest-api.md`. 469 | * `rest-api_JP.md`. 470 | 471 | --- 472 | ## 2020-12-25 473 | * Added missing 1month for candle-type of candlestick to `public-api.md` and `public-api_JP.md` 474 | 475 | --- 476 | ## 2020-12-23 477 | * Added `count` limitation of "Fetch trade history" endpoint to `rest-api.md` and `rest-api_JP.md` ([#19](https://github.com/bitbankinc/bitbank-api-docs/issues/19)) 478 | 479 | --- 480 | ## 2020-11-20 481 | * Added some missing error codes to `errors.md` 482 | 483 | --- 484 | ## 2020-09-16 485 | * Added new pairs to 486 | * `public-api.md`. 487 | * `public-api_JP.md`. 488 | * `public-stream.md`. 489 | * `public-stream_JP.md`. 490 | * `rest-api.md`. 491 | * `rest-api_JP.md`. 492 | 493 | --- 494 | ## 2020-05-24 495 | * Added new pairs to 496 | * `public-api.md`. 497 | * `public-api_JP.md`. 498 | * `public-stream.md`. 499 | * `public-stream_JP.md`. 500 | * `rest-api.md`. 501 | * `rest-api_JP.md`. 502 | 503 | --- 504 | ## 2020-02-17 505 | * Fix ([#10](https://github.com/bitbankinc/bitbank-api-docs/issues/10)) 506 | * Added candlestick params additional info to `public-api.md`. 507 | 508 | --- 509 | ## 2019-10-24 510 | * Remove `realtime-api.md` 511 | * Realtime API, PubNub was abolished. 512 | * Use public-stream instead. 513 | 514 | --- 515 | ## 2019-10-18 516 | * Added new error codes to `errors.md`. 517 | ### Rest API 518 | * New order status: REJECTED 519 | * The conditions to become REJECTED are as follows. 520 | * Market order (FOK) does not match the conditions and not fulfilled. 521 | * Limit order quantity is excessive for the order book. 522 | * Changes to order behavior 523 | * The order execution condition for a market order is changed to FOK (Fill or Kill). 524 | * FOK (Fill or Kill) is an order execution condition that rejects (cancels) order if all ordered quantities are not filled. 525 | * Order may become invalid if an excessive quantity is placed against the order book. 526 | * New Exchange status: GET /spot/status 527 | * HALT 528 | * All order and cancel request suspended. 529 | * New Pair statuses: GET /spot/pairs 530 | * is_enabled 531 | * stop_order 532 | * stop_order_and_cancel 533 | 534 | --- 535 | ## 2019-10-03 536 | * Added wscat sample code to `public-stream.md`. 537 | 538 | --- 539 | ## 2019-10-02 540 | * Added curl sample code to `rest-api.md`. 541 | 542 | --- 543 | ## 2019-10-01 544 | * Added Realtime API documentation to `realtime-api.md`. 545 | 546 | --- 547 | ## 2019-09-27 548 | * Added first version. 549 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Official Documentation for the bitbank.cc APIs and Streams. 2 | 3 | [日本語](README_JP.md) 4 | 5 | * Official Announcements regarding system maintenance, api update, etc. will be reported here: **[https://blog.bitbank.cc/tag/service](https://blog.bitbank.cc/tag/service)** 6 | 7 | Name | Description 8 | ------------ | ------------ 9 | [rest-api.md](./rest-api.md) | Details on the Private REST API. 10 | [public-api.md](./public-api.md) | Details on the Public API. 11 | [public-stream.md](./public-stream.md) | Details on available real time streams api. 12 | [private-stream.md](./private-stream.md) | Details on available real time private streams api. 13 | [errors.md](./errors.md) | Descriptions of possible error messages from the Private REST API. 14 | 15 | **Issue Tracker:** 16 | 17 | Bug reports are welcome! You can use the issue tracker to report bugs and request features on [https://github.com/bitbankinc/bitbank-api-docs/issues](https://github.com/bitbankinc/bitbank-api-docs/issues). 18 | 19 | Pull request welcome! You can use our pull request to improve our documents [https://github.com/bitbankinc/bitbank-api-docs/pulls](https://github.com/bitbankinc/bitbank-api-docs/pulls). 20 | -------------------------------------------------------------------------------- /README_JP.md: -------------------------------------------------------------------------------- 1 | # bitbank.cc 公式APIドキュメント 2 | 3 | [English](README.md) 4 | 5 | * 公式なアナウンスやメンテナンスのお知らせについては、**[https://blog.bitbank.cc/tag/service](https://blog.bitbank.cc/tag/service)** を確認してください。 6 | 7 | ドキュメント名 | 内容 8 | ------------ | ------------ 9 | [rest-api_JP.md](./rest-api_JP.md) | 新規注文やそのキャンセル、資産残高などを確認できます。 10 | [public-api_JP.md](./public-api_JP.md) | 公開されている約定履歴、板情報などを参照できます。 11 | [public-stream_JP.md](./public-stream_JP.md) | リアルタイムデータ配信API 12 | [private-stream_JP.md](./private-stream_JP.md) | ユーザー情報をリアルタイムで取得できるAPI 13 | [errors_JP.md](./errors_JP.md) | エラーコードの一覧 14 | 15 | _APIに関する改善、機能追加の要望、ドキュメント記載内容の誤り、サンプルコードのバグなどに関する内容は本リポジトリのIssueからご報告ください。_ 16 | [https://github.com/bitbankinc/bitbank-api-docs/issues](https://github.com/bitbankinc/bitbank-api-docs/issues) 17 | 18 | _具体的なドキュメント記載内容の修正、記載の追加がある場合、Pull Requestも受け付けております。_ 19 | [https://github.com/bitbankinc/bitbank-api-docs/pulls](https://github.com/bitbankinc/bitbank-api-docs/pulls). -------------------------------------------------------------------------------- /assets.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [assets](#assets) 6 | 7 | 8 | 9 | # assets 10 | 11 | The following is the list of asset. 12 | 13 | Symbol | Coin name 14 | ------------ | ------------ 15 | jpy | japanese yen 16 | btc | bitcoin 17 | xrp | ripple 18 | ltc | litecoin 19 | eth | ethereum 20 | mona | monacoin 21 | bcc | bitcoin cash 22 | xlm | stellar 23 | qtum | qtum 24 | bat | basic attention token 25 | omg | omg network 26 | xym | symbol 27 | link | chainlink 28 | mkr | maker 29 | boba | boba network 30 | enj | enjin coin 31 | matic | polygon 32 | dot | polkadot 33 | doge | dogecoin 34 | astr | astar network 35 | ada | cardano 36 | avax | avalanche 37 | axs | axie infinity 38 | flr | flare 39 | sand | the sandbox 40 | gala | gala 41 | ape | ape coin 42 | chz | chiliz 43 | oas | oasys 44 | mana | decentraland 45 | grt | the graph 46 | rndr | render 47 | bnb | build and build 48 | dai | multi-collateral dai 49 | op | optimism 50 | arb | arbitrum 51 | klay | klaytn 52 | imx | immutable x 53 | mask | mask network 54 | pol | polygon ecosystem token 55 | sol | solana 56 | cyber | cyber connect 57 | render | render 58 | trx | tron 59 | lpt | livepeer 60 | atom | cosmos 61 | -------------------------------------------------------------------------------- /errors.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [Error codes for Bitbank](#error-codes-for-bitbank) 6 | - [SYSTEM_ERROR](#system_error) 7 | - [AUTHENTICATION_ERROR](#authentication_error) 8 | - [REQUIRED_PARAMETER_ERROR](#required_parameter_error) 9 | - [INVALID_PARAMETER_ERROR](#invalid_parameter_error) 10 | - [DATA_ERROR](#data_error) 11 | - [VALUE_ERROR](#value_error) 12 | - [STOP_UPDATE_REQUEST_SYSTEM_STATUS](#stop_update_request_system_status) 13 | 14 | 15 | 16 | [日本語](errors_JP.md) 17 | 18 | # Error codes for Bitbank 19 | 20 | Here is the format of error JSON payload: 21 | 22 | ```json 23 | { 24 | "success": 0, 25 | "data": { 26 | "code": 20003 27 | } 28 | } 29 | ``` 30 | 31 | The following is the list of Bitbank's error codes. 32 | 33 | ## SYSTEM_ERROR 34 | 35 | - `10000` Url not found. 36 | - `10001` System error. 37 | - `10002` Malformed request. 38 | - `10003` System error. 39 | - `10005` Timeout waiting for response. 40 | - `10007` System maintenance. 41 | - `10008` Server is busy. Retry later. 42 | - `10009` You sent requests too frequently. Retry later with decreased requests. 43 | 44 | ## AUTHENTICATION_ERROR 45 | 46 | - `20001` Authentication failed api authorization. 47 | - `20002` Invalid ACCESS-KEY. 48 | - `20003` ACCESS-KEY not found. 49 | - `20004` ACCESS-NONCE not found. 50 | - `20005` Invalid ACCESS-SIGNATURE. 51 | - `20011` MFA failed. 52 | - `20014` SMS verification failed. 53 | - `20018` Please login. (This happens when you request API without `/v1/`.) 54 | - `20023` Missing OTP code. 55 | - `20024` Missing SMS code. 56 | - `20025` Missing OTP and SMS code. 57 | - `20026` MFA is temporarily locked because too many failures. Please retry after 60 seconds. 58 | - `20033` ACCESS-REQUEST-TIME not found. 59 | - `20034` Invalid time of ACCESS-REQUEST-TIME. 60 | - `20035` No request was sent within ACCESS-TIME-WINDOW. 61 | - `20036` ACCESS-REQUEST-TIME and ACCESS-NONCE not found. 62 | - `20037` Invalid ACCESS-REQUEST-TIME. 63 | - `20038` Invalid ACCESS-TIME-WINDOW. 64 | - `20039` Invalid ACCESS-NONCE. 65 | 66 | ## REQUIRED_PARAMETER_ERROR 67 | 68 | - `30001` Missing order quantity. 69 | - `30006` Missing order id. 70 | - `30007` Missing order id array. 71 | - `30009` Missing asset. 72 | - `30012` Missing order price. 73 | - `30013` Missing side. 74 | - `30015` Missing order type. 75 | - `30016` Missing asset. 76 | - `30019` Missing uuid. 77 | - `30039` Missing withdraw amount. 78 | - `30101` Missing trigger price. 79 | - `30103` Missing withdrawal type. 80 | - `30104` Missing withdrawal name. 81 | - `30105` Missing VASP. 82 | - `30106` Missing beneficiary type. 83 | - `30107` Missing beneficiary last name. 84 | - `30108` Missing beneficiary first name. 85 | - `30109` Missing beneficiary last kana. 86 | - `30110` Missing beneficiary first kana. 87 | - `30111` Missing beneficiary company name. 88 | - `30112` Missing beneficiary company kana. 89 | - `30113` Missing beneficiary company type. 90 | - `30114` Missing beneficiary company type position. 91 | - `30115` Missing uploaded documents. 92 | - `30116` Missing withdrawal purpose. 93 | - `30117` Missing beneficiary country. 94 | - `30118` Missing beneficiary zip code. 95 | - `30119` Missing beneficiary prefecture. 96 | - `30120` Missing beneficiary city. 97 | - `30121` Missing beneficiary address. 98 | - `30122` Missing beneficiary building. 99 | - `30123` Missing extraction request category. 100 | 101 | ## INVALID_PARAMETER_ERROR 102 | 103 | - `40001` Invalid order quantity. 104 | - `40006` Invalid count. 105 | - `40007` Invalid end param. 106 | - `40008` Invalid end_id. 107 | - `40009` Invalid from_id. 108 | - `40013` Invalid order id. 109 | - `40014` Invalid order id array. 110 | - `40015` Too many orders are specified. 111 | - `40017` Invalid asset. 112 | - `40020` Invalid order price. 113 | - `40021` Invalid order side. 114 | - `40022` Invalid trading start time. 115 | - `40024` Invalid order type. 116 | - `40025` Invalid asset. 117 | - `40028` Invalid uuid. 118 | - `40048` Invalid withdraw amount. 119 | - `40112` Invalid trigger price. 120 | - `40113` Invalid post_only. 121 | - `40114` post_only can not be specified with such order type. 122 | - `40116` Invalid withdrawal type. 123 | - `40117` Invalid withdrawal name. 124 | - `40118` Invalid VASP. 125 | - `40119` Invalid beneficiary type. 126 | - `40120` Invalid beneficiary last name. 127 | - `40121` Invalid beneficiary first name. 128 | - `40122` Invalid beneficiary last kana. 129 | - `40123` Invalid beneficiary first kana. 130 | - `40124` Invalid beneficiary company name. 131 | - `40125` Invalid beneficiary company kana. 132 | - `40126` Invalid beneficiary company type. 133 | - `40127` Invalid beneficiary company type position. 134 | - `40152` Invalid originator label. 135 | - `40153` Invalid originator last name. 136 | - `40154` Invalid originator first name. 137 | - `40155` Invalid originator company name. 138 | - `40156` Invalid originator prefecture. 139 | - `40157` Invalid originator city. 140 | - `40158` Invalid originator address. 141 | - `40159` Invalid originator building. 142 | - `40160` Invalid originator substantial controller name. 143 | - `40163` Invalid beneficiary substantial controller name. 144 | - `40164` Invalid position side. 145 | - `40165` Can not be margin trading with such pair. 146 | - `40200` Stop open orders cannot be accepted. 147 | 148 | ## DATA_ERROR 149 | 150 | - `50003` Account is restricted. 151 | - `50004` Account is provisional. 152 | - `50005` Account is blocked. 153 | - `50006` Account is blocked. 154 | - `50008` Identity verification is not finished. 155 | - `50009` Order not found. 156 | - `50010` Order can not be canceled. 157 | - `50011` Api not found. 158 | - `50026` Order has already been canceled. 159 | - `50027` Order has already been executed. 160 | - `50033` Withdrawals to this address require additional entries. 161 | - `50034` VASP not found. 162 | - `50035` Company information is not registerd. 163 | - `50037` We are temporarily restricting withdrawals while we verify your last deposit. Please try again in a few minutes. 164 | - `50038` Cannot withdraw to chosen VASP service. 165 | - `50043` Originator already registered. 166 | - `50044` Originator not found. 167 | - `50045` Deposit not found. 168 | - `50046` Cannot edit beneficiary under review. 169 | - `50047` Cannot edit disabled beneficiary. 170 | - `50048` Cannot withdraw to beneficiary under review. 171 | - `50049` Beneficiary requires additional entries. 172 | - `50050` Cannot withdraw to chosen beneficiary. 173 | - `50051` Cannot confirm deposit with originator under review. 174 | - `50052` Originator requires additional entries. 175 | - `50053` Cannot edit originator under review. 176 | - `50054` Cannot withdraw because the information registration for unreflected deposits has not been completed. 177 | - `50058` Margin trading review has not been completed. 178 | - `50059` Temporarily restricting new margin orders. Please try your request again after a while. 179 | - `50060` Temporarily restricting new margin orders. Please try your request again after a while. 180 | - `50061` Exceeds available balance for open order. 181 | - `50062` Exceeds total margin position. 182 | - `50070` Withdrawals in JPY are not available. 183 | - `50071` Withdrawals in CC are not available. 184 | - `50072` Buy orders cannot be used in spot transactions. 185 | - `50073` Sell orders cannot be used in spot transactions. 186 | - `50078` Open orders cannot be used in margin trading. 187 | - `50079` Close orders cannot be used in margin trading. 188 | - `50080` Open orders cannot be used in margin trading. 189 | - `50081` Close orders cannot be used in margin trading. 190 | - `50083` Withdrawals can not be used due to realized loss. 191 | 192 | ## VALUE_ERROR 193 | 194 | - `60001` Insufficient amount. 195 | - `60002` Market buy order quantity has exceeded the upper limit. 196 | - `60003` Order quantity has exceeded the limit. 197 | - `60004` Order quantity has exceeded the lower threshold. 198 | - `60005` Order price has exceeded the upper limit. 199 | - `60006` Order price has exceeded the lower limit. 200 | - `60011` Too many Simultaneous orders, current limit is 30. 201 | - `60016` Trigger price has exceeded the upper limit. 202 | - `60017` Withdrawal amount has exceeded the upper limit. 203 | - `60018` Trigger price to trigger immediately cannot be specified. 204 | - `60019` The side of a TakeProfit or StopLoss order must be in the close direction. 205 | 206 | ## STOP_UPDATE_REQUEST_SYSTEM_STATUS 207 | 208 | - `70001` System error. 209 | - `70002` System error. 210 | - `70003` System error. 211 | - `70004` Order is restricted during suspension of transactions. 212 | - `70005` Buy ​​order has been temporarily restricted. 213 | - `70006` Sell ​​order has been temporarily restricted. 214 | - `70009` Market order has been temporarily restricted. Please use limit order instead. 215 | - `70010` Minimum Order Quantity is increased temporarily. 216 | - `70011` System is busy. Please try again. 217 | - `70012` System error. 218 | - `70013` Order and cancel has been temporarily restricted. 219 | - `70014` Withdraw and cancel request has been temporarily restricted. 220 | - `70015` Lending and cancel request has been temporarily restricted. 221 | - `70016` Lending and cancel request has been restricted. 222 | - `70017` Orders on pair have been suspended. 223 | - `70018` Order and cancel on pair have been suspended. 224 | - `70019` Order cancel request is in process. 225 | - `70020` Market order has been temporarily restricted. 226 | - `70021` Limit order price is over the threshold. 227 | - `70022` Stop limit order has been temporarily restricted. 228 | - `70023` Stop order has been temporarily restricted. 229 | - `70024` Long open order has been temporarily restricted. 230 | - `70025` Short open order has been temporarily restricted. 231 | - `70026` Order has been temporarily restricted. 232 | -------------------------------------------------------------------------------- /errors_JP.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [エラーコード一覧](#%E3%82%A8%E3%83%A9%E3%83%BC%E3%82%B3%E3%83%BC%E3%83%89%E4%B8%80%E8%A6%A7) 6 | - [システムエラー/予期せぬエラー](#%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E3%82%A8%E3%83%A9%E3%83%BC%E4%BA%88%E6%9C%9F%E3%81%9B%E3%81%AC%E3%82%A8%E3%83%A9%E3%83%BC) 7 | - [認証エラー](#%E8%AA%8D%E8%A8%BC%E3%82%A8%E3%83%A9%E3%83%BC) 8 | - [必須パラメータバリデーションエラー](#%E5%BF%85%E9%A0%88%E3%83%91%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E3%83%90%E3%83%AA%E3%83%87%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%A8%E3%83%A9%E3%83%BC) 9 | - [バリデーションエラー](#%E3%83%90%E3%83%AA%E3%83%87%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%A8%E3%83%A9%E3%83%BC) 10 | - [DBに問い合わせた結果データ異常](#db%E3%81%AB%E5%95%8F%E3%81%84%E5%90%88%E3%82%8F%E3%81%9B%E3%81%9F%E7%B5%90%E6%9E%9C%E3%83%87%E3%83%BC%E3%82%BF%E7%95%B0%E5%B8%B8) 11 | - [値が不正](#%E5%80%A4%E3%81%8C%E4%B8%8D%E6%AD%A3) 12 | - [システムステータスによりリクエスト停止状態](#%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%81%AB%E3%82%88%E3%82%8A%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E5%81%9C%E6%AD%A2%E7%8A%B6%E6%85%8B) 13 | 14 | 15 | 16 | [English](errors.md) 17 | 18 | # エラーコード一覧 19 | 20 | プライベートAPIでエラーが起きた場合は下記のようなレスポンスが返ります。 21 | 22 | ```json 23 | { 24 | "success": 0, 25 | "data": { 26 | "code": 20003 27 | } 28 | } 29 | ``` 30 | 31 | エラーコード詳細は以下の通りです。 32 | 33 | ## システムエラー/予期せぬエラー 34 | 35 | - 10000 URLが存在しません 36 | - 10001 システムエラーが発生しました。サポートにお問い合わせ下さい 37 | - 10002 不正なJSON形式です。送信内容をご確認下さい 38 | - 10003 システムエラーが発生しました。サポートにお問い合わせ下さい 39 | - 10005 タイムアウトエラーが発生しました。しばらく間をおいて再度実行して下さい 40 | - 10007 メンテナンスのため一時サービスを停止しております。 今しばらくお待ちください。 41 | - 10008 ただいまサーバが大変混み合っています。時間をおいてから再度リクエストしてください。 42 | - 10009 アクセス頻度が高すぎます。時間をおいてから再度リクエストしてください。 43 | 44 | ## 認証エラー 45 | 46 | - 20001 API認証に失敗しました 47 | - 20002 ACCESS-KEYの値が不正です 48 | - 20003 ACCESS-KEYが存在しません 49 | - 20004 ACCESS-NONCEが存在しません 50 | - 20005 ACCESS-SIGNATUREが存在しません 51 | - 20011 2段階認証に失敗しました 52 | - 20014 SMS認証に失敗しました 53 | - 20018 ログインして下さい (API呼び出し時に `/v1/` を付け忘れている時に起こります) 54 | - 20023 2段階認証コードを入力して下さい 55 | - 20024 SMS認証コードを入力して下さい 56 | - 20025 2段階認証コードとSMS認証コードを入力して下さい 57 | - 20026 一定回数以上2段階認証に失敗したためロックしました。60秒待ってから再度お試しください 58 | - 20033 ACCESS-REQUEST-TIMEが存在しません 59 | - 20034 ACCESS-REQUEST-TIMEの時刻が不正です 60 | - 20035 ACCESS-TIME-WINDOW内にリクエストが送信されませんでした 61 | - 20036 ACCESS-REQUEST-TIMEおよびACCESS-NONCEが存在しません 62 | - 20037 ACCESS-REQUEST-TIMEの値が不正です 63 | - 20038 ACCESS-TIME-WINDOWの値が不正です 64 | - 20039 ACCESS-NONCEの値が不正です 65 | 66 | ## 必須パラメータバリデーションエラー 67 | 68 | - 30001 注文数量を指定して下さい 69 | - 30006 注文IDを指定して下さい 70 | - 30007 注文ID配列を指定して下さい 71 | - 30009 銘柄を指定して下さい 72 | - 30012 注文価格を指定して下さい 73 | - 30013 売買どちらかを指定して下さい 74 | - 30015 注文タイプを指定して下さい 75 | - 30016 アセット名を指定して下さい 76 | - 30019 uuidを指定して下さい 77 | - 30039 出金額を指定して下さい 78 | - 30101 トリガー価格を指定してください 79 | - 30103 送金先種別を指定して下さい 80 | - 30104 送金先名を入力して下さい 81 | - 30105 VASPを指定して下さい 82 | - 30106 受取人種別を指定して下さい 83 | - 30107 受取人姓を入力して下さい 84 | - 30108 受取人名を入力して下さい 85 | - 30109 受取人カナ姓を入力して下さい 86 | - 30110 受取人カナ名を入力して下さい 87 | - 30111 受取法人名を入力して下さい 88 | - 30112 受取法人カナ名を入力して下さい 89 | - 30113 法人格を入力して下さい 90 | - 30114 法人格表示位置を入力して下さい 91 | - 30115 書類のアップロードが必要です 92 | - 30116 出金目的を指定して下さい 93 | - 30117 住所(国)を入力して下さい 94 | - 30118 住所(郵便番号)を入力して下さい 95 | - 30119 住所(都道府県)を入力して下さい 96 | - 30120 住所(市区町村)を入力して下さい 97 | - 30121 住所(番地)を入力して下さい 98 | - 30122 住所(建物・アパート名)を入力して下さい 99 | - 30123 抽出リクエストのカテゴリを指定してください 100 | 101 | ## バリデーションエラー 102 | 103 | - 40001 注文数量が不正です 104 | - 40006 count値が不正です 105 | - 40007 終了時期が不正です 106 | - 40008 end_id値が不正です 107 | - 40009 from_id値が不正です 108 | - 40013 注文IDが不正です 109 | - 40014 注文ID配列が不正です 110 | - 40015 指定された注文が多すぎます 111 | - 40017 銘柄名が不正です 112 | - 40020 注文価格が不正です 113 | - 40021 売買区分が不正です 114 | - 40022 開始時期が不正です 115 | - 40024 注文タイプが不正です 116 | - 40025 アセット名が不正です 117 | - 40028 uuidが不正です 118 | - 40048 出金額が不正です 119 | - 40112 トリガー価格が不正です 120 | - 40113 post_only値が不正です 121 | - 40114 Post Onlyはご指定の注文タイプでは指定できません 122 | - 40116 送金先種別が不正です 123 | - 40117 送金先名が不正です 124 | - 40118 VASPが不正です 125 | - 40119 受取人種別が不正です 126 | - 40120 受取人姓が不正です 127 | - 40121 受取人名が不正です 128 | - 40122 受取人カナ姓が不正です 129 | - 40123 受取人カナ名が不正です 130 | - 40124 受取法人名が不正です 131 | - 40125 受取法人カナ名が不正です 132 | - 40126 法人格が不正です 133 | - 40127 法人格表示位置が不正です 134 | - 40152 送付人ラベルが不正です 135 | - 40153 送付人姓が不正です 136 | - 40154 送付人名が不正です 137 | - 40155 送付法人名称が不正です 138 | - 40156 送付人都道府県(State/Province/Region)が不正です 139 | - 40157 送付人市区町村(Town/City)が不正です 140 | - 40158 送付人番地(Address 1)が不正です 141 | - 40159 送付人建物名(Address 2)が不正です 142 | - 40160 送付人実質的支配者の氏名が不正です 143 | - 40163 受取法人実質的支配者名が不正です 144 | - 40164 ポジション区分が不正です 145 | - 40165 信用取引が可能な銘柄ではありません 146 | - 40200 逆指値新規建注文は承ることができません 147 | 148 | ## DBに問い合わせた結果データ異常 149 | 150 | - 50003 現在、このアカウントはご指定の操作を実行できない状態となっております。サポートにお問い合わせ下さい 151 | - 50004 現在、このアカウントは仮登録の状態となっております。アカウント登録完了後、再度お試し下さい 152 | - 50005 現在、このアカウントはロックされております。サポートにお問い合わせ下さい 153 | - 50006 現在、このアカウントはロックされております。サポートにお問い合わせ下さい 154 | - 50008 ユーザの本人確認が完了していません 155 | - 50009 ご指定の注文は存在しません 156 | - 50010 ご指定の注文はキャンセルできません 157 | - 50011 APIが見つかりません 158 | - 50026 ご指定の注文は既にキャンセル済みです 159 | - 50027 ご指定の注文は既に約定済みです 160 | - 50033 このアドレスへの出金は追加項目の入力が必要です 161 | - 50034 VASPが見つかりません 162 | - 50035 法人情報が登録されていません 163 | - 50037 直前の入金内容を確認中のため、一時的に出金を制限しております。数分後に再度実行して下さい。 164 | - 50038 この取引所には出金できません 165 | - 50043 送付人が既に登録されています 166 | - 50044 送付人が登録されていません 167 | - 50045 入金が存在しません 168 | - 50046 このアドレスは審査中のため編集できません 169 | - 50047 このアドレスは無効なため編集できません 170 | - 50048 このアドレスは審査中のため出金できません 171 | - 50049 このアドレスへの出金は追加項目の入力が必要です 172 | - 50050 このアドレスへは出金できません 173 | - 50051 この送付人は審査中のため入金確認できません 174 | - 50052 この送付人は追加項目の入力が必要です 175 | - 50053 この送付人は審査中のため編集できません 176 | - 50054 未反映入金への情報登録が未完了のため出金できません 177 | - 50058 信用取引の審査が完了していません 178 | - 50059 新規建注文を一時的に制限しています。しばらく時間を空けてから再度リクエストをお願いします 179 | - 50060 新規建注文を一時的に制限しています。しばらく時間を空けてから再度リクエストをお願いします 180 | - 50061 新規建可能額を上回っています 181 | - 50062 建玉数量を上回っています 182 | - 50070 現在、日本円の出金はご利用いただけません。 183 | - 50071 現在、暗号資産の出金はご利用いただけません 184 | - 50072 現在、現物取引における買い注文はご利用いただけません。 185 | - 50073 現在、現物取引における売り注文はご利用いただけません。 186 | - 50078 現在、信用取引における新規建て注文はご利用いただけません。 187 | - 50079 現在、信用取引における決済注文はご利用いただけません。 188 | - 50080 現在、信用取引における新規建て注文はご利用いただけません。 189 | - 50081 現在、信用取引における決済注文はご利用いただけません。 190 | - 50083 決済損金があるため、出金はご利用いただけません。 191 | 192 | ## 値が不正 193 | 194 | - 60001 保有数量が不足しています 195 | - 60002 成行買い注文の数量上限を上回っています 196 | - 60003 指定した数量が制限を超えています 197 | - 60004 指定した数量がしきい値を下回っています 198 | - 60005 指定した価格が上限を上回っています 199 | - 60006 指定した価格が下限を下回っています 200 | - 60011 同時発注制限件数(30件)を上回っています 201 | - 60016 指定したトリガー価格が上限を上回っています 202 | - 60017 出金数量が上限を上回っています 203 | - 60018 即時トリガーするトリガー価格は指定できません 204 | - 60019 TakeProfitまたはStopLoss注文のsideは決済方向である必要があります 205 | 206 | ## システムステータスによりリクエスト停止状態 207 | 208 | - 70001 システムエラーが発生しました。サポートにお問い合わせ下さい 209 | - 70002 システムエラーが発生しました。サポートにお問い合わせ下さい 210 | - 70003 システムエラーが発生しました。サポートにお問い合わせ下さい 211 | - 70004 現在取引停止中のため、注文を承ることができません 212 | - 70005 現在買い注文停止中のため、注文を承ることができません 213 | - 70006 現在売り注文停止中のため、注文を承ることができません 214 | - 70009 ただいま成行注文を一時的に制限しています。指値注文をご利用ください 215 | - 70010 ただいまシステム負荷が高まっているため、最小注文数量を一時的に引き上げています 216 | - 70011 ただいまリクエストが混雑してます。しばらく時間を空けてから再度リクエストをお願いします 217 | - 70012 システムエラーが発生しました。サポートにお問い合わせ下さい 218 | - 70013 ただいまシステム負荷が高まっているため、注文および注文キャンセルを一時的に制限しています 219 | - 70014 ただいまシステム負荷が高まっているため、出金申請および出金申請キャンセルを一時的に制限しています 220 | - 70015 ただいまシステム負荷が高まっているため、貸出申請および貸出申請キャンセルを一時的に制限しています 221 | - 70016 貸出申請および貸出申請キャンセル停止中のため、リクエストを承ることができません 222 | - 70017 指定された銘柄は注文停止中のため、リクエストを承ることができません 223 | - 70018 指定された銘柄は注文およびキャンセル停止中のため、リクエストを承ることができません 224 | - 70019 注文はキャンセル中です 225 | - 70020 現在成行注文停止中のため、注文を承ることができません 226 | - 70021 指値注文価格が乖離率を超過しています 227 | - 70022 現在逆指値指値注文停止中のため、注文を承ることができません 228 | - 70023 現在逆指値成行注文停止中のため、注文を承ることができません 229 | - 70024 現在ロング新規建注文停止中のため、注文を承ることができません 230 | - 70025 現在ショート新規建注文停止中のため、注文を承ることができません 231 | - 70026 ただいま一時的に受注を制限してます 232 | -------------------------------------------------------------------------------- /networks.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [networks](#networks) 6 | 7 | 8 | 9 | # networks 10 | 11 | The following is the list of network. 12 | 13 | Network | Network name 14 | ------------ | ------------ 15 | bitcoin | Bitcoin 16 | litecoin | Litecoin 17 | ripple | XRP 18 | ethereum | Ethereum 19 | monacoin | Monacoin 20 | bitcoincash | Bitcoin Cash 21 | stellar | Stellar 22 | qtum | Qtum 23 | symbol | Symbol 24 | polkadot | Polkadot 25 | dogecoin | Dogecoin 26 | astar | Astar 27 | cardano | Cardano 28 | avalanche | Avalanche C-Chain 29 | flare | Flare 30 | oasys | Oasys 31 | bsc | BNB Smart Chain 32 | arbitrum | Arbitrum 33 | op | OP Mainnet 34 | polygon | Polygon 35 | tron | Tron 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bitbank-api-docs", 3 | "version": "1.0.0", 4 | "description": "Official Documentation for the bitbank.cc APIs and Streams", 5 | "main": "README.md", 6 | "scripts": { 7 | "toc": "doctoc rest-api.md rest-api_JP.md private-stream.md private-stream_JP.md public-stream.md public-stream_JP.md public-api.md public-api_JP.md errors.md errors_JP.md networks.md assets.md pairs.md", 8 | "changelog": "standard-version", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/bitbankinc/bitbank-api-docs.git" 14 | }, 15 | "keywords": [ 16 | "bitbank", 17 | "api", 18 | "docs" 19 | ], 20 | "author": "bitbank.cc", 21 | "license": "UNLICENSED", 22 | "bugs": { 23 | "url": "https://github.com/bitbankinc/bitbank-api-docs/issues" 24 | }, 25 | "homepage": "https://github.com/bitbankinc/bitbank-api-docs#readme", 26 | "devDependencies": { 27 | "doctoc": "^2.2.1", 28 | "standard-version": "^9.5.0", 29 | "textlint": "^13.3.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pairs.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [pairs (2024-12-11)](#pairs-2024-12-11) 6 | 7 | 8 | 9 | # pairs (2024-12-11) 10 | 11 | The following is the list of pair. 12 | 13 | Symbol | Base asset | Quote asset | Order suspended flag (delisted) 14 | ------------ | ------------ | ------------ | ------------ 15 | btc_jpy | btc | jpy | false 16 | xrp_jpy | xrp | jpy | false 17 | xrp_btc | xrp | btc | true 18 | ltc_jpy | ltc | jpy | false 19 | ltc_btc | ltc | btc | true 20 | eth_jpy | eth | jpy | false 21 | eth_btc | eth | btc | true 22 | mona_jpy | mona | jpy | false 23 | mona_btc | mona | btc | true 24 | bcc_jpy | bcc | jpy | false 25 | bcc_btc | bcc | btc | true 26 | xlm_jpy | xlm | jpy | false 27 | xlm_btc | xlm | btc | true 28 | qtum_jpy | qtum | jpy | false 29 | qtum_btc | qtum | btc | true 30 | bat_jpy | bat | jpy | false 31 | bat_btc | bat | btc | true 32 | omg_jpy | omg | jpy | false 33 | omg_btc | omg | btc | true 34 | xym_jpy | xym | jpy | false 35 | xym_btc | xym | btc | true 36 | link_jpy | link | jpy | false 37 | link_btc | link | btc | true 38 | mkr_jpy | mkr | jpy | false 39 | mkr_btc | mkr | btc | true 40 | boba_jpy | boba | jpy | false 41 | boba_btc | boba | btc | true 42 | enj_jpy | enj | jpy | false 43 | enj_btc | enj | btc | true 44 | matic_jpy | matic | jpy | true 45 | matic_btc | matic | btc | true 46 | dot_jpy | dot | jpy | false 47 | doge_jpy | doge | jpy | false 48 | astr_jpy | astr | jpy | false 49 | ada_jpy | ada | jpy | false 50 | avax_jpy | avax | jpy | false 51 | axs_jpy | axs | jpy | false 52 | flr_jpy | flr | jpy | false 53 | sand_jpy | sand | jpy | false 54 | gala_jpy | gala | jpy | false 55 | ape_jpy | ape | jpy | false 56 | chz_jpy | chz | jpy | false 57 | oas_jpy | oas | jpy | false 58 | mana_jpy | mana | jpy | false 59 | grt_jpy | grt | jpy | false 60 | rndr_jpy | rndr | jpy | true 61 | bnb_jpy | bnb | jpy | false 62 | dai_jpy | dai | jpy | false 63 | op_jpy | op | jpy | false 64 | arb_jpy | arb | jpy | false 65 | klay_jpy | klay | jpy | false 66 | imx_jpy | imx | jpy | false 67 | mask_jpy | mask | jpy | false 68 | pol_jpy | pol | jpy | false 69 | sol_jpy | sol | jpy | false 70 | cyber_jpy | cyber | jpy | false 71 | render_jpy | render | jpy | false 72 | trx_jpy | trx | jpy | false 73 | lpt_jpy | lpt | jpy | false 74 | atom_jpy | atom | jpy | false 75 | -------------------------------------------------------------------------------- /private-stream.md: -------------------------------------------------------------------------------- 1 | [日本語](private-stream_JP.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [Private stream for bitbank](#private-stream-for-bitbank) 8 | - [Introduction](#introduction) 9 | - [What is a private stream?](#what-is-a-private-stream) 10 | - [What is PubNub?](#what-is-pubnub) 11 | - [How to use](#how-to-use) 12 | - [Step 1: Get your API key](#step-1-get-your-api-key) 13 | - [Step 2: Get channel name and token](#step-2-get-channel-name-and-token) 14 | - [Step 3: Connect to PubNub](#step-3-connect-to-pubnub) 15 | - [Step 4: Receive order user data](#step-4-receive-order-user-data) 16 | - [method: asset_update](#method-asset_update) 17 | - [method: spot_order_new](#method-spot_order_new) 18 | - [method: spot_order](#method-spot_order) 19 | - [method: spot_order_invalidation](#method-spot_order_invalidation) 20 | - [method: spot_trade](#method-spot_trade) 21 | - [method: dealer_order_new](#method-dealer_order_new) 22 | - [method: withdrawal](#method-withdrawal) 23 | - [method: deposit](#method-deposit) 24 | - [method: margin_position_update](#method-margin_position_update) 25 | - [method: margin_payable_update](#method-margin_payable_update) 26 | - [method: margin_notice_update](#method-margin_notice_update) 27 | - [Step 5: Reconnect to PubNub](#step-5-reconnect-to-pubnub) 28 | - [Example code](#example-code) 29 | 30 | 31 | 32 | # Private stream for bitbank 33 | 34 | ## Introduction 35 | 36 | ### What is a private stream? 37 | 38 | A private stream is a feature that allows you to receive real-time user data (such as order and asset change information) from the bitbank server. 39 | This feature is useful when you want to trade using real-time user data. 40 | User data is sent using PubNub and can be received in real-time. 41 | 42 | ### What is PubNub? 43 | 44 | PubNub is a service that provides real-time data streaming. bitbank uses PubNub to provide users with real-time user data. 45 | 46 | Using the PubNub SDK, you can connect to the PubNub server based on the information obtained from the API and receive user data. 47 | 48 | ## How to use 49 | 50 | ### Step 1: Get your API key 51 | 52 | To use the private stream, please get your API key and secret from the bitbank website. 53 | 54 | ### Step 2: Get channel name and token 55 | 56 | To connect to the private stream, you need to get the channel name and token from REST API GET /v1/user/subscribe endpoint. 57 | 58 | Refer to ["Get channel and token for private stream"](rest-api.md#get-channel-and-token-for-private-stream) in [rest-api](rest-api.md). 59 | 60 | ### Step 3: Connect to PubNub 61 | 62 | To connect to the private stream, you need to use the PubNub SDK. You can connect to the private stream by following the steps below: 63 | 64 | 1. Install the [PubNub SDK](https://www.pubnub.com/docs/sdks) for your language. ex. JavaScript: `npm install pubnub` 65 | 2. Create a PubNub configuration. ex. [JavaScript](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration) 66 | 3. Receive user data from the private stream. ex. [JavaScript](https://www.pubnub.com/docs/sdks/javascript/api-reference/publish-and-subscribe#subscribe) 67 | 68 | Use `sub-c-ecebae8e-dd60-11e6-b6b1-02ee2ddab7fe` as the subscribeKey. 69 | 70 | Refer to the [Example code](#example-code) for detailed implementation. 71 | 72 | ### Step 4: Receive order user data 73 | 74 | Once you have connected to the private stream, you can start receiving user data. The user data is sent in JSON format and contains the following information: 75 | 76 | #### method: asset_update 77 | 78 | Receive information about changes in owned assets. 79 | 80 | Name | Type | Description 81 | ------------ | ------------ | ------------ 82 | asset | string | Asset name: [Asset list](assets.md) 83 | amount_precision | number | Precision 84 | free_amount | string | Available amount 85 | locked_amount | string | Locked amount 86 | onhand_amount | string | On-hand amount 87 | withdrawing_amount | string | Withdrawing amount 88 | 89 | **Response format:** 90 | 91 | ```json 92 | { 93 | "message": { 94 | "method": "asset_update", 95 | "params": [ 96 | { 97 | "asset": "string", 98 | "amountPrecision": 0, 99 | "freeAmount": "string", 100 | "lockedAmount": "string", 101 | "onhandAmount": "string", 102 | "withdrawingAmount": "string" 103 | } 104 | ] 105 | } 106 | } 107 | ``` 108 | 109 | #### method: spot_order_new 110 | 111 | Receive information about new orders. 112 | 113 | If you are managing active orders locally, when you receive a notification with the status `FULLY_FILLED`, `CANCELED_UNFILLED`, or `CANCELED_PARTIALLY_FILLED`, it indicates that the order has been executed or canceled, so please remove it from your order information. 114 | 115 | Name | Type | Description 116 | ------------ | ------------ | ------------ 117 | average_price | string | avg executed price 118 | canceled_at | number | canceled at unix timestamp (milliseconds) 119 | executed_amount | string | qty executed 120 | executed_at | number | order executed at unix timestamp (milliseconds) 121 | order_id | number | order ID 122 | ordered_at | number | ordered at unix timestamp (milliseconds) 123 | pair | string | pair enum: [pair list](pairs.md) 124 | price | string | order price 125 | trigger_price | string \| undefined | trigger price(present only if type = `stop`, `stop_limit`, `take_profit`, `stop_loss`) 126 | remaining_amount | string \| null | qty not executed 127 | position_side | string \| undefined | `long` or `short`(only for margin trading) 128 | side | string | `buy` or `sell` 129 | start_amount | string \| null | order qty when placed 130 | status | string | status enum: `INACTIVE`, `UNFILLED`, `PARTIALLY_FILLED`, `FULLY_FILLED`, `CANCELED_UNFILLED`, `CANCELED_PARTIALLY_FILLED` 131 | type | string | one of `limit`, `market`, `stop`, `stop_limit`, `take_profit`, `stop_loss`, `losscut` 132 | expire_at | number \| null | expiration time in unix timestamp (milliseconds) 133 | triggered_at | number \| undefined | triggered at unix timestamp (milliseconds) (present only if type = `stop`, `stop_limit`, `take_profit`, `stop_loss`) 134 | post_only | boolean \| undefined | whether Post Only or not (present only if type = `limit`) 135 | user_cancelable | boolean | User cancelable 136 | is_just_triggered | boolean | Just triggered 137 | 138 | **Response format:** 139 | 140 | ```json 141 | { 142 | "message": { 143 | "method": "spot_order_new", 144 | "params": [ 145 | { 146 | "average_price": "string", 147 | "canceled_at": 0, 148 | "executed_amount": "string", 149 | "executed_at": 0, 150 | "order_id": 0, 151 | "ordered_at": 0, 152 | "pair": "string", 153 | "price": "string", 154 | "trigger_price": "string", 155 | "remaining_amount": "string", 156 | "position_side": "string", 157 | "side": "string", 158 | "start_amount": "string", 159 | "status": "string", 160 | "type": "string", 161 | "expire_at": 0, 162 | "triggered_at": 0, 163 | "post_only": false, 164 | "user_cancelable": true, 165 | "is_just_triggered": false 166 | } 167 | ] 168 | } 169 | } 170 | ``` 171 | 172 | #### method: spot_order 173 | 174 | Receive information about order updates. 175 | 176 | The content is the same as `spot_order_new`. 177 | 178 | If you are managing active orders locally, when you receive a notification with the status `FULLY_FILLED`, `CANCELED_UNFILLED`, or `CANCELED_PARTIALLY_FILLED`, it indicates that the order has been executed or canceled, so please remove it from your order information. 179 | 180 | **Response format:** 181 | 182 | ```json 183 | { 184 | "message": { 185 | "method": "spot_order", 186 | "params": [ 187 | { 188 | "average_price": "string", 189 | "canceled_at": 0, 190 | "executed_amount": "string", 191 | "executed_at": 0, 192 | "order_id": 0, 193 | "ordered_at": 0, 194 | "pair": "string", 195 | "price": "string", 196 | "trigger_price": "string", 197 | "remaining_amount": "string", 198 | "position_side": "string", 199 | "side": "string", 200 | "start_amount": "string", 201 | "status": "string", 202 | "type": "string", 203 | "expire_at": 0, 204 | "triggered_at": 0, 205 | "post_only": false, 206 | "user_cancelable": true, 207 | "is_just_triggered": false 208 | } 209 | ] 210 | } 211 | } 212 | ``` 213 | 214 | #### method: spot_order_invalidation 215 | 216 | Receive information about order invalidation. 217 | 218 | This notification is sent when an order is invalidated due to asset shortages within our matching engine. 219 | Therefore, this notification does not occur frequently. 220 | Immediate cancellations of orders that typically occur are notified via `spot_order_new`, `spot_order`, or error responses from the REST API. 221 | 222 | If you are managing active orders locally, please remove the notified order from your order information. 223 | 224 | Name | Type | Description 225 | ------------ | ------------ | ------------ 226 | order_id | number | order ID 227 | 228 | **Response format:** 229 | 230 | ```json 231 | { 232 | "message": { 233 | "method": "spot_order_invalidation", 234 | "params": { 235 | "order_id": [1, 2, 3] 236 | } 237 | } 238 | } 239 | ``` 240 | 241 | #### method: spot_trade 242 | 243 | Receive information about trades. 244 | 245 | Name | Type | Description 246 | ------------ | ------------ | ------------ 247 | amount | string | executed amount 248 | executed_at | number | order executed at unix timestamp (milliseconds) 249 | fee_amount_base | string | base asset fee amount 250 | fee_amount_quote | string | quote asset fee amount 251 | fee_occurred_amount_quote | string | Quote fee occurred. Collected on close orders for margin trading. For spot trading, it is collected immediately and is the same as `fee_amount_quote`. 252 | maker_taker | string | maker or taker 253 | order_id | number | order ID 254 | pair | string | pair enum: [pair list](pairs.md) 255 | price | string | order price 256 | position_side | string \| undefined | `long` or `short`(only for margin trading) 257 | side | string | `buy` or `sell` 258 | trade_id | number | trade ID 259 | type | string | one of `limit`, `market`, `stop`, `stop_limit`, `take_profit`, `stop_loss`, `losscut` 260 | profit_loss | string \| undefined | realized profit and loss 261 | interest | string \| undefined | interest 262 | 263 | **Response format:** 264 | 265 | ```json 266 | { 267 | "message": { 268 | "method": "spot_trade", 269 | "params": [ 270 | { 271 | "amount": "string", 272 | "executed_at": 0, 273 | "fee_amount_base": "string", 274 | "fee_amount_quote": "string", 275 | "fee_occurred_amount_quote": "string", 276 | "maker_taker": "string", 277 | "order_id": 0, 278 | "pair": "string", 279 | "price": "string", 280 | "position_side": "string", 281 | "side": "string", 282 | "trade_id": 0, 283 | "type": "string", 284 | "profit_loss": "string", 285 | "interest": "string" 286 | } 287 | ] 288 | } 289 | } 290 | ``` 291 | 292 | #### method: dealer_order_new 293 | 294 | Receive information about new dealer orders. 295 | 296 | Name | Type | Description 297 | ------------ | ------------ | ------------ 298 | order_id | string | order ID 299 | asset | string | enum: [asset list](assets.md) 300 | side | string | `buy` or `sell` 301 | price | string | price 302 | amount | string | amount 303 | ordered_at | number | ordered at unix timestamp (milliseconds) 304 | 305 | **Response format:** 306 | 307 | ```json 308 | { 309 | "message": { 310 | "method": "dealer_order_new", 311 | "params": [ 312 | { 313 | "order_id": 0, 314 | "asset": "string", 315 | "side": "string", 316 | "price": "string", 317 | "amount": "string", 318 | "ordered_at": 0 319 | } 320 | ] 321 | } 322 | } 323 | ``` 324 | 325 | #### method: withdrawal 326 | 327 | Receive information about withdrawals. 328 | 329 | Name | Type | Description 330 | ------------ | ------------ | ------------ 331 | uuid | string | withdrawal ID 332 | network | string | enum: [network list](networks.md)(only for crypto assets) 333 | asset | string | enum: [asset list](assets.md) 334 | account_uuid | string | account UUID 335 | asset | string | enum: [asset list](assets.md) 336 | fee | string | withdrawal fee 337 | label | string | withdrawal account label (only for crypto assets) 338 | address | string | withdrawal destination address (only for crypto assets) 339 | txid | string \| null | withdrawal transaction id (only for crypto assets) 340 | bank_name | string | bank of withdrawal account (only for fiat assets) 341 | branch_name | string | bank branch of withdrawal account (only for fiat assets) 342 | account_type | string | type of withdrawal account (only for fiat assets) 343 | account_number | string | withdrawal account number (only for fiat assets) 344 | account_owner | string | owner of withdrawal account (only for fiat assets) 345 | status | string | withdrawal status enum: `CONFIRMING`, `EXAMINING`, `SENDING`, `DONE`, `REJECTED`, `CANCELED`, `CONFIRM_TIMEOUT` 346 | requested_at | number | requested at unix timestamp (milliseconds) 347 | 348 | **Response format:** 349 | 350 | ```json 351 | { 352 | "message": { 353 | "method": "withdrawal", 354 | "params": [ 355 | { 356 | "uuid": "string", 357 | "asset": "string", 358 | "account_uuid": "string", 359 | "amount": "string", 360 | "fee": "string", 361 | "bank_name": "string", 362 | "branch_name": "string", 363 | "account_type": "string", 364 | "account_number": "string", 365 | "account_owner": "string", 366 | "status": "string", 367 | "requested_at": 0 368 | } 369 | ] 370 | } 371 | } 372 | ``` 373 | 374 | #### method: deposit 375 | 376 | Receive information about deposits. 377 | 378 | Name | Type | Description 379 | ------------ | ------------ | ------------ 380 | uuid | string | deposit ID 381 | asset | string | enum: [asset list](assets.md) 382 | amount | number | deposit amount 383 | network | string | enum: [network list](networks.md)(only for crypto assets) 384 | address | string | deposit address(only for crypto assets) 385 | txid | string \| null | deposit transaction id (only for crypto assets) 386 | found_at | number | found at unix timestamp (milliseconds) 387 | confirmed_at | number | confirmed (about to be added to your balance) at unix timestamp (milliseconds, exists only for confirmed one) 388 | status | string | deposit status enum: `FOUND`, `CONFIRMED`, `DONE` 389 | 390 | **Response format:** 391 | 392 | ```json 393 | { 394 | "message": { 395 | "method": "deposit", 396 | "params": [ 397 | { 398 | "uuid": "string", 399 | "asset": "string", 400 | "amount": "string", 401 | "network": "string", 402 | "address": "string", 403 | "txid": "string", 404 | "found_at": 0, 405 | "confirmed_at": 0, 406 | "status": "string" 407 | } 408 | ] 409 | } 410 | } 411 | ``` 412 | 413 | #### method: margin_position_update 414 | 415 | Receive information about margin positions. 416 | 417 | Name | Type | Description 418 | ------------ | ------------ | ------------ 419 | pair | string | pair enum: [pair list](pairs.md) 420 | position_side | string | `long` or `short` 421 | average_price | string | avg executed price 422 | open_amount | string | open amount 423 | locked_amount | string | locked amount 424 | product | string | average executed price x open amount 425 | unrealized_fee_amount | string | unrealized fee amount 426 | unrealized_interest_amount | string | unrealized interest amount 427 | 428 | **Response format:** 429 | 430 | ```json 431 | { 432 | "message": { 433 | "method": "margin_position_update", 434 | "params": [ 435 | { 436 | "pair": "string", 437 | "position_side": "string", 438 | "average_price": "string", 439 | "open_amount": "string", 440 | "locked_amount": "string", 441 | "product": "string", 442 | "unrealized_fee_amount": "string", 443 | "unrealized_interest_amount": "string" 444 | } 445 | ] 446 | } 447 | } 448 | ``` 449 | 450 | #### method: margin_payable_update 451 | 452 | Receive information about margin payables. 453 | 454 | Name | Type | Description 455 | ------------ | ------------ | ------------ 456 | amount | string | payable amount 457 | 458 | **Response format:** 459 | 460 | ```json 461 | { 462 | "message": { 463 | "method": "margin_payable_update", 464 | "params": [ 465 | { 466 | "amount": "string" 467 | } 468 | ] 469 | } 470 | } 471 | ``` 472 | 473 | #### method: margin_notice_update 474 | 475 | Receive information about margin notices. 476 | 477 | This is published when a margin call or insufficient funds occur, or when they are partially deposited or partially repaid. 478 | Additionally, if these are resolved or fully settled, a message with all properties set to `null` will be published. 479 | 480 | Name | Type | Description 481 | ------------ | ------------ | ------------ 482 | what | string \| null | what the notice is for (marginCall, debt, or settled) 483 | occurred_at | number \| null | occurrence time 484 | amount | string \| null | amount 485 | due_date_at | number \| null | due date 486 | 487 | **Response format:** 488 | 489 | ```json 490 | { 491 | "message": { 492 | "method": "margin_notice_update", 493 | "params": [ 494 | { 495 | "what": "string", 496 | "occurred_at": 0, 497 | "amount": "string", 498 | "due_date_at": 0 499 | } 500 | ] 501 | } 502 | } 503 | ``` 504 | 505 | ### Step 5: Reconnect to PubNub 506 | 507 | If the connection to the private stream is lost, you can reconnect to PubNub by following the steps below: 508 | 509 | 1. Detect that the connection to PubNub has been lost from the status event. 510 | 2. Reconnect to PubNub. 511 | 512 | Refer to the [Example code](#example-code) for detailed implementation. 513 | 514 | ## Example code 515 | 516 | Here is an example code that shows how to connect to the private stream and receive user data: 517 | 518 | ```javascript 519 | // npm install pubnub 520 | const PubNub = require('pubnub'); 521 | const crypto = require('crypto'); 522 | 523 | const API_KEY = ''; 524 | const API_SECRET = ''; 525 | 526 | const PUBNUB_SUB_KEY = 'sub-c-ecebae8e-dd60-11e6-b6b1-02ee2ddab7fe'; 527 | 528 | const main = async () => { 529 | 530 | const { channel, token } = await getChannelAndToken(); 531 | 532 | const pubnub = getPubNubAndAddListener(channel, token); 533 | 534 | subscribePrivateChannel(pubnub, channel, token); 535 | 536 | setInterval(() => { 537 | // Keep connection alive 538 | }, 10000); 539 | } 540 | 541 | const toSha256 = (key, value) =>{ 542 | return crypto 543 | .createHmac('sha256', key) 544 | .update(Buffer.from(value)) 545 | .digest('hex') 546 | .toString(); 547 | } 548 | 549 | const getPubNubAndAddListener = (channel, token) => { 550 | const pubnub = new PubNub({ 551 | subscribeKey: PUBNUB_SUB_KEY, 552 | userId: channel, 553 | ssl: true, 554 | }); 555 | pubnub.addListener({ 556 | status: async (status) => { 557 | switch (status.category) { 558 | /** 559 | * When pubnub channel connection established successfully. 560 | * This is called once after trying to start to connect. 561 | */ 562 | case 'PNConnectedCategory': { 563 | console.info('pubnub connection established'); 564 | break; 565 | } 566 | 567 | /** 568 | * When connection restored. 569 | */ 570 | case 'PNNetworkUpCategory': 571 | case 'PNReconnectedCategory': { 572 | console.info('pubnub connection restored'); 573 | // When network down, pubnub disposes subscribers so we need to re-subscribe manually. 574 | subscribePrivateChannel(pubnub_channel, token); 575 | break; 576 | } 577 | 578 | /** 579 | * When connection failed by timeout. 580 | * In this case, we need to reconnect manually. 581 | */ 582 | case 'PNTimeoutCategory': { 583 | console.warn('pubnub connection Failed by timeout.'); 584 | await reconnect(); 585 | break; 586 | } 587 | 588 | /** 589 | * When connection failed due to network error. 590 | */ 591 | case 'PNNetworkDownCategory': 592 | case 'PNNetworkIssuesCategory': { 593 | console.error('pubnub connection network error', status); 594 | await reconnect(); 595 | break; 596 | } 597 | 598 | /** 599 | * This will be called when token is expired. 600 | */ 601 | case 'PNAccessDeniedCategory': { 602 | console.error('pubnub access denied', status); 603 | await reconnect(); 604 | break; 605 | } 606 | 607 | /** 608 | * This will not be called. 609 | * Maybe pubnub-library is not implement these events. 610 | */ 611 | case 'PNBadRequestCategory': 612 | case 'PNMalformedResponseCategory': 613 | case 'PNDecryptionErrorCategory': { 614 | console.error('pubnub connection failed', status); 615 | break; 616 | } 617 | 618 | /** 619 | * This will not be called. 620 | * If this called, implement new handling for the event. 621 | */ 622 | default: { 623 | console.warn('default'); 624 | } 625 | } 626 | }, 627 | 628 | message: (data) => { 629 | if (data && data.message) { 630 | console.info('message received', JSON.stringify(data.message)); 631 | } 632 | }, 633 | }); 634 | 635 | return pubnub; 636 | } 637 | 638 | const getChannelAndToken = async () => { 639 | const nonce = new Date().getTime(); 640 | const timeWindow = '5000'; 641 | const message = `${nonce}${timeWindow}/v1/user/subscribe`; 642 | 643 | // Get channel and token from API 644 | const res = await fetch('https://api.bitbank.cc/v1/user/subscribe', { 645 | method: 'GET', 646 | headers: { 647 | 'Content-Type': 'application/json', 648 | 'ACCESS-KEY': API_KEY, 649 | 'ACCESS-REQUEST-TIME': nonce.toString(), 650 | 'ACCESS-TIME-WINDOW': timeWindow, 651 | 'ACCESS-SIGNATURE': toSha256(API_SECRET, message), 652 | }, 653 | }).then((res) => res.json()); 654 | 655 | const channel = res.data.pubnub_channel; 656 | const token = res.data.pubnub_token; 657 | return { channel, token }; 658 | } 659 | 660 | const subscribePrivateChannel = (pubnub, channel, token) => { 661 | pubnub.setToken(token); 662 | pubnub.subscribe({ 663 | channels: [channel], 664 | }); 665 | } 666 | 667 | const reconnect = async () => { 668 | // Reconnect to pubnub 669 | const { channel, token } = await getChannelAndToken(); 670 | const pubnub = getPubNubAndAddListener(channel, token); 671 | 672 | subscribePrivateChannel(pubnub, channel, token); 673 | } 674 | 675 | main().catch(console.error); 676 | ``` -------------------------------------------------------------------------------- /private-stream_JP.md: -------------------------------------------------------------------------------- 1 | [English](private-stream.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [プライベートストリーム](#%E3%83%97%E3%83%A9%E3%82%A4%E3%83%99%E3%83%BC%E3%83%88%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0) 8 | - [はじめに](#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB) 9 | - [プライベートストリームとは?](#%E3%83%97%E3%83%A9%E3%82%A4%E3%83%99%E3%83%BC%E3%83%88%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0%E3%81%A8%E3%81%AF) 10 | - [PubNubとは?](#pubnub%E3%81%A8%E3%81%AF) 11 | - [使い方](#%E4%BD%BF%E3%81%84%E6%96%B9) 12 | - [ステップ1: APIキーを取得する](#%E3%82%B9%E3%83%86%E3%83%83%E3%83%971-api%E3%82%AD%E3%83%BC%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 13 | - [ステップ2: チャンネル名とトークンを取得する](#%E3%82%B9%E3%83%86%E3%83%83%E3%83%972-%E3%83%81%E3%83%A3%E3%83%B3%E3%83%8D%E3%83%AB%E5%90%8D%E3%81%A8%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 14 | - [ステップ3: PubNubに接続する](#%E3%82%B9%E3%83%86%E3%83%83%E3%83%973-pubnub%E3%81%AB%E6%8E%A5%E7%B6%9A%E3%81%99%E3%82%8B) 15 | - [ステップ4: ユーザーデータを受信する](#%E3%82%B9%E3%83%86%E3%83%83%E3%83%974-%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%83%87%E3%83%BC%E3%82%BF%E3%82%92%E5%8F%97%E4%BF%A1%E3%81%99%E3%82%8B) 16 | - [資産変更通知 asset_update](#%E8%B3%87%E7%94%A3%E5%A4%89%E6%9B%B4%E9%80%9A%E7%9F%A5-asset_update) 17 | - [新規注文通知 spot_order_new](#%E6%96%B0%E8%A6%8F%E6%B3%A8%E6%96%87%E9%80%9A%E7%9F%A5-spot_order_new) 18 | - [注文変更通知 spot_order](#%E6%B3%A8%E6%96%87%E5%A4%89%E6%9B%B4%E9%80%9A%E7%9F%A5-spot_order) 19 | - [注文無効通知 spot_order_invalidation](#%E6%B3%A8%E6%96%87%E7%84%A1%E5%8A%B9%E9%80%9A%E7%9F%A5-spot_order_invalidation) 20 | - [約定情報通知 spot_trade](#%E7%B4%84%E5%AE%9A%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-spot_trade) 21 | - [新規販売所注文情報通知 dealer_order_new](#%E6%96%B0%E8%A6%8F%E8%B2%A9%E5%A3%B2%E6%89%80%E6%B3%A8%E6%96%87%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-dealer_order_new) 22 | - [出金情報通知 withdrawal](#%E5%87%BA%E9%87%91%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-withdrawal) 23 | - [入金情報通知 deposit](#%E5%85%A5%E9%87%91%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-deposit) 24 | - [建玉ポジション情報通知 margin_position_update](#%E5%BB%BA%E7%8E%89%E3%83%9D%E3%82%B8%E3%82%B7%E3%83%A7%E3%83%B3%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-margin_position_update) 25 | - [決済損金額・不足金額情報通知 margin_payable_update](#%E6%B1%BA%E6%B8%88%E6%90%8D%E9%87%91%E9%A1%8D%E3%83%BB%E4%B8%8D%E8%B6%B3%E9%87%91%E9%A1%8D%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-margin_payable_update) 26 | - [督促情報通知 margin_notice_update](#%E7%9D%A3%E4%BF%83%E6%83%85%E5%A0%B1%E9%80%9A%E7%9F%A5-margin_notice_update) 27 | - [ステップ5: PubNubに再接続する](#%E3%82%B9%E3%83%86%E3%83%83%E3%83%975-pubnub%E3%81%AB%E5%86%8D%E6%8E%A5%E7%B6%9A%E3%81%99%E3%82%8B) 28 | - [サンプルコード](#%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%B3%E3%83%BC%E3%83%89) 29 | 30 | 31 | 32 | # プライベートストリーム 33 | 34 | ## はじめに 35 | 36 | ### プライベートストリームとは? 37 | 38 | プライベートストリームは、bitbankのサーバーからリアルタイムのユーザーデータ(注文、資産などの変更情報)を受信する機能です。 39 | この機能は、リアルタイムにユーザーデータを用いた取引を行いたい場合に便利です。 40 | ユーザーデータはPubNubを使用して送信され、リアルタイムで受信できます。 41 | 42 | ### PubNubとは? 43 | 44 | PubNubは、リアルタイムデータストリーミングを提供するサービスです。bitbankは、ユーザーにリアルタイムのユーザーデータを提供するためにPubNubを使用しています。 45 | 46 | PubNubのSDKを使用して、APIから取得した情報をもとに、PubNubサーバーに接続してユーザーデータを受信します。 47 | 48 | ## 使い方 49 | 50 | ### ステップ1: APIキーを取得する 51 | 52 | プライベートストリームを使用するには、bitbankのウェブサイトからAPIキーとシークレットを取得してください。 53 | 54 | ### ステップ2: チャンネル名とトークンを取得する 55 | 56 | プライベートストリームに接続するには、REST APIのGET /v1/user/subscribeエンドポイントよりチャンネル名とトークンを取得する必要があります。 57 | 58 | [rest-api_JP](rest-api_JP.md)の [「プライベートストリームのチャンネルとトークンを取得する」](rest-api_JP.md#プライベートストリームのチャンネルとトークンを取得する)を参照してください。 59 | 60 | ### ステップ3: PubNubに接続する 61 | 62 | プライベートストリームに接続するには、PubNub SDKを使用する必要があります。以下の手順に従ってプライベートストリームに接続できます。 63 | 64 | 1. 使用言語の[PubNub SDK](https://www.pubnub.com/docs/sdks)をインストールします。 ex. JavaScript: `npm install pubnub` 65 | 2. それぞれの言語のPubNub Configurationを行います。 ex. [JavaScript](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration) 66 | 3. subscribeを行います。 ex. [JavaScript](https://www.pubnub.com/docs/sdks/javascript/api-reference/publish-and-subscribe#subscribe) 67 | 68 | subscribeKeyは、 `sub-c-ecebae8e-dd60-11e6-b6b1-02ee2ddab7fe` を使用してください。 69 | 70 | 詳細な実装は[サンプルコード](#サンプルコード)を参照してください。 71 | 72 | ### ステップ4: ユーザーデータを受信する 73 | 74 | プライベートストリームに接続したら、ユーザーデータを受信できます。ユーザーデータはJSON形式で送信され、以下の情報を含んでいます。 75 | 76 | #### 資産変更通知 asset_update 77 | 78 | 所有資産の変更情報を受信します。 79 | 80 | Name | Type | Description 81 | ------------ | ------------ | ------------ 82 | asset | string | アセット名: [アセット一覧](assets.md) 83 | amount_precision | number | 精度 84 | free_amount | string | 利用可能な量 85 | locked_amount | string | ロックされている量 86 | onhand_amount | string | 保有量 87 | withdrawing_amount | string | ロックされている量のうち出金中数量 88 | 89 | **レスポンスのフォーマット:** 90 | 91 | ```json 92 | { 93 | "message": { 94 | "method": "asset_update", 95 | "params": [ 96 | { 97 | "asset": "string", 98 | "amountPrecision": 0, 99 | "freeAmount": "string", 100 | "lockedAmount": "string", 101 | "onhandAmount": "string", 102 | "withdrawingAmount": "string" 103 | } 104 | ] 105 | } 106 | } 107 | ``` 108 | 109 | #### 新規注文通知 spot_order_new 110 | 111 | 新規注文情報を受信します。 112 | 113 | 手元でアクティブ注文を管理されている場合は、statusが `FULLY_FILLED`、 `CANCELED_UNFILLED`、 `CANCELED_PARTIALLY_FILLED` の通知を受け取った時、注文が約定、あるいはキャンセルされることを示しているため、手元の注文情報から削除してください。 114 | 115 | 116 | Name | Type | Description 117 | ------------ | ------------ | ------------ 118 | average_price | string | 平均約定価格 119 | canceled_at | number \| undefined | キャンセル日時(UnixTimeのミリ秒) 120 | executed_amount | string | 約定済み数量 121 | executed_at | number | 約定日時(UnixTimeのミリ秒) 122 | order_id | number | 注文ID 123 | ordered_at | number | 注文日時(UnixTimeのミリ秒) 124 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 125 | price | string \| undefined | 注文価格(type = `limit` または `stop_limit` 時のみ) 126 | trigger_price | string \| undefined | トリガー価格(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 127 | remaining_amount | string | 未約定の数量 128 | position_side | string \| undefined | `long` または `short`(信用取引の時のみ) 129 | side | string | `buy` または `sell` 130 | start_amount | string | 注文時の数量 131 | status | string | 注文ステータス: `INACTIVE` 非アクティブ, `UNFILLED` 注文中, `PARTIALLY_FILLED` 注文中(一部約定), `FULLY_FILLED` 約定済み, `CANCELED_UNFILLED` 取消済, `CANCELED_PARTIALLY_FILLED` 取消済(一部約定) 132 | type | string | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 133 | expire_at | number | 有効期限(UnixTimeのミリ秒) 134 | triggered_at | number \| undefined | トリガー日時(UnixTimeのミリ秒)(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 135 | post_only | boolean \| undefined | Post Onlyかどうか(type = `limit`時のみ) 136 | user_cancelable | boolean | ユーザがキャンセル可能な注文かどうか 137 | is_just_triggered | boolean | トリガーされたばかりかどうか 138 | 139 | **レスポンスのフォーマット:** 140 | 141 | ```json 142 | { 143 | "message": { 144 | "method": "spot_order_new", 145 | "params": [ 146 | { 147 | "average_price": "string", 148 | "canceled_at": 0, 149 | "executed_amount": "string", 150 | "executed_at": 0, 151 | "order_id": 0, 152 | "ordered_at": 0, 153 | "pair": "string", 154 | "price": "string", 155 | "trigger_price": "string", 156 | "remaining_amount": "string", 157 | "position_side": "string", 158 | "side": "string", 159 | "start_amount": "string", 160 | "status": "string", 161 | "type": "string", 162 | "expire_at": 0, 163 | "triggered_at": 0, 164 | "post_only": false, 165 | "user_cancelable": true, 166 | "is_just_triggered": false 167 | } 168 | ] 169 | } 170 | } 171 | ``` 172 | 173 | #### 注文変更通知 spot_order 174 | 175 | 注文更新情報を受信します。 176 | 177 | 内容は `spot_order_new` と同一です。 178 | 179 | 手元でアクティブ注文を管理されている場合は、statusが `FULLY_FILLED`、 `CANCELED_UNFILLED`、 `CANCELED_PARTIALLY_FILLED` の通知を受け取った時、注文が約定、あるいはキャンセルされることを示しているため、手元の注文情報から削除してください。 180 | 181 | **レスポンスのフォーマット:** 182 | 183 | ```json 184 | { 185 | "message": { 186 | "method": "spot_order", 187 | "params": [ 188 | { 189 | "average_price": "string", 190 | "canceled_at": 0, 191 | "executed_amount": "string", 192 | "executed_at": 0, 193 | "order_id": 0, 194 | "ordered_at": 0, 195 | "pair": "string", 196 | "price": "string", 197 | "trigger_price": "string", 198 | "remaining_amount": "string", 199 | "position_side": "string", 200 | "side": "string", 201 | "start_amount": "string", 202 | "status": "string", 203 | "type": "string", 204 | "expire_at": 0, 205 | "triggered_at": 0, 206 | "post_only": false, 207 | "user_cancelable": true, 208 | "is_just_triggered": false 209 | } 210 | ] 211 | } 212 | } 213 | ``` 214 | 215 | #### 注文無効通知 spot_order_invalidation 216 | 217 | 注文無効情報を受信します。 218 | 219 | こちらの通知は弊社マッチングエンジン内での資産不足等の理由により、注文が無効となった場合に通知されます。 220 | そのため、こちらの通知は頻繁に発生することはありません。 221 | 通常発生するような、注文の即時キャンセルは `spot_order_new`、 `spot_order` もしくはREST APIのエラーレスポンスで通知されます。 222 | 223 | 手元でアクティブ注文を管理されている場合は、手元の注文情報から通知された注文を削除してください。 224 | 225 | Name | Type | Description 226 | ------------ | ------------ | ------------ 227 | order_id | number | 注文ID 228 | 229 | **レスポンスのフォーマット:** 230 | 231 | ```json 232 | { 233 | "message": { 234 | "method": "spot_order_invalidation", 235 | "params": { 236 | "order_id": [1, 2, 3] 237 | } 238 | } 239 | } 240 | ``` 241 | 242 | #### 約定情報通知 spot_trade 243 | 244 | 約定情報を受信します。 245 | 246 | Name | Type | Description 247 | ------------ | ------------ | ------------ 248 | amount | string | 約定数量 249 | executed_at | number | 約定日時(UnixTimeのミリ秒) 250 | fee_amount_base | string | base手数料 251 | fee_amount_quote | string | quote手数料 252 | fee_occurred_amount_quote | string | quote発生手数料。信用取引では決済時に徴収。現物取引では即時徴収され`fee_amount_quote`と同値。 253 | maker_taker | string | `maker` または `taker` 254 | order_id | number | 注文ID 255 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 256 | price | string | 価格 257 | position_side | string \| null | `long` または `short`(信用取引の時のみ) 258 | side | string | `buy` または `sell` 259 | trade_id | number | 約定ID 260 | type | string | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 261 | profit_loss | string \| null | 実現損益 262 | interest | string \| null | 利息 263 | 264 | **レスポンスのフォーマット:** 265 | 266 | ```json 267 | { 268 | "message": { 269 | "method": "spot_trade", 270 | "params": [ 271 | { 272 | "amount": "string", 273 | "executed_at": 0, 274 | "fee_amount_base": "string", 275 | "fee_amount_quote": "string", 276 | "fee_occurred_amount_quote": "string", 277 | "maker_taker": "string", 278 | "order_id": 0, 279 | "pair": "string", 280 | "price": "string", 281 | "position_side": "string", 282 | "side": "string", 283 | "trade_id": 0, 284 | "type": "string", 285 | "profit_loss": "string", 286 | "interest": "string" 287 | } 288 | ] 289 | } 290 | } 291 | ``` 292 | 293 | #### 新規販売所注文情報通知 dealer_order_new 294 | 295 | 新規販売所注文情報を受信します。 296 | 297 | Name | Type | Description 298 | ------------ | ------------ | ------------ 299 | order_id | string | 注文ID 300 | asset | string | アセット名 301 | side | string | `buy` または `sell` 302 | price | string | 価格 303 | amount | string | 注文数量 304 | ordered_at | number | 注文日時 305 | 306 | **レスポンスのフォーマット:** 307 | 308 | ```json 309 | { 310 | "message": { 311 | "method": "dealer_order_new", 312 | "params": [ 313 | { 314 | "order_id": 0, 315 | "asset": "string", 316 | "side": "string", 317 | "price": "string", 318 | "amount": "string", 319 | "ordered_at": 0 320 | } 321 | ] 322 | } 323 | } 324 | ``` 325 | 326 | #### 出金情報通知 withdrawal 327 | 328 | 出金情報を受信します。 329 | 330 | Name | Type | Description 331 | ------------ | ------------ | ------------ 332 | uuid | string | 出金ID 333 | network | string | ネットワーク名(暗号資産の時のみ): [ネットワーク一覧](networks.md) 334 | asset | string | アセット名: [アセット一覧](assets.md) 335 | account_uuid | string | 出金アカウントのID 336 | amount | string | 出金数量 337 | fee | string | 出金手数料 338 | label | string | 出金先アドレスにつけたラベル(暗号資産の時のみ) 339 | address | string | 出金先アドレス(暗号資産の時のみ) 340 | txid | string \| null | 出金トランザクションID(暗号資産の時のみ) 341 | bank_name | string | 出金先銀行(法定通貨の時のみ) 342 | branch_name | string | 出金先銀行支店(法定通貨の時のみ) 343 | account_type | string | 出金先口座種別(法定通貨の時のみ) 344 | account_number | string | 出金先口座番号(法定通貨の時のみ) 345 | account_owner | string | 出金先口座名義(法定通貨の時のみ) 346 | status | string | `CONFIRMING`, `EXAMINING`, `SENDING`, `DONE`, `REJECTED`, `CANCELED`, `CONFIRM_TIMEOUT` 347 | requested_at | number | リクエスト日時UNIXタイムスタンプ(ミリ秒) 348 | 349 | **レスポンスのフォーマット:** 350 | 351 | ```json 352 | { 353 | "message": { 354 | "method": "withdrawal", 355 | "params": [ 356 | { 357 | "uuid": "string", 358 | "asset": "string", 359 | "account_uuid": "string", 360 | "amount": "string", 361 | "fee": "string", 362 | "bank_name": "string", 363 | "branch_name": "string", 364 | "account_type": "string", 365 | "account_number": "string", 366 | "account_owner": "string", 367 | "status": "string", 368 | "requested_at": 0 369 | } 370 | ] 371 | } 372 | } 373 | ``` 374 | 375 | #### 入金情報通知 deposit 376 | 377 | 入金情報を受信します。 378 | 379 | Name | Type | Description 380 | ------------ | ------------ | ------------ 381 | uuid | string | 入金ID 382 | asset | string | アセット名: [アセット一覧](assets.md) 383 | amount | string | 入金数量 384 | network | string \| undefined | ネットワーク名: [ネットワーク一覧](networks.md)(暗号通貨入金のみ) 385 | address | string \| undefined | 入金address(暗号通貨入金のみ) 386 | txid | string \| undefined | 入金トランザクションID(暗号通貨入金のみ) 387 | found_at | number | 検知UNIXタイムスタンプ(ミリ秒) 388 | confirmed_at | number | 承認(残高追加確定時)UNIXタイムスタンプ(ミリ秒、承認後のみ存在) 389 | status | string | 入金状態: `FOUND`, `CONFIRMED`, `DONE` 390 | 391 | **レスポンスのフォーマット:** 392 | 393 | ```json 394 | { 395 | "message": { 396 | "method": "deposit", 397 | "params": [ 398 | { 399 | "uuid": "string", 400 | "asset": "string", 401 | "amount": "string", 402 | "network": "string", 403 | "address": "string", 404 | "txid": "string", 405 | "found_at": 0, 406 | "confirmed_at": 0, 407 | "status": "string" 408 | } 409 | ] 410 | } 411 | } 412 | ``` 413 | 414 | #### 建玉ポジション情報通知 margin_position_update 415 | 416 | 建玉ポジション情報を受信します。 417 | 418 | Name | Type | Description 419 | ------------ | ------------ | ------------ 420 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 421 | position_side | string | `long` または `short` 422 | average_price | string | 平均約定価格 423 | open_amount | string | オープン数量 424 | locked_amount | string | ロック数量 425 | product | string | 平均約定価格 x オープン数量 426 | unrealized_fee_amount | string | 未実現手数料 427 | unrealized_interest_amount | string | 未実現利息 428 | 429 | **レスポンスのフォーマット:** 430 | 431 | ```json 432 | { 433 | "message": { 434 | "method": "margin_position_update", 435 | "params": [ 436 | { 437 | "pair": "string", 438 | "position_side": "string", 439 | "average_price": "string", 440 | "open_amount": "string", 441 | "locked_amount": "string", 442 | "product": "string", 443 | "unrealized_fee_amount": "string", 444 | "unrealized_interest_amount": "string" 445 | } 446 | ] 447 | } 448 | } 449 | ``` 450 | 451 | #### 決済損金額・不足金額情報通知 margin_payable_update 452 | 453 | 決済損金額・不足金情報を受信します。 454 | 455 | Name | Type | Description 456 | ------------ | ------------ | ------------ 457 | amount | string | 金額 458 | 459 | **レスポンスのフォーマット:** 460 | 461 | ```json 462 | { 463 | "message": { 464 | "method": "margin_payable_update", 465 | "params": [ 466 | { 467 | "amount": "string" 468 | } 469 | ] 470 | } 471 | } 472 | ``` 473 | 474 | #### 督促情報通知 margin_notice_update 475 | 476 | 督促情報を受信します。 477 | 478 | 追証や不足金額が発生した際や、それらを一部差入・一部返済した際に配信されます。 479 | また、それらを解消・完済した場合は全てのプロパティを null にしたものが配信されます。 480 | 481 | 482 | Name | Type | Description 483 | ------------ | ------------ | ------------ 484 | what | string \| null | 何に対する催促か(marginCall or debt or settled) 485 | occurred_at | number \| null | 発生日時 486 | amount | string \| null | 金額 487 | due_date_at | number \| null | 期限日時 488 | 489 | **レスポンスのフォーマット:** 490 | 491 | ```json 492 | { 493 | "message": { 494 | "method": "margin_notice_update", 495 | "params": [ 496 | { 497 | "what": "string", 498 | "occurred_at": 0, 499 | "amount": "string", 500 | "due_date_at": 0 501 | } 502 | ] 503 | } 504 | } 505 | ``` 506 | 507 | ### ステップ5: PubNubに再接続する 508 | 509 | プライベートストリームへの接続が切断された場合、以下の手順に従ってPubNubに再接続できます。 510 | 511 | 1. PubNubから切断されたことをstatusイベントから検知します。 512 | 2. PubNubに再接続します。 513 | 514 | 詳細な実装は[サンプルコード](#サンプルコード)を参照してください。 515 | 516 | ## サンプルコード 517 | 518 | 以下は、プライベートストリームに接続してユーザデータを受信する方法を示すサンプルコードです。 519 | 520 | ```javascript 521 | // npm install pubnub 522 | const PubNub = require('pubnub'); 523 | const crypto = require('crypto'); 524 | 525 | const API_KEY = ''; 526 | const API_SECRET = ''; 527 | 528 | const PUBNUB_SUB_KEY = 'sub-c-ecebae8e-dd60-11e6-b6b1-02ee2ddab7fe'; 529 | 530 | const main = async () => { 531 | const { channel, token } = await getChannelAndToken(); 532 | 533 | const pubnub = getPubNubAndAddListener(channel, token); 534 | 535 | subscribePrivateChannel(pubnub, channel, token); 536 | 537 | setInterval(() => { 538 | // Keep connection alive 539 | }, 10000); 540 | } 541 | 542 | const toSha256 = (key, value) =>{ 543 | return crypto 544 | .createHmac('sha256', key) 545 | .update(Buffer.from(value)) 546 | .digest('hex') 547 | .toString(); 548 | } 549 | 550 | const getPubNubAndAddListener = (channel, token) => { 551 | const pubnub = new PubNub({ 552 | subscribeKey: PUBNUB_SUB_KEY, 553 | userId: channel, 554 | ssl: true, 555 | }); 556 | pubnub.addListener({ 557 | status: async (status) => { 558 | switch (status.category) { 559 | /** 560 | * When pubnub channel connection established successfully. 561 | * This is called once after trying to start to connect. 562 | */ 563 | case 'PNConnectedCategory': { 564 | console.info('pubnub connection established'); 565 | break; 566 | } 567 | 568 | /** 569 | * When connection restored. 570 | */ 571 | case 'PNNetworkUpCategory': 572 | case 'PNReconnectedCategory': { 573 | console.info('pubnub connection restored'); 574 | // When network down, pubnub disposes subscribers so we need to re-subscribe manually. 575 | subscribePrivateChannel(pubnub_channel, token); 576 | break; 577 | } 578 | 579 | /** 580 | * When connection failed by timeout. 581 | * In this case, we need to reconnect manually. 582 | */ 583 | case 'PNTimeoutCategory': { 584 | console.warn('pubnub connection Failed by timeout.'); 585 | await reconnect(); 586 | break; 587 | } 588 | 589 | /** 590 | * When connection failed due to network error. 591 | */ 592 | case 'PNNetworkDownCategory': 593 | case 'PNNetworkIssuesCategory': { 594 | console.error('pubnub connection network error', status); 595 | await reconnect(); 596 | break; 597 | } 598 | 599 | /** 600 | * This will be called when token is expired. 601 | */ 602 | case 'PNAccessDeniedCategory': { 603 | console.error('pubnub access denied', status); 604 | await reconnect(); 605 | break; 606 | } 607 | 608 | /** 609 | * This will not be called. 610 | * Maybe pubnub-library is not implement these events. 611 | */ 612 | case 'PNBadRequestCategory': 613 | case 'PNMalformedResponseCategory': 614 | case 'PNDecryptionErrorCategory': { 615 | console.error('pubnub connection failed', status); 616 | break; 617 | } 618 | 619 | /** 620 | * This will not be called. 621 | * If this called, implement new handling for the event. 622 | */ 623 | default: { 624 | console.warn('default'); 625 | } 626 | } 627 | }, 628 | 629 | message: (data) => { 630 | if (data && data.message) { 631 | console.info('message received', JSON.stringify(data.message)); 632 | } 633 | }, 634 | }); 635 | 636 | return pubnub; 637 | } 638 | 639 | const getChannelAndToken = async () => { 640 | const nonce = new Date().getTime(); 641 | const timeWindow = '5000'; 642 | const message = `${nonce}${timeWindow}/v1/user/subscribe`; 643 | 644 | // Get channel and token from API 645 | const res = await fetch('https://api.bitbank.cc/v1/user/subscribe', { 646 | method: 'GET', 647 | headers: { 648 | 'Content-Type': 'application/json', 649 | 'ACCESS-KEY': API_KEY, 650 | 'ACCESS-REQUEST-TIME': nonce.toString(), 651 | 'ACCESS-TIME-WINDOW': timeWindow, 652 | 'ACCESS-SIGNATURE': toSha256(API_SECRET, message), 653 | }, 654 | }).then((res) => res.json()); 655 | 656 | const channel = res.data.pubnub_channel; 657 | const token = res.data.pubnub_token; 658 | return { channel, token }; 659 | } 660 | 661 | const subscribePrivateChannel = (pubnub, channel, token) => { 662 | pubnub.setToken(token); 663 | pubnub.subscribe({ 664 | channels: [channel], 665 | }); 666 | } 667 | 668 | const reconnect = async () => { 669 | // Reconnect to pubnub 670 | const { channel, token } = await getChannelAndToken(); 671 | const pubnub = getPubNubAndAddListener(channel, token); 672 | 673 | subscribePrivateChannel(pubnub, channel, token); 674 | } 675 | 676 | main().catch(console.error); 677 | ``` -------------------------------------------------------------------------------- /public-api.md: -------------------------------------------------------------------------------- 1 | [日本語](public-api_JP.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [Public REST API for Bitbank](#public-rest-api-for-bitbank) 8 | - [General API Information](#general-api-information) 9 | - [General endpoints](#general-endpoints) 10 | - [Ticker](#ticker) 11 | - [Tickers](#tickers) 12 | - [TickersJPY](#tickersjpy) 13 | - [Depth](#depth) 14 | - [In circuit_break_info.mode is `NONE` or estimated price is null](#in-circuit_break_infomode-is-none-or-estimated-price-is-null) 15 | - [In circuit_break_info.mode is not `NONE` and estimated price is not null](#in-circuit_break_infomode-is-not-none-and-estimated-price-is-not-null) 16 | - [Transactions](#transactions) 17 | - [Candlestick](#candlestick) 18 | - [Circuit Break Info](#circuit-break-info) 19 | 20 | 21 | 22 | # Public REST API for Bitbank 23 | 24 | ## General API Information 25 | 26 | - The base endpoint is: **[https://public.bitbank.cc](https://public.bitbank.cc)** 27 | - HTTP `4XX` return codes are used for malformed requests; the issue is on the sender's side. 28 | - Any endpoint can return an ERROR; the error payload is as follows: 29 | 30 | ```json 31 | { 32 | "success": 0, 33 | "data": { 34 | "code": 10000 35 | } 36 | } 37 | ``` 38 | 39 | ## General endpoints 40 | 41 | ### Ticker 42 | 43 | Get Ticker information 44 | 45 | Except for continuous trading mode, it may be the case that sell <= buy. 46 | 47 | ```txt 48 | GET /{pair}/ticker 49 | ``` 50 | 51 | **Parameters:** 52 | 53 | Name | Type | Mandatory | Description 54 | ------------ | ------------ | ------------ | ------------ 55 | pair | string | YES | pair enum: [pair list](pairs.md) 56 | 57 | **Response:** 58 | 59 | Name | Type | Description 60 | ------------ | ------------ | ------------ 61 | sell | string | the lowest price of sell orders 62 | buy | string | the highest price of buy orders 63 | high | string | the highest price in last 24 hours 64 | low | string | the lowest price in last 24 hours 65 | open | string | the open price at 24 hours ago 66 | last | string | the latest price executed 67 | vol | string | trading volume in last 24 hours 68 | timestamp | number | ticked at unix timestamp (milliseconds) 69 | 70 | **Response format:** 71 | 72 | ```json 73 | { 74 | "success": 1, 75 | "data": { 76 | "sell": "string", 77 | "buy": "string", 78 | "high": "string", 79 | "low": "string", 80 | "open": "string", 81 | "last": "string", 82 | "vol": "string", 83 | "timestamp": 0 84 | } 85 | } 86 | ``` 87 | 88 | ### Tickers 89 | 90 | Get All Tickers information 91 | 92 | Except for continuous trading mode, it may be the case that sell <= buy. 93 | 94 | ```txt 95 | GET /tickers 96 | ``` 97 | 98 | **Parameters:** 99 | 100 | nothing 101 | 102 | **Response:** 103 | 104 | Name | Type | Description 105 | ------------ | ------------ | ------------ 106 | pair | string | pair enum: [pair list](pairs.md) 107 | sell | string | the lowest price of sell orders 108 | buy | string | the highest price of buy orders 109 | high | string | the highest price in last 24 hours 110 | low | string | the lowest price in last 24 hours 111 | open | string | the open price at 24 hours ago 112 | last | string | the latest price executed 113 | vol | string | trading volume in last 24 hours 114 | timestamp | number | ticked at unix timestamp (milliseconds) 115 | 116 | **Response format:** 117 | 118 | ```json 119 | { 120 | "success": 1, 121 | "data": [{ 122 | "pair": "string", 123 | "sell": "string", 124 | "buy": "string", 125 | "high": "string", 126 | "low": "string", 127 | "open": "string", 128 | "last": "string", 129 | "vol": "string", 130 | "timestamp": 0 131 | }] 132 | } 133 | ``` 134 | 135 | ### TickersJPY 136 | 137 | Get All JPY Pair Tickers information 138 | 139 | Except for continuous trading mode, it may be the case that sell <= buy. 140 | 141 | ```txt 142 | GET /tickers_jpy 143 | ``` 144 | 145 | **Parameters:** 146 | 147 | nothing 148 | 149 | **Response:** 150 | 151 | Name | Type | Description 152 | ------------ | ------------ | ------------ 153 | pair | string | JPY pair enum: [pair list](pairs.md) 154 | sell | string | the lowest price of sell orders 155 | buy | string | the highest price of buy orders 156 | high | string | the highest price in last 24 hours 157 | low | string | the lowest price in last 24 hours 158 | open | string | the open price at 24 hours ago 159 | last | string | the latest price executed 160 | vol | string | trading volume in last 24 hours 161 | timestamp | number | ticked at unix timestamp (milliseconds) 162 | 163 | **Response format:** 164 | 165 | ```json 166 | { 167 | "success": 1, 168 | "data": [{ 169 | "pair": "string", 170 | "sell": "string", 171 | "buy": "string", 172 | "high": "string", 173 | "low": "string", 174 | "open": "string", 175 | "last": "string", 176 | "vol": "string", 177 | "timestamp": 0 178 | }] 179 | } 180 | ``` 181 | 182 | ### Depth 183 | 184 | Get Depth information. 185 | 186 | #### In circuit_break_info.mode is `NONE` or estimated price is null 187 | 188 | - Asks and bids data is restricted to 200 entries each from best bid offer. 189 | - Asks and bids price never cross. 190 | 191 | #### In circuit_break_info.mode is not `NONE` and estimated price is not null 192 | 193 | - Asks and bids data is restricted to 200 entries each around the estimated price. (Max 400 entries) 194 | - Asks and bids price possibly cross. 195 | - asks_under, bids_over possibly includes the quantity of orders which price is out of range. 196 | 197 | ```txt 198 | GET /{pair}/depth 199 | ``` 200 | 201 | **Parameters:** 202 | 203 | Name | Type | Mandatory | Description 204 | ------------ | ------------ | ------------ | ------------ 205 | pair | string | YES | pair enum: [pair list](pairs.md) 206 | 207 | **Response:** 208 | 209 | Name | Type | Description 210 | ------------ | ------------ | ------------ 211 | asks | [string, string][] | array of [price, amount] 212 | bids | [string, string][] | array of [price, amount] 213 | asks_over | string | the quantity of asks over the highest price of asks orders. 214 | bids_under | string | the quantity of bids under the lowest price of bids orders. 215 | asks_under | string | the quantity of asks under the lowest price of asks orders. Usually "0" in `NORMAL` mode. 216 | bids_over | string | the quantity of bids over the highest price of bids orders. Usually "0" in `NORMAL` mode. 217 | ask_market | string | the quantity of market sell orders. Usually "0" in `NORMAL` mode. 218 | bid_market | string | the quantity of market buy orders. Usually "0" in `NORMAL` mode. 219 | timestamp | number | published at timestamp 220 | sequenceId | number | sequence id, increased monotonically but not always consecutive 221 | 222 | **Response format:** 223 | 224 | ```json 225 | { 226 | "success": 1, 227 | "data": { 228 | "asks": [ 229 | [ 230 | "string", "string" 231 | ] 232 | ], 233 | "bids": [ 234 | [ 235 | "string", "string" 236 | ] 237 | ], 238 | "asks_over": "string", 239 | "bids_under": "string", 240 | "asks_under": "string", 241 | "bids_over": "string", 242 | "ask_market": "string", 243 | "bid_market": "string", 244 | "timestamp": 0, 245 | "sequenceId": "string" 246 | } 247 | } 248 | ``` 249 | 250 | ### Transactions 251 | 252 | Get latest executed transactions. If you omit YYYYMMDD, you can get the latest 60. 253 | 254 | ```txt 255 | GET /{pair}/transactions/{YYYYMMDD} 256 | ``` 257 | 258 | **Parameters:** 259 | 260 | Name | Type | Mandatory | Description 261 | ------------ | ------------ | ------------ | ------------ 262 | pair | string | YES | pair enum: [pair list](pairs.md) 263 | YYYYMMDD | string | NO | date formatted as `YYYYMMDD` 264 | 265 | **Response:** 266 | 267 | Name | Type | Description 268 | ------------ | ------------ | ------------ 269 | transaction_id | number | transaction id 270 | side | string | enum: `buy`, `sell` 271 | price | string | price 272 | amount | string | amount 273 | executed_at | number | executed at unix timestamp (milliseconds) 274 | 275 | **Response format:** 276 | 277 | ```json 278 | { 279 | "success": 1, 280 | "data": { 281 | "transactions": [ 282 | { 283 | "transaction_id": 0, 284 | "side": "string", 285 | "price": "string", 286 | "amount": "string", 287 | "executed_at": 0 288 | } 289 | ] 290 | } 291 | } 292 | ``` 293 | 294 | ### Candlestick 295 | 296 | Get candlestick information. 297 | 298 | ```txt 299 | GET /{pair}/candlestick/{candle-type}/{YYYY} 300 | ``` 301 | 302 | **Parameters:** 303 | 304 | Name | Type | Mandatory | Description 305 | ------------ | ------------ | ------------ | ------------ 306 | pair | string | YES | pair enum: [pair list](pairs.md) 307 | candle-type | string | YES | candle type enum: `1min`, `5min`, `15min`, `30min`, `1hour`, `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` 308 | YYYY | string | YES | date formatted as `YYYY` or `YYYYMMDD` 309 | 310 | - YYYY Format depends on the candle-type: 311 | - `YYYYMMDD`: `1min`, `5min`, `15min`, `30min`, `1hour` 312 | - `YYYY`: `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` 313 | 314 | **Response:** 315 | 316 | Name | Type | Description 317 | ------------ | ------------ | ------------ 318 | type | string | candle type enum: `1min`, `5min`, `15min`, `30min`, `1hour`, `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` 319 | ohlcv | [string, string, string, string, string, number][] | [open, high, low, close, volume, **unix timestamp (milliseconds)**] 320 | 321 | **Response format:** 322 | 323 | ```json 324 | { 325 | "success": 1, 326 | "data": { 327 | "candlestick": [ 328 | { 329 | "type": "string", 330 | "ohlcv": [ 331 | [ 332 | "string", 333 | "string", 334 | "string", 335 | "string", 336 | "string", 337 | 0 338 | ] 339 | ] 340 | } 341 | ] 342 | } 343 | } 344 | ``` 345 | 346 | ### Circuit Break Info 347 | 348 | Get circuit break informations. 349 | 350 | ```txt 351 | GET /{pair}/circuit_break_info 352 | ``` 353 | 354 | **Parameters:** 355 | 356 | Name | Type | Mandatory | Description 357 | ------------ | ------------ | ------------ | ------------ 358 | pair | string | YES | pair enum: [pair list](pairs.md) 359 | 360 | **Response:** 361 | 362 | Name | Type | Description 363 | ------------ | ------------ | ------------ 364 | mode | string | enum: `NONE`, `CIRCUIT_BREAK`, `FULL_RANGE_CIRCUIT_BREAK`, `RESUMPTION`, `LISTING` 365 | estimated_itayose_price | string \| null | estimated price. Null if mode is `NONE` or when there is no estimated price. 366 | estimated_itayose_amount | string \| null | estimated amount. Null if mode is `NONE`. 367 | itayose_upper_price | string \| null | itayose price range upper limit. Null if mode is in `NONE`, `FULL_RANGE_CIRCUIT_BREAK` or `LISTING`. 368 | itayose_lower_price | string \| null | itayose price range lower limit. Null if mode is in `NONE`, `FULL_RANGE_CIRCUIT_BREAK` or `LISTING`. 369 | upper_trigger_price | string \| null | upper trigger price. Null if mode is not `NONE`. 370 | lower_trigger_price | string \| null | lower trigger price. Null if mode is not `NONE`. 371 | fee_type | string | enum: `NORMAL`, `SELL_MAKER`, `BUY_MAKER`, `DYNAMIC` 372 | reopen_timestamp | number \| null | reopen timestamp(milliseconds). Null if mode is `NONE`, or reopen timestamp is undetermined yet. 373 | timestamp | number | ticked at unix timestamp (milliseconds) 374 | 375 | For details on `mode` and `fee_type`, please check the [Circuit breaker system](https://bitbank.cc/docs/circuit-breaker-mode/) page. 376 | 377 | **Response format:** 378 | 379 | ```json 380 | { 381 | "success": 1, 382 | "data": { 383 | "mode": "string", 384 | "estimated_itayose_price": "string", 385 | "estimated_itayose_amount": "string", 386 | "itayose_upper_price": "string", 387 | "itayose_lower_price": "string", 388 | "upper_trigger_price": "string", 389 | "lower_trigger_price": "string", 390 | "fee_type": "string", 391 | "reopen_timestamp": 0, 392 | "timestamp": 0 393 | } 394 | } 395 | ``` 396 | -------------------------------------------------------------------------------- /public-api_JP.md: -------------------------------------------------------------------------------- 1 | [English](public-api.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [Public API一覧](#public-api%E4%B8%80%E8%A6%A7) 8 | - [API 概要](#api-%E6%A6%82%E8%A6%81) 9 | - [エンドポイント一覧](#%E3%82%A8%E3%83%B3%E3%83%89%E3%83%9D%E3%82%A4%E3%83%B3%E3%83%88%E4%B8%80%E8%A6%A7) 10 | - [ティッカー](#%E3%83%86%E3%82%A3%E3%83%83%E3%82%AB%E3%83%BC) 11 | - [Tickers](#tickers) 12 | - [TickersJPY](#tickersjpy) 13 | - [Depth](#depth) 14 | - [circuit_break_info.modeが `NONE` もしくは 見積価格がNull の場合](#circuit_break_infomode%E3%81%8C-none-%E3%82%82%E3%81%97%E3%81%8F%E3%81%AF-%E8%A6%8B%E7%A9%8D%E4%BE%A1%E6%A0%BC%E3%81%8Cnull-%E3%81%AE%E5%A0%B4%E5%90%88) 15 | - [circuit_break_info.modeが `NONE` 以外 かつ 見積価格が存在する 場合](#circuit_break_infomode%E3%81%8C-none-%E4%BB%A5%E5%A4%96-%E3%81%8B%E3%81%A4-%E8%A6%8B%E7%A9%8D%E4%BE%A1%E6%A0%BC%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%99%E3%82%8B-%E5%A0%B4%E5%90%88) 16 | - [約定履歴](#%E7%B4%84%E5%AE%9A%E5%B1%A5%E6%AD%B4) 17 | - [Candlestick](#candlestick) 18 | - [サーキットブレイク情報](#%E3%82%B5%E3%83%BC%E3%82%AD%E3%83%83%E3%83%88%E3%83%96%E3%83%AC%E3%82%A4%E3%82%AF%E6%83%85%E5%A0%B1) 19 | 20 | 21 | 22 | # Public API一覧 23 | 24 | ## API 概要 25 | 26 | - エンドポイント URL: **[https://public.bitbank.cc](https://public.bitbank.cc)** 27 | - リクエストに不正がある場合、HTTPステータス `4XX` を返します。 28 | - リクエストに不正がある場合、以下のようなエラーレスポンスを返します。 29 | 30 | ```json 31 | { 32 | "success": 0, 33 | "data": { 34 | "code": 10000 35 | } 36 | } 37 | ``` 38 | 39 | ## エンドポイント一覧 40 | 41 | ### ティッカー 42 | 43 | [Public API] ティッカー情報を取得。 44 | 45 | 通常モード以外の場合、sell <= buy となる場合があります。 46 | 47 | ```txt 48 | GET /{pair}/ticker 49 | ``` 50 | 51 | **Parameters:** 52 | 53 | Name | Type | Mandatory | Description 54 | ------------ | ------------ | ------------ | ------------ 55 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 56 | 57 | **Response:** 58 | 59 | Name | Type | Description 60 | ------------ | ------------ | ------------ 61 | sell | string | 現在の売り注文の最安値 62 | buy | string | 現在の買い注文の最高値 63 | high | string | 過去24時間の最高値取引価格 64 | low | string | 過去24時間の最安値取引価格 65 | open | string | 24時間前の始値 66 | last | string | 最新取引価格 67 | vol | string | 過去24時間の出来高 68 | timestamp | number | 日時(UnixTimeのミリ秒) 69 | 70 | **レスポンスのフォーマット:** 71 | 72 | ```json 73 | { 74 | "success": 1, 75 | "data": { 76 | "sell": "string", 77 | "buy": "string", 78 | "high": "string", 79 | "low": "string", 80 | "open": "string", 81 | "last": "string", 82 | "vol": "string", 83 | "timestamp": 0 84 | } 85 | } 86 | ``` 87 | 88 | ### Tickers 89 | 90 | [Public API] 全ペアのティッカー情報を取得。 91 | 92 | 通常モード以外の場合、sell <= buy となる場合があります。 93 | 94 | ```txt 95 | GET /tickers 96 | ``` 97 | 98 | **Parameters:** 99 | 100 | なし 101 | 102 | **Response:** 103 | 104 | Name | Type | Description 105 | ------------ | ------------ | ------------ 106 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 107 | sell | string | 現在の売り注文の最安値 108 | buy | string | 現在の買い注文の最高値 109 | high | string | 過去24時間の最高値取引価格 110 | low | string | 過去24時間の最安値取引価格 111 | open | string | 24時間前の始値 112 | last | string | 最新取引価格 113 | vol | string | 過去24時間の出来高 114 | timestamp | number | 日時(UnixTimeのミリ秒) 115 | 116 | **レスポンスのフォーマット:** 117 | 118 | ```json 119 | { 120 | "success": 1, 121 | "data": [{ 122 | "pair": "string", 123 | "sell": "string", 124 | "buy": "string", 125 | "high": "string", 126 | "low": "string", 127 | "open": "string", 128 | "last": "string", 129 | "vol": "string", 130 | "timestamp": 0 131 | }] 132 | } 133 | ``` 134 | 135 | ### TickersJPY 136 | 137 | [Public API] JPYペアのティッカー情報を取得。 138 | 139 | 通常モード以外の場合、sell <= buy となる場合があります。 140 | 141 | ```txt 142 | GET /tickers_jpy 143 | ``` 144 | 145 | **Parameters:** 146 | 147 | なし 148 | 149 | **Response:** 150 | 151 | Name | Type | Description 152 | ------------ | ------------ | ------------ 153 | pair | string | 通貨ペア(JPYペアのみ): [ペア一覧](pairs.md) 154 | sell | string | 現在の売り注文の最安値 155 | buy | string | 現在の買い注文の最高値 156 | high | string | 過去24時間の最高値取引価格 157 | low | string | 過去24時間の最安値取引価格 158 | open | string | 24時間前の始値 159 | last | string | 最新取引価格 160 | vol | string | 過去24時間の出来高 161 | timestamp | number | 日時(UnixTimeのミリ秒) 162 | 163 | **レスポンスのフォーマット:** 164 | 165 | ```json 166 | { 167 | "success": 1, 168 | "data": [{ 169 | "pair": "string", 170 | "sell": "string", 171 | "buy": "string", 172 | "high": "string", 173 | "low": "string", 174 | "open": "string", 175 | "last": "string", 176 | "vol": "string", 177 | "timestamp": 0 178 | }] 179 | } 180 | ``` 181 | 182 | ### Depth 183 | 184 | [Public API] 板情報を取得。 185 | 186 | #### circuit_break_info.modeが `NONE` もしくは 見積価格がNull の場合 187 | 188 | - asks, bidsで配信されるデータは、Best Bid Offerから200件ずつです。 189 | - したがって、asks, bidsのBBO(Best Bid Offer)は必ず `最も安いAsk > 最も高いBid` となります。 190 | 191 | #### circuit_break_info.modeが `NONE` 以外 かつ 見積価格が存在する 場合 192 | 193 | - asks, bidsで配信されるデータは、見積価格から上下200件ずつです。(最大400件) 194 | - したがって、通常時とは異なり、 `最も安いAsk < 最も高いBid` となる場合があります。 195 | - また、配信データの価格範囲よりも安い売り注文は `asks_under` に、高い買い注文は `bids_over` に加算されます。 196 | 197 | ```txt 198 | GET /{pair}/depth 199 | ``` 200 | 201 | **Parameters:** 202 | 203 | Name | Type | Mandatory | Description 204 | ------------ | ------------ | ------------ | ------------ 205 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 206 | 207 | **Response:** 208 | 209 | Name | Type | Description 210 | ------------ | ------------ | ------------ 211 | asks | [string, string][] | 売り板 [価格, 数量] 212 | bids | [string, string][] | 買い板 [価格, 数量] 213 | asks_over | string | asksの最高値(asks配列の一番最後の要素)よりも高いasksの数量 214 | bids_under | string | bidsの最安値(bids配列の一番最後の要素)よりも安いbidsの数量 215 | asks_under | string | bidsの最安値(bids配列の一番最後の要素)よりも安いasksの数量。通常モードの場合は `0` 216 | bids_over | string | asksの最高値(asks配列の一番最後の要素)よりも高いbidsの数量。通常モードの場合は `0` 217 | ask_market | string | 成行売り数量。通常モードの場合は `0` 218 | bid_market | string | 成行買い数量。通常モードの場合は `0` 219 | timestamp | number | timestamp 220 | sequenceId | number | シーケンスID、単調増加しますが連続しているとは限りません 221 | 222 | **レスポンスのフォーマット:** 223 | 224 | ```json 225 | { 226 | "success": 1, 227 | "data": { 228 | "asks": [ 229 | [ 230 | "string", "string" 231 | ] 232 | ], 233 | "bids": [ 234 | [ 235 | "string", "string" 236 | ] 237 | ], 238 | "asks_over": "string", 239 | "bids_under": "string", 240 | "asks_under": "string", 241 | "bids_over": "string", 242 | "ask_market": "string", 243 | "bid_market": "string", 244 | "timestamp": 0, 245 | "sequenceId": "string" 246 | } 247 | } 248 | ``` 249 | 250 | ### 約定履歴 251 | 252 | [Public API] 指定された日付の全約定履歴を取得。YYYYMMDDを省略した場合、最新60件が取得可能。 253 | 254 | ```txt 255 | GET /{pair}/transactions/{YYYYMMDD} 256 | ``` 257 | 258 | **Parameters:** 259 | 260 | Name | Type | Mandatory | Description 261 | ------------ | ------------ | ------------ | ------------ 262 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 263 | YYYYMMDD | string | NO | date formatted as `YYYYMMDD` 264 | 265 | **Response:** 266 | 267 | Name | Type | Description 268 | ------------ | ------------ | ------------ 269 | transaction_id | number | 取引ID 270 | side | string | `buy` または `sell` 271 | price | string | 価格 272 | amount | string | 数量 273 | executed_at | number | 約定日時(UnixTimeのミリ秒) 274 | 275 | **レスポンスのフォーマット:** 276 | 277 | ```json 278 | { 279 | "success": 1, 280 | "data": { 281 | "transactions": [ 282 | { 283 | "transaction_id": 0, 284 | "side": "string", 285 | "price": "string", 286 | "amount": "string", 287 | "executed_at": 0 288 | } 289 | ] 290 | } 291 | } 292 | ``` 293 | 294 | ### Candlestick 295 | 296 | [Public API] 指定された日付のロウソク足データを取得。 297 | 298 | ```txt 299 | GET /{pair}/candlestick/{candle-type}/{YYYY} 300 | ``` 301 | 302 | **Parameters:** 303 | 304 | Name | Type | Mandatory | Description 305 | ------------ | ------------ | ------------ | ------------ 306 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 307 | candle-type | string | YES | 以下の期間から指定: `1min`, `5min`, `15min`, `30min`, `1hour`, `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` 308 | YYYY | string | YES | 日付 `YYYYMMDD` 形式または `YYYY` を指定 309 | 310 | - YYYY の指定は candle-type によって異なります: 311 | - `YYYYMMDD`: `1min`, `5min`, `15min`, `30min`, `1hour` 312 | - `YYYY`: `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` 313 | 314 | **Response:** 315 | 316 | Name | Type | Description 317 | ------------ | ------------ | ------------ 318 | type | string | 以下の期間から指定: `1min`, `5min`, `15min`, `30min`, `1hour`, `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` 319 | ohlcv | [string, string, string, string, string, number][] | [始値, 高値, 安値, 終値, 出来高, **UnixTimeのミリ秒**] 320 | 321 | **レスポンスのフォーマット:** 322 | 323 | ```json 324 | { 325 | "success": 1, 326 | "data": { 327 | "candlestick": [ 328 | { 329 | "type": "string", 330 | "ohlcv": [ 331 | [ 332 | "string", 333 | "string", 334 | "string", 335 | "string", 336 | "string", 337 | 0 338 | ] 339 | ] 340 | } 341 | ] 342 | } 343 | } 344 | ``` 345 | 346 | ### サーキットブレイク情報 347 | 348 | [Public API] サーキットブレイク情報を取得。 349 | 350 | ```txt 351 | GET /{pair}/circuit_break_info 352 | ``` 353 | 354 | **Parameters:** 355 | 356 | Name | Type | Mandatory | Description 357 | ------------ | ------------ | ------------ | ------------ 358 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 359 | 360 | **Response:** 361 | 362 | Name | Type | Description 363 | ------------ | ------------ | ------------ 364 | mode | string | `NONE` または `CIRCUIT_BREAK` または `FULL_RANGE_CIRCUIT_BREAK` または `RESUMPTION` または `LISTING` 365 | estimated_itayose_price | string \| null | 見積価格。通常モードまたは見積価格が無い場合はnull 366 | estimated_itayose_amount | string \| null | 見積数量。通常モードであればnull 367 | itayose_upper_price | string \| null | CB時制限値幅価格上限。通常モード、無期限サーキットブレイクモード、新規上場モードはnull 368 | itayose_lower_price | string \| null | CB時制限値幅価格下限。通常モード、無期限サーキットブレイクモード、新規上場モードはnull 369 | upper_trigger_price | string \| null | CB突入判定価格上限。CB中はnull 370 | lower_trigger_price | string \| null | CB突入判定価格下限。CB中はnull 371 | fee_type | string | `NORMAL` または `SELL_MAKER` または `BUY_MAKER` または `DYNAMIC` 372 | reopen_timestamp | number \| null | サーキットブレイク終了予定時刻(UnixTimeのミリ秒)。通常モード、またはCB終了予定時刻がない場合はnull 373 | timestamp | number | 日時(UnixTimeのミリ秒) 374 | 375 | `mode` および `fee_type` の詳細は[サーキットブレーカー制度](https://bitbank.cc/docs/circuit-breaker-mode/)のページをご確認ください。 376 | 377 | **レスポンスのフォーマット:** 378 | 379 | ```json 380 | { 381 | "success": 1, 382 | "data": { 383 | "mode": "string", 384 | "estimated_itayose_price": "string", 385 | "estimated_itayose_amount": "string", 386 | "itayose_upper_price": "string", 387 | "itayose_lower_price": "string", 388 | "upper_trigger_price": "string", 389 | "lower_trigger_price": "string", 390 | "fee_type": "string", 391 | "reopen_timestamp": 0, 392 | "timestamp": 0 393 | } 394 | } 395 | ``` 396 | -------------------------------------------------------------------------------- /public-stream.md: -------------------------------------------------------------------------------- 1 | [日本語](public-stream_JP.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [Web Socket Streams for Bitbank](#web-socket-streams-for-bitbank) 8 | - [General WSS information](#general-wss-information) 9 | - [General endpoints](#general-endpoints) 10 | - [Ticker](#ticker) 11 | - [Transactions](#transactions) 12 | - [Depth Diff](#depth-diff) 13 | - [Depth Whole](#depth-whole) 14 | - [In circuit_break_info.mode is `NONE` or estimated price is null](#in-circuit_break_infomode-is-none-or-estimated-price-is-null) 15 | - [In circuit_break_info.mode is not `NONE` and estimated price is not null](#in-circuit_break_infomode-is-not-none-and-estimated-price-is-not-null) 16 | - [Circuit Break Info](#circuit-break-info) 17 | - [How to manage a local order book correctly](#how-to-manage-a-local-order-book-correctly) 18 | 19 | 20 | 21 | # Web Socket Streams for Bitbank 22 | 23 | ## General WSS information 24 | 25 | - The base endpoint is: **wss://stream.bitbank.cc**. 26 | - [socket.io 4.x](https://socket.io/docs/v4/) (Engine.io protocol v4) is used under the hood, and the following code examples are demonstrated with [github.com/websockets/wscat](https://github.com/websockets/wscat) 27 | - From 2022-07-26, [socket.io](https://socket.io/) is upgraded from [2.x](https://socket.io/docs/v2/) to [4.x](https://socket.io/docs/v4/) 28 | - The specification of disconnection after 6 hours is abolished. Continuously, if an error occurs the connection will be closed. Please check the error messages. 29 | 30 | ## General endpoints 31 | 32 | ### Ticker 33 | 34 | Ticker channel name is `ticker_{pair}`, available pairs are written in [pair list](pairs.md). 35 | 36 | Except for continuous trading mode, it may be the case that sell <= buy. 37 | 38 | **Response:** 39 | 40 | Name | Type | Description 41 | ------------ | ------------ | ------------ 42 | sell | string | the lowest price of sell orders 43 | buy | string | the highest price of buy orders 44 | high | string | the highest price in last 24 hours 45 | low | string | the lowest price in last 24 hours 46 | open | string | the open price at 24 hours ago 47 | last | string | the latest price executed 48 | vol | string | trading volume in last 24 hours 49 | timestamp | number | ticked at unix timestamp (milliseconds) 50 | 51 | **Sample code:** 52 | 53 |
54 | wscat 55 |

56 | 57 | ```sh 58 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 59 | 60 | connected (press CTRL+C to quit) 61 | < 0{"sid":"bDAf6vgk5xPau87WAA1u","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 62 | > 40 63 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 64 | > 42["join-room","ticker_btc_jpy"] 65 | < 42["message",{"room_name":"ticker_btc_jpy","message":{"pid":851203833,"data":{"sell":"896490","buy":"896489","open":"896489","high":"905002","low":"881500","last":"896489","vol":"650.2026","timestamp":1570080042822}}}] 66 | < 42["message",{"room_name":"ticker_btc_jpy","message":{"pid":851203952,"data":{"sell":"896490","buy":"896489","open":"896489","high":"905002","low":"881500","last":"896489","vol":"650.2226","timestamp":1570080053768}}}] 67 | ... 68 | 69 | ``` 70 | 71 |

72 |
73 | 74 | **Response format:** 75 | 76 | ```json 77 | [ 78 | "message", 79 | { 80 | "room_name": "ticker_btc_jpy", 81 | "message": { 82 | "pid": 0, 83 | "data": { 84 | "last": "string", 85 | "open": "string", 86 | "timestamp": 0, 87 | "sell": "string", 88 | "vol": "string", 89 | "buy": "string", 90 | "high": "string", 91 | "low": "string" 92 | } 93 | } 94 | } 95 | ] 96 | ``` 97 | 98 | ### Transactions 99 | 100 | Transactions channel name is `transactions_{pair}`, available pairs are written in [pair list](pairs.md). 101 | 102 | **Response:** 103 | 104 | Name | Type | Description 105 | ------------ | ------------ | ------------ 106 | transaction_id | number | transaction id 107 | side | string | enum: `buy`, `sell` 108 | price | string | price 109 | amount | string | amount 110 | executed_at | number | executed at unix timestamp (milliseconds) 111 | 112 | **Sample code:** 113 | 114 |
115 | wscat 116 |

117 | 118 | ```sh 119 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 120 | 121 | connected (press CTRL+C to quit) 122 | < 0{"sid":"PG3FbI0WrKIP7hKMABH_","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 123 | > 40 124 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 125 | > 42["join-room","transactions_xrp_jpy"] 126 | < 42["message",{"room_name":"transactions_xrp_jpy","message":{"pid":851205254,"data":{"transactions":[{"transaction_id":34745047,"side":"sell","price":"26.930","amount":"4703.5671","executed_at":1570080162855},{"transaction_id":34745046,"side":"sell","price":"26.930","amount":"500.0000","executed_at":1570080162829},{"transaction_id":34745045,"side":"sell","price":"26.930","amount":"378.0000","executed_at":1570080162802},{"transaction_id":34745044,"side":"sell","price":"26.930","amount":"12.0000","executed_at":1570080162758},{"transaction_id":34745043,"side":"sell","price":"26.930","amount":"301.4874","executed_at":1570080162725}]}}}] 127 | ... 128 | 129 | ``` 130 | 131 |

132 |
133 | 134 | **Response format:** 135 | 136 | ```json 137 | [ 138 | "message", 139 | { 140 | "room_name": "transactions_btc_jpy", 141 | "message": { 142 | "pid": 0, 143 | "data": { 144 | "transactions": [ 145 | { 146 | "side": "string", 147 | "executed_at": 0, 148 | "amount": "string", 149 | "price": "string", 150 | "transaction_id": 0 151 | } 152 | ] 153 | } 154 | } 155 | } 156 | ] 157 | ``` 158 | 159 | ### Depth Diff 160 | 161 | Depth Diff channel name is `depth_diff_{pair}`, available pairs are written in [pair list](pairs.md). 162 | 163 | Except for continuous trading mode, it may be the case that a <= b. 164 | 165 | **Response:** 166 | 167 | Name | Type | Description 168 | ------------ | ------------ | ------------ 169 | a | [string, string][] | [ask, amount][] 170 | b | [string, string][] | [bid, amount][] 171 | ao | string \| undefined | optional. The quantity of asks over the highest price of [asks orders](#Depth-Whole). If there is no change in quantity, it will not be included in the message. 172 | bu | string \| undefined | optional. The quantity of bids under the lowest price of [bids orders](#Depth-Whole). If there is no change in quantity, it will not be included in the message. 173 | au | string \| undefined | optional. The quantity of asks under the lowest price of [bids orders](#Depth-Whole) orders. If there is no change in quantity, it will not be included in the message. 174 | bo | string \| undefined | optional. The quantity of bids over the highest price of [asks orders](#Depth-Whole). If there is no change in quantity, it will not be included in the message. 175 | am | string \| undefined | optional. The quantity of market sell orders. If there is no change in quantity, it will not be included in the message. 176 | bm | string \| undefined | optional. The quantity of market buy orders. If there is no change in quantity, it will not be included in the message. 177 | t | number | published at unix timestamp (milliseconds) 178 | s | string | sequence id, increased monotonically but not always consecutive 179 | 180 | The amount of `a` (asks) and `b` (bids) is absolute, and its 0 means its price level has gone. 181 | 182 | The `s` (sequence id) is common with the `sequenceId` of `depth_whole_{pair}`. 183 | 184 | For usage, see [How to manage a local order book correctly](#how-to-manage-a-local-order-book-correctly) section. 185 | 186 | **Sample code:** 187 | 188 |
189 | wscat 190 |

191 | 192 | ```sh 193 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 194 | connected (press CTRL+C to quit) 195 | < 0{"sid":"9-zd3P1G-BNu_w37ABMX","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 196 | > 40 197 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 198 | > 42["join-room","depth_diff_xrp_jpy"] 199 | < 42["message",{"room_name":"depth_diff_xrp_jpy","message":{"data":{"a":[],"b":[["26.758","20000.0000"],["26.212","0"]],"t":1570080269609,"s":"1234567890"}}}] 200 | < 42["message",{"room_name":"depth_diff_xrp_jpy","message":{"data":{"a":[],"b":[["26.212","1000.0000"],["26.815","0"]],"t":1570080270100,"s":"1234567893"}}}] 201 | ... 202 | 203 | ``` 204 | 205 |

206 |
207 | 208 | **Response format:** 209 | 210 | ```json 211 | [ 212 | "message", 213 | { 214 | "room_name": "depth_diff_xrp_jpy", 215 | "message": { 216 | "data": { 217 | "b": [ 218 | [ 219 | "26.872", 220 | "43.3989" 221 | ], 222 | [ 223 | "26.871", 224 | "100.0000" 225 | ], 226 | ], 227 | "a": [ 228 | [ 229 | "27.839", 230 | "1634.3980" 231 | ], 232 | [ 233 | "28.450", 234 | "0" 235 | ] 236 | ], 237 | "ao": "1", 238 | "bu": "1", 239 | "am": "1", 240 | "bm": "1", 241 | "t": 1568344204624, 242 | "s": "1234567890" 243 | } 244 | } 245 | } 246 | ] 247 | ``` 248 | 249 | ### Depth Whole 250 | 251 | Whole depth channel name is `depth_whole_{pair}`, available pairs are written in [pair list](pairs.md). 252 | 253 | Except for continuous trading mode, it may be the case that asks <= bids. 254 | 255 | #### In circuit_break_info.mode is `NONE` or estimated price is null 256 | 257 | - Asks and bids data is restricted to 200 entries each from best bid offer. 258 | - Asks and bids price never cross. 259 | 260 | #### In circuit_break_info.mode is not `NONE` and estimated price is not null 261 | 262 | - Asks and bids data is restricted to 200 entries each around the estimated price. (Max 400 entries) 263 | - Asks and bids price possibly cross. 264 | - asks_under, bids_over possibly includes the quantity of orders which price is out of range. 265 | 266 | #### In circuit_break_info.mode is `NONE` or estimated price is null 267 | 268 | - Asks and bids data is restricted to 200 entries each from best bid offer. 269 | - Asks and bids price never cross. 270 | 271 | #### In circuit_break_info.mode is not `NONE` and estimated price is not null 272 | 273 | - Asks and bids data is restricted to 200 entries each around the estimated price. (Max 400 entries) 274 | - Asks and bids price possibly cross. 275 | - asks_under, bids_over possibly includes the quantity of orders which price is out of range. 276 | 277 | **Response:** 278 | 279 | Name | Type | Description 280 | ------------ | ------------ | ------------ 281 | asks | [string, string][] | array of [price, amount] 282 | bids | [string, string][] | array of [price, amount] 283 | asks_over | string | the quantity of asks over the highest price of asks orders. 284 | bids_under | string | the quantity of bids under the lowest price of bids orders. 285 | asks_under | string | the quantity of asks under the lowest price of asks orders. Usually "0" in `NORMAL` mode. 286 | bids_over | string | the quantity of bids over the highest price of bids orders. Usually "0" in `NORMAL` mode. 287 | ask_market | string | the quantity of market sell orders. Usually "0" in `NORMAL` mode. 288 | bid_market | string | the quantity of market buy orders. Usually "0" in `NORMAL` mode. 289 | timestamp | number | published at timestamp 290 | sequenceId | number | sequence id, increased monotonically but not always consecutive 291 | 292 | The `sequenceId` is common with the `s` of `depth_diff_{pair}`. 293 | 294 | For usage, see [How to manage a local order book correctly](#how-to-manage-a-local-order-book-correctly) section. 295 | 296 | **Sample code:** 297 | 298 |
299 | wscat 300 |

301 | 302 | ```sh 303 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 304 | connected (press CTRL+C to quit) 305 | < 0{"sid":"PR6GLrwlEFjzHIPrABBM","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 306 | > 40 307 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 308 | > 42["join-room","depth_whole_xrp_jpy"] 309 | < 42["message",{"room_name":"depth_whole_xrp_jpy","message":{"data":{"asks":[["26.928","1000.0000"],["26.929","56586.5153"],["26.930","218.3431"],["26.931","3123.8845"],["26.933","1799.0000"],["26.934","377.9136"],["26.938","3411.1507"],["26.950","80.0000"],["26.955","80.0000"],["26.958","7434.5900"],["26.959","15000.0000"],["26.960","15000.0000"],["26.964","10837.6620"],["26.979","15000.0000"], ...]}}}] 310 | 311 | ``` 312 | 313 |

314 |
315 | 316 | **Response format:** 317 | 318 | ```json 319 | [ 320 | "message", 321 | { 322 | "room_name": "depth_whole_xrp_jpy", 323 | "message": { 324 | "data": { 325 | "bids": [ 326 | [ 327 | "27.537", 328 | "6211.6210" 329 | ], 330 | [ 331 | "27.523", 332 | "875.3413" 333 | ], 334 | ], 335 | "asks": [ 336 | [ 337 | "27.538", 338 | "7233.6837" 339 | ], 340 | [ 341 | "27.540", 342 | "19.4551" 343 | ], 344 | ], 345 | "asks_over": "0.123", 346 | "bids_under": "0.123", 347 | "asks_under": "0", 348 | "bids_over": "0", 349 | "ask_market": "0", 350 | "bid_market": "0", 351 | "timestamp": 1568344476514, 352 | "sequenceId": "1234567890" 353 | } 354 | } 355 | } 356 | ] 357 | ``` 358 | 359 | ### Circuit Break Info 360 | 361 | Get circuit break informations. 362 | 363 | **Response:** 364 | 365 | Name | Type | Description 366 | ------------ | ------------ | ------------ 367 | mode | string | enum: `NONE`, `CIRCUIT_BREAK`, `FULL_RANGE_CIRCUIT_BREAK`, `RESUMPTION`, `LISTING` 368 | estimated_itayose_price | string \| null | estimated price. Null if mode is `NONE` or when there is no estimated price. 369 | estimated_itayose_amount | string \| null | estimated amount. Null if mode is `NONE`. 370 | itayose_upper_price | string \| null | itayose price range upper limit. Null if mode is in `NONE`, `FULL_RANGE_CIRCUIT_BREAK` or `LISTING`. 371 | itayose_lower_price | string \| null | itayose price range lower limit. Null if mode is in `NONE`, `FULL_RANGE_CIRCUIT_BREAK` or `LISTING`. 372 | upper_trigger_price | string \| null | upper trigger price. Null if mode is not `NONE`. 373 | lower_trigger_price | string \| null | lower trigger price. Null if mode is not `NONE`. 374 | fee_type | string | enum: `NORMAL`, `SELL_MAKER`, `BUY_MAKER`, `DYNAMIC` 375 | reopen_timestamp | number \| null | reopen timestamp(milliseconds). Null if mode is `NONE`, or reopen timestamp is undetermined yet. 376 | timestamp | number | ticked at unix timestamp (milliseconds) 377 | 378 | For details on `mode` and `fee_type`, please check the [Circuit breaker system](https://bitbank.cc/docs/circuit-breaker-mode/) page. 379 | 380 | **Sample code:** 381 | 382 |
383 | wscat 384 |

385 | 386 | ```sh 387 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 388 | 389 | connected (press CTRL+C to quit) 390 | < 0{"sid":"PG3FbI0WrKIP7hKMABH_","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 391 | > 40 392 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 393 | > 42["join-room","circuit_break_info_xrp_jpy"] 394 | < 42["message",{"room_name":"circuit_break_info_xrp_jpy","message":{"data":{"mode":"NONE","estimated_itayose_price":null,"estimated_itayose_amount":null,"itayose_upper_price":null,"itayose_lower_price":null,"upper_trigger_price":"1200000","lower_trigger_price":"800000","fee_type":"NORMAL","reopen_timestamp":null,"timestamp":1570080162855}}}] 395 | < 42["message",{"room_name":"circuit_break_info_xrp_jpy","message":{"data":{"mode":"CIRCUIT_BREAK","estimated_itayose_price":"1000000","estimated_itayose_amount":null,"itayose_upper_price":"1300000","itayose_lower_price":"800000","upper_trigger_price":null,"lower_trigger_price":null,"fee_type":"SELL_MAKER","reopen_timestamp":1234573890000,"timestamp":1570080162856}}}] 396 | ... 397 | 398 | ``` 399 | 400 |

401 |
402 | 403 | **Response format:** 404 | 405 | ```json 406 | [ 407 | "message", 408 | { 409 | "room_name": "circuit_break_info_btc_jpy", 410 | "message": { 411 | "data": { 412 | "mode": "string", 413 | "estimated_itayose_price": "string", 414 | "estimated_itayose_amount": "string", 415 | "itayose_upper_price": "string", 416 | "itayose_lower_price": "string", 417 | "upper_trigger_price": "string", 418 | "lower_trigger_price": "string", 419 | "fee_type": "string", 420 | "reopen_timestamp": 0, 421 | "timestamp": 0 422 | } 423 | } 424 | } 425 | ] 426 | ``` 427 | 428 | ## How to manage a local order book correctly 429 | 430 | You can manage a local (typically on-memory) order book of a pair, by using room `depth_whole_{pair}` and `depth_diff_{pair}` as follows: 431 | 432 | 1. Subscribe both `depth_whole_{pair}` and `depth_diff_{pair}`. See [the sample code of Depth Whole](#depth-whole-sample-code) and [Depth Diff](#depth-diff-sample-code) for usage. 433 | 1. Buffer the `depth_diff_{pair}` messages you receive continuously. 434 | 1. When you receive a `depth_diff_{pair}` message, 435 | * If its amount is NOT zero, add or overwrite the amount of that price level to your local order book. 436 | * If its amount IS zero, remove that price level from your local order book. 437 | 1. When you receive a `depth_whole_{pair}` message, 438 | * replace your local order book by its `data`, 439 | * and apply buffered `depth_diff_{pair}`s, 440 | * that in ascending `s` order, 441 | * only for `s` is greater than the `sequenceId` of `depth_whole_{pair}`. 442 | 443 | Here is an example of processing `depth_whole_{pair}`. 444 | If you receive following messages in this order: 445 | 446 | > diff{s=3}, diff{s=5}, diff{s=6}, diff{s=8}, whole{sequenceId=5} 447 | 448 | you should replace the local order book by `whole{sequenceId=5}`, then apply `diff{s=6}` then `diff{s=8}` and ignore about `diff{s=3}` and `diff{s=5}`. 449 | 450 | The sequence id never rewinds (at least on each room), 451 | so you can forget `depth_diff_{pair}` messages that its `s` is less or equal than latest `depth_whole_{pair}`'s `sequenceId,` to reduce resource usage. 452 | 453 | **Caveats:** 454 | 455 | * `depth_diff_{pair}` messages are sent for only ~200 price levels from best bid/ask at that time. 456 | For that reason, you must refresh your local order book with each `depth_whole_{pair}` message to get the correct order book. 457 | (or you'll miss some price levels on price change.) 458 | * A `depth_whole_{pair}` message sometimes be sent delayed from `depth_diff_{pair}` messages. 459 | For that reason, you must buffer `depth_diff_{pair}` messages and apply them on receiving a `depth_whole_{pair}` message. 460 | -------------------------------------------------------------------------------- /public-stream_JP.md: -------------------------------------------------------------------------------- 1 | [English](public-stream.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [リアルタイムデータ配信API](#%E3%83%AA%E3%82%A2%E3%83%AB%E3%82%BF%E3%82%A4%E3%83%A0%E3%83%87%E3%83%BC%E3%82%BF%E9%85%8D%E4%BF%A1api) 8 | - [API 概要](#api-%E6%A6%82%E8%A6%81) 9 | - [WSチャンネル一覧](#ws%E3%83%81%E3%83%A3%E3%83%B3%E3%83%8D%E3%83%AB%E4%B8%80%E8%A6%A7) 10 | - [ティッカー](#%E3%83%86%E3%82%A3%E3%83%83%E3%82%AB%E3%83%BC) 11 | - [約定履歴](#%E7%B4%84%E5%AE%9A%E5%B1%A5%E6%AD%B4) 12 | - [板情報の差分配信](#%E6%9D%BF%E6%83%85%E5%A0%B1%E3%81%AE%E5%B7%AE%E5%88%86%E9%85%8D%E4%BF%A1) 13 | - [板情報](#%E6%9D%BF%E6%83%85%E5%A0%B1) 14 | - [circuit_break_info.modeが `NONE` もしくは 見積価格がNull の場合](#circuit_break_infomode%E3%81%8C-none-%E3%82%82%E3%81%97%E3%81%8F%E3%81%AF-%E8%A6%8B%E7%A9%8D%E4%BE%A1%E6%A0%BC%E3%81%8Cnull-%E3%81%AE%E5%A0%B4%E5%90%88) 15 | - [circuit_break_info.modeが `NONE` 以外 かつ 見積価格が存在する 場合](#circuit_break_infomode%E3%81%8C-none-%E4%BB%A5%E5%A4%96-%E3%81%8B%E3%81%A4-%E8%A6%8B%E7%A9%8D%E4%BE%A1%E6%A0%BC%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%99%E3%82%8B-%E5%A0%B4%E5%90%88) 16 | - [サーキットブレイク情報](#%E3%82%B5%E3%83%BC%E3%82%AD%E3%83%83%E3%83%88%E3%83%96%E3%83%AC%E3%82%A4%E3%82%AF%E6%83%85%E5%A0%B1) 17 | - [板情報の処理方法](#%E6%9D%BF%E6%83%85%E5%A0%B1%E3%81%AE%E5%87%A6%E7%90%86%E6%96%B9%E6%B3%95) 18 | 19 | 20 | 21 | # リアルタイムデータ配信API 22 | 23 | ## API 概要 24 | 25 | - エンドポイント URL: **wss://stream.bitbank.cc**. 26 | - [socket.io 4.x](https://socket.io/docs/v4/)(Engine.io protocol v4)によって実装されています。下記のサンプルコードでは[github.com/websockets/wscat](https://github.com/websockets/wscat) を利用しています。 27 | - 2022-07-26 より [socket.io](https://socket.io/) が [2.x](https://socket.io/docs/v2/) -> [4.x](https://socket.io/docs/v4/) にバージョンアップされました。 28 | - stream.bitbank.ccの6時間後に自動切断される仕様は廃止されました。エラーが発生した場合は切断されますので、エラー内容をご確認ください。 29 | 30 | ## WSチャンネル一覧 31 | 32 | ### ティッカー 33 | 34 | ティッカーのwsチャンネルの名前: `ticker_{pair}`。 35 | 通貨ペアの一覧: [ペア一覧](pairs.md)。 36 | 37 | 通常モード以外の場合、sell <= buy となる場合があります。 38 | 39 | **Response:** 40 | 41 | Name | Type | Description 42 | ------------ | ------------ | ------------ 43 | sell | string | 現在の売り注文の最安値 44 | buy | string | 現在の買い注文の最高値 45 | high | string | 過去24時間の最高値取引価格 46 | low | string | 過去24時間の最安値取引価格 47 | open | string | 24時間前の始値 48 | last | string | 最新取引価格 49 | vol | string | 過去24時間の出来高 50 | timestamp | number | 日時(UnixTimeのミリ秒) 51 | 52 | **サンプルコード:** 53 | 54 |
55 | wscat 56 |

57 | 58 | ```sh 59 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 60 | 61 | connected (press CTRL+C to quit) 62 | < 0{"sid":"bDAf6vgk5xPau87WAA1u","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 63 | > 40 64 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 65 | > 42["join-room","ticker_btc_jpy"] 66 | < 42["message",{"room_name":"ticker_btc_jpy","message":{"pid":851203833,"data":{"sell":"896490","buy":"896489","open":"896489","high":"905002","low":"881500","last":"896489","vol":"650.2026","timestamp":1570080042822}}}] 67 | < 42["message",{"room_name":"ticker_btc_jpy","message":{"pid":851203952,"data":{"sell":"896490","buy":"896489","open":"896489","high":"905002","low":"881500","last":"896489","vol":"650.2226","timestamp":1570080053768}}}] 68 | ... 69 | 70 | ``` 71 | 72 |

73 |
74 | 75 | **レスポンスのフォーマット:** 76 | 77 | ```json 78 | [ 79 | "message", 80 | { 81 | "room_name": "ticker_btc_jpy", 82 | "message": { 83 | "pid": 0, 84 | "data": { 85 | "last": "string", 86 | "open": "string", 87 | "timestamp": 0, 88 | "sell": "string", 89 | "vol": "string", 90 | "buy": "string", 91 | "high": "string", 92 | "low": "string" 93 | } 94 | } 95 | } 96 | ] 97 | ``` 98 | 99 | ### 約定履歴 100 | 101 | 約定履歴のwsチャンネルの名前: `transactions_{pair}`。 102 | 103 | 通貨ペアの一覧: [ペア一覧](pairs.md)。 104 | 105 | **Response:** 106 | 107 | Name | Type | Description 108 | ------------ | ------------ | ------------ 109 | transaction_id | number | 取引ID 110 | side | string | `buy` または `sell` 111 | price | string | 価格 112 | amount | string | 数量 113 | executed_at | number | 約定日時(UnixTimeのミリ秒) 114 | 115 | **サンプルコード:** 116 | 117 |
118 | wscat 119 |

120 | 121 | ```sh 122 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 123 | 124 | connected (press CTRL+C to quit) 125 | < 0{"sid":"PG3FbI0WrKIP7hKMABH_","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 126 | > 40 127 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 128 | > 42["join-room","transactions_xrp_jpy"] 129 | < 42["message",{"room_name":"transactions_xrp_jpy","message":{"pid":851205254,"data":{"transactions":[{"transaction_id":34745047,"side":"sell","price":"26.930","amount":"4703.5671","executed_at":1570080162855},{"transaction_id":34745046,"side":"sell","price":"26.930","amount":"500.0000","executed_at":1570080162829},{"transaction_id":34745045,"side":"sell","price":"26.930","amount":"378.0000","executed_at":1570080162802},{"transaction_id":34745044,"side":"sell","price":"26.930","amount":"12.0000","executed_at":1570080162758},{"transaction_id":34745043,"side":"sell","price":"26.930","amount":"301.4874","executed_at":1570080162725}]}}}] 130 | ... 131 | 132 | ``` 133 | 134 |

135 |
136 | 137 | **レスポンスのフォーマット:** 138 | 139 | ```json 140 | [ 141 | "message", 142 | { 143 | "room_name": "transactions_btc_jpy", 144 | "message": { 145 | "pid": 0, 146 | "data": { 147 | "transactions": [ 148 | { 149 | "side": "string", 150 | "executed_at": 0, 151 | "amount": "string", 152 | "price": "string", 153 | "transaction_id": 0 154 | } 155 | ] 156 | } 157 | } 158 | } 159 | ] 160 | ``` 161 | 162 | ### 板情報の差分配信 163 | 164 | 板情報の差分配信のwsチャンネルの名前: `depth_diff_{pair}`。 165 | 通貨ペアの一覧: [ペア一覧](pairs.md)。 166 | 167 | 通常モード以外の場合、a <= b となる場合があります。 168 | 169 | **Response:** 170 | 171 | Name | Type | Description 172 | ------------ | ------------ | ------------ 173 | a | [string, string][] | [ask, amount][] 174 | b | [string, string][] | [bid, amount][] 175 | ao | string \| undefined | [asks](#板情報)の最高値よりも高いasksの数量。数量の変動がない場合はメッセージに含まれません。 176 | bu | string \| undefined | [bids](#板情報)の最安値よりも安いbidsの数量。数量の変動がない場合はメッセージに含まれません。 177 | au | string \| undefined | [bids](#板情報)の最安値よりも安いasksの数量。数量の変動がない場合はメッセージに含まれません。 178 | bo | string \| undefined | [asks](#板情報)の最高値よりも高いbidsの数量。数量の変動がない場合はメッセージに含まれません。 179 | am | string \| undefined | 新しい成行売り数量。数量の変動がない場合はメッセージに含まれません。 180 | bm | string \| undefined | 新しい成行買い数量。数量の変動がない場合はメッセージに含まれません。 181 | t | number | 日時(UnixTimeのミリ秒) 182 | s | string | シーケンスID、単調増加しますが連続しているとは限りません 183 | 184 | `a` (asks)と `b` (bids)のamountは絶対数量です。またamountが0なものはその気配値が無くなったことを示します。 185 | 186 | `s` は `depth_whole_{pair}` の `sequenceId` と共通のシーケンスIDです。 187 | 188 | 使い方については [板情報の処理方法](#%E6%9D%BF%E6%83%85%E5%A0%B1%E3%81%AE%E5%87%A6%E7%90%86%E6%96%B9%E6%B3%95) の節をご覧ください。 189 | 190 | **サンプルコード:** 191 | 192 |
193 | wscat 194 |

195 | 196 | ```sh 197 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 198 | connected (press CTRL+C to quit) 199 | < 0{"sid":"9-zd3P1G-BNu_w37ABMX","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 200 | > 40 201 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 202 | > 42["join-room","depth_diff_xrp_jpy"] 203 | < 42["message",{"room_name":"depth_diff_xrp_jpy","message":{"data":{"a":[],"b":[["26.758","20000.0000"],["26.212","0"]],"t":1570080269609,"s":"1234567890"}}}] 204 | < 42["message",{"room_name":"depth_diff_xrp_jpy","message":{"data":{"a":[],"b":[["26.212","1000.0000"],["26.815","0"]],"t":1570080270100,"s":"1234567893"}}}] 205 | ... 206 | 207 | ``` 208 | 209 |

210 |
211 | 212 | **レスポンスのフォーマット:** 213 | 214 | ```json 215 | [ 216 | "message", 217 | { 218 | "room_name": "depth_diff_xrp_jpy", 219 | "message": { 220 | "data": { 221 | "b": [ 222 | [ 223 | "26.872", 224 | "43.3989" 225 | ], 226 | [ 227 | "26.871", 228 | "100.0000" 229 | ], 230 | ], 231 | "a": [ 232 | [ 233 | "27.839", 234 | "1634.3980" 235 | ], 236 | [ 237 | "28.450", 238 | "0" 239 | ] 240 | ], 241 | "ao": "1", 242 | "bu": "1", 243 | "am": "1", 244 | "bm": "1", 245 | "t": 1568344204624, 246 | "s": "1234567890" 247 | } 248 | } 249 | } 250 | ] 251 | ``` 252 | 253 | ### 板情報 254 | 255 | 板情報のwsチャンネルの名前: `depth_whole_{pair}` 256 | 通貨ペアの一覧: [ペア一覧](pairs.md)。 257 | 258 | 通常モード以外の場合、asks <= bids となる場合があります。 259 | 260 | #### circuit_break_info.modeが `NONE` もしくは 見積価格がNull の場合 261 | 262 | - asks, bidsで配信されるデータは、Best Bid Offerから200件ずつです。 263 | - したがって、asks, bidsのBBO(Best Bid Offer)は必ず `最も安いAsk > 最も高いBid` となります。 264 | 265 | #### circuit_break_info.modeが `NONE` 以外 かつ 見積価格が存在する 場合 266 | 267 | - asks, bidsで配信されるデータは、見積価格から上下200件ずつです。(最大400件) 268 | - したがって、通常時とは異なり、 `最も安いAsk < 最も高いBid` となる場合があります。 269 | - また、配信データの価格範囲よりも安い売り注文は `asks_under` に、高い買い注文は `bids_over` に加算されます。 270 | 271 | #### circuit_break_info.modeが `NONE` もしくは 見積価格がNull の場合 272 | 273 | - asks, bidsで配信されるデータは、Best Bid Offerから200件ずつです。 274 | - したがって、asks, bidsのBBO(Best Bid Offer)は必ず `最も安いAsk > 最も高いBid` となります。 275 | 276 | #### circuit_break_info.modeが `NONE` 以外 かつ 見積価格が存在する 場合 277 | 278 | - asks, bidsで配信されるデータは、見積価格から上下200件ずつです。(最大400件) 279 | - したがって、通常時とは異なり、 `最も安いAsk < 最も高いBid` となる場合があります。 280 | - また、配信データの価格範囲よりも安い売り注文は `asks_under` に、高い買い注文は `bids_over` に加算されます。 281 | 282 | **Response:** 283 | 284 | Name | Type | Description 285 | ------------ | ------------ | ------------ 286 | asks | [string, string][] | 売り板 [価格, 数量] 287 | bids | [string, string][] | 買い板 [価格, 数量] 288 | asks_over | string | asksの最高値(asks配列の一番最後の要素)よりも高いasksの数量 289 | bids_under | string | bidsの最安値(bids配列の一番最後の要素)よりも安いbidsの数量 290 | asks_under | string | bidsの最安値(bids配列の一番最後の要素)よりも安いasksの数量。通常モードの場合は `0` 291 | bids_over | string | asksの最高値(asks配列の一番最後の要素)よりも高いbidsの数量。通常モードの場合は `0` 292 | ask_market | string | 成行売り数量。通常モードの場合は `0` 293 | bid_market | string | 成行買い数量。通常モードの場合は `0` 294 | timestamp | number | timestamp 295 | sequenceId | number | シーケンスID、単調増加しますが連続しているとは限りません 296 | 297 | `sequenceId` は `depth_diff_{pair}` の `s` と共通のシーケンスIDです。 298 | 299 | 使い方については [板情報の処理方法](#%E6%9D%BF%E6%83%85%E5%A0%B1%E3%81%AE%E5%87%A6%E7%90%86%E6%96%B9%E6%B3%95) の節をご覧ください。 300 | 301 | **サンプルコード:** 302 | 303 |
304 | wscat 305 |

306 | 307 | ```sh 308 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 309 | connected (press CTRL+C to quit) 310 | < 0{"sid":"PR6GLrwlEFjzHIPrABBM","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 311 | > 40 312 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 313 | > 42["join-room","depth_whole_xrp_jpy"] 314 | < 42["message",{"room_name":"depth_whole_xrp_jpy","message":{"data":{"asks":[["26.928","1000.0000"],["26.929","56586.5153"],["26.930","218.3431"],["26.931","3123.8845"],["26.933","1799.0000"],["26.934","377.9136"],["26.938","3411.1507"],["26.950","80.0000"],["26.955","80.0000"],["26.958","7434.5900"],["26.959","15000.0000"],["26.960","15000.0000"],["26.964","10837.6620"],["26.979","15000.0000"], ...]}}}] 315 | 316 | ``` 317 | 318 |

319 |
320 | 321 | **レスポンスのフォーマット:** 322 | 323 | ```json 324 | [ 325 | "message", 326 | { 327 | "room_name": "depth_whole_xrp_jpy", 328 | "message": { 329 | "data": { 330 | "bids": [ 331 | [ 332 | "27.537", 333 | "6211.6210" 334 | ], 335 | [ 336 | "27.523", 337 | "875.3413" 338 | ], 339 | ], 340 | "asks": [ 341 | [ 342 | "27.538", 343 | "7233.6837" 344 | ], 345 | [ 346 | "27.540", 347 | "19.4551" 348 | ], 349 | ], 350 | "asks_over": "0.123", 351 | "bids_under": "0.123", 352 | "asks_under": "0", 353 | "bids_over": "0", 354 | "ask_market": "0", 355 | "bid_market": "0", 356 | "timestamp": 1568344476514, 357 | "sequenceId": "1234567890" 358 | } 359 | } 360 | } 361 | ] 362 | ``` 363 | 364 | ### サーキットブレイク情報 365 | 366 | [Public API] サーキットブレイク情報を取得。 367 | 368 | **Response:** 369 | 370 | Name | Type | Description 371 | ------------ | ------------ | ------------ 372 | mode | string | `NONE` または `CIRCUIT_BREAK` または `FULL_RANGE_CIRCUIT_BREAK` または `RESUMPTION` または `LISTING` 373 | estimated_itayose_price | string \| null | 見積価格。通常モードまたは見積価格が無い場合はnull 374 | estimated_itayose_amount | string \| null | 見積数量。通常モードであればnull 375 | itayose_upper_price | string \| null | CB時制限値幅価格上限。通常モード、無期限サーキットブレイクモード、新規上場モードはnull 376 | itayose_lower_price | string \| null | CB時制限値幅価格下限。通常モード、無期限サーキットブレイクモード、新規上場モードはnull 377 | upper_trigger_price | string \| null | CB突入判定価格上限。CB中はnull 378 | lower_trigger_price | string \| null | CB突入判定価格下限。CB中はnull 379 | fee_type | string | `NORMAL` または `SELL_MAKER` または `BUY_MAKER` または `DYNAMIC` 380 | reopen_timestamp | number \| null | サーキットブレイク終了予定時刻(UnixTimeのミリ秒)。通常モード、またはCB終了予定時刻がない場合はnull 381 | timestamp | number | 日時(UnixTimeのミリ秒) 382 | 383 | `mode` および `fee_type` の詳細は[サーキットブレーカー制度](https://bitbank.cc/docs/circuit-breaker-mode/)のページをご確認ください。 384 | 385 | **サンプルコード:** 386 | 387 |
388 | wscat 389 |

390 | 391 | ```sh 392 | $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' 393 | 394 | connected (press CTRL+C to quit) 395 | < 0{"sid":"PG3FbI0WrKIP7hKMABH_","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 396 | > 40 397 | < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} 398 | > 42["join-room","circuit_break_info_xrp_jpy"] 399 | < 42["message",{"room_name":"circuit_break_info_xrp_jpy","message":{"data":{"mode":"NONE","estimated_itayose_price":null,"estimated_itayose_amount":null,"itayose_upper_price":null,"itayose_lower_price":null,"upper_trigger_price":"1200000","lower_trigger_price":"800000","fee_type":"NORMAL","reopen_timestamp":null,"timestamp":1570080162855}}}] 400 | < 42["message",{"room_name":"circuit_break_info_xrp_jpy","message":{"data":{"mode":"CIRCUIT_BREAK","estimated_itayose_price":"1000000","estimated_itayose_amount":null,"itayose_upper_price":"1300000","itayose_lower_price":"800000","upper_trigger_price":null,"lower_trigger_price":null,"fee_type":"SELL_MAKER","reopen_timestamp":1234573890000,"timestamp":1570080162856}}}] 401 | ... 402 | 403 | ``` 404 | 405 |

406 |
407 | 408 | **レスポンスのフォーマット:** 409 | 410 | ```json 411 | [ 412 | "message", 413 | { 414 | "room_name": "circuit_break_info_btc_jpy", 415 | "message": { 416 | "data": { 417 | "mode": "string", 418 | "estimated_itayose_price": "string", 419 | "estimated_itayose_amount": "string", 420 | "itayose_upper_price": "string", 421 | "itayose_lower_price": "string", 422 | "upper_trigger_price": "string", 423 | "lower_trigger_price": "string", 424 | "fee_type": "string", 425 | "reopen_timestamp": 0, 426 | "timestamp": 0 427 | } 428 | } 429 | } 430 | ] 431 | ``` 432 | 433 | ## 板情報の処理方法 434 | 435 | あるペアのリアルタイムな板情報は以下のように `depth_whole_{pair}` および `depth_diff_{pair}` roomのメッセージを処理することで得られます: 436 | 437 | 1. `depth_whole_{pair}` および `depth_diff_{pair}` について受信を開始します。方法については[板情報](#depth-whole-sample-code)および[板情報の差分配信のサンプルコード](#depth-diff-sample-code)をご覧ください。 438 | 1. `depth_diff_{pair}` メッセージたちを継続的にバッファ(記憶)します。 439 | 1. `depth_diff_{pair}` メッセージを受信したら、 440 | * その数量が「非0」なら、板のその気配値について追加または上書きします。 441 | * その数量が「0」なら、板からその気配値を取り除きます。 442 | 1. `depth_whole_{pair}` メッセージを受信したら、 443 | * 板をその `data` で置き換え、 444 | * バッファしておいた `depth_diff_{pair}` たちを、 445 | * その `s` の昇順で、 446 | * その `s` が `depth_whole_{pair}` の `sequenceId` より大きいものについてのみ、 447 | * 適用します。 448 | 449 | `depth_whole_{pair}` の処理方法について例示します。 450 | 例えば以下の順でメッセージを受信した場合: 451 | 452 | > diff{s=3}, diff{s=5}, diff{s=6}, diff{s=8}, whole{sequenceId=5} 453 | 454 | `whole{sequenceId=5}` で板を置き換えた後、 `diff{s=6}` と `diff{s=8}` をこの順で適用しなおします。 `diff{s=3}` と `diff{s=5}` は無視します。 455 | 456 | シーケンスIDは(少なくともroomごとには)巻き戻ることはありませんので、 457 | バッファした `depth_diff_{pair}` メッセージたちのうち、その `s` が最後の `depth_whole_{pair}` メッセージの `sequenceId` より小さいか等しいものについて破棄することでリソース使用量を削減できます。 458 | 459 | **注意事項:** 460 | 461 | * `depth_diff_{pair}` メッセージはその時々のbest bid/askより200エントリに対するものしか配信されません。 462 | このため、正確な板情報を得るには `depth_whole_{pair}` メッセージで定期的に置き換えし続ける必要があります。 463 | (さもなくば価格変動時に変動方向の価格を見過すことになります。) 464 | * `depth_whole_{pair}` メッセージは `depth_diff_{pair}` メッセージより遅延することがあります。 465 | このため、 `depth_diff_{pair}` メッセージをバッファし `depth_whole_{pair}` メッセージ受信時に再適用する必要があります。 466 | -------------------------------------------------------------------------------- /rest-api_JP.md: -------------------------------------------------------------------------------- 1 | [English](rest-api.md) 2 | 3 | 4 | 5 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 6 | 7 | - [Private REST API一覧](#private-rest-api%E4%B8%80%E8%A6%A7) 8 | - [API 概要](#api-%E6%A6%82%E8%A6%81) 9 | - [認証](#%E8%AA%8D%E8%A8%BC) 10 | - [ACCESS-TIME-WINDOW方式](#access-time-window%E6%96%B9%E5%BC%8F) 11 | - [ACCESS-NONCE方式](#access-nonce%E6%96%B9%E5%BC%8F) 12 | - [署名](#%E7%BD%B2%E5%90%8D) 13 | - [サンプル](#%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB) 14 | - [ACCESS-TIME-WINDOW](#access-time-window) 15 | - [ACCESS-NONCE](#access-nonce) 16 | - [レートリミット](#%E3%83%AC%E3%83%BC%E3%83%88%E3%83%AA%E3%83%9F%E3%83%83%E3%83%88) 17 | - [エンドポイント一覧](#%E3%82%A8%E3%83%B3%E3%83%89%E3%83%9D%E3%82%A4%E3%83%B3%E3%83%88%E4%B8%80%E8%A6%A7) 18 | - [アセット](#%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88) 19 | - [アセット一覧を返す](#%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E4%B8%80%E8%A6%A7%E3%82%92%E8%BF%94%E3%81%99) 20 | - [注文情報](#%E6%B3%A8%E6%96%87%E6%83%85%E5%A0%B1) 21 | - [注文情報を取得する](#%E6%B3%A8%E6%96%87%E6%83%85%E5%A0%B1%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 22 | - [新規注文を行う](#%E6%96%B0%E8%A6%8F%E6%B3%A8%E6%96%87%E3%82%92%E8%A1%8C%E3%81%86) 23 | - [注文をキャンセルする](#%E6%B3%A8%E6%96%87%E3%82%92%E3%82%AD%E3%83%A3%E3%83%B3%E3%82%BB%E3%83%AB%E3%81%99%E3%82%8B) 24 | - [注文をキャンセルする(複数)](#%E6%B3%A8%E6%96%87%E3%82%92%E3%82%AD%E3%83%A3%E3%83%B3%E3%82%BB%E3%83%AB%E3%81%99%E3%82%8B%E8%A4%87%E6%95%B0) 25 | - [注文情報を取得する(複数)](#%E6%B3%A8%E6%96%87%E6%83%85%E5%A0%B1%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B%E8%A4%87%E6%95%B0) 26 | - [アクティブな注文を取得する](#%E3%82%A2%E3%82%AF%E3%83%86%E3%82%A3%E3%83%96%E3%81%AA%E6%B3%A8%E6%96%87%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 27 | - [建玉情報](#%E5%BB%BA%E7%8E%89%E6%83%85%E5%A0%B1) 28 | - [建玉・追証・不足金額情報を取得する](#%E5%BB%BA%E7%8E%89%E3%83%BB%E8%BF%BD%E8%A8%BC%E3%83%BB%E4%B8%8D%E8%B6%B3%E9%87%91%E9%A1%8D%E6%83%85%E5%A0%B1%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 29 | - [約定履歴](#%E7%B4%84%E5%AE%9A%E5%B1%A5%E6%AD%B4) 30 | - [約定履歴を取得する](#%E7%B4%84%E5%AE%9A%E5%B1%A5%E6%AD%B4%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 31 | - [入金](#%E5%85%A5%E9%87%91) 32 | - [入金履歴を取得する](#%E5%85%A5%E9%87%91%E5%B1%A5%E6%AD%B4%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 33 | - [未反映入金を取得する](#%E6%9C%AA%E5%8F%8D%E6%98%A0%E5%85%A5%E9%87%91%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 34 | - [送付人を取得する](#%E9%80%81%E4%BB%98%E4%BA%BA%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 35 | - [未反映入金に送付人を登録する](#%E6%9C%AA%E5%8F%8D%E6%98%A0%E5%85%A5%E9%87%91%E3%81%AB%E9%80%81%E4%BB%98%E4%BA%BA%E3%82%92%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B) 36 | - [未反映入金に送付人を一括登録する](#%E6%9C%AA%E5%8F%8D%E6%98%A0%E5%85%A5%E9%87%91%E3%81%AB%E9%80%81%E4%BB%98%E4%BA%BA%E3%82%92%E4%B8%80%E6%8B%AC%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B) 37 | - [出金](#%E5%87%BA%E9%87%91) 38 | - [出金アカウントを取得する](#%E5%87%BA%E9%87%91%E3%82%A2%E3%82%AB%E3%82%A6%E3%83%B3%E3%83%88%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 39 | - [出金リクエストを行う](#%E5%87%BA%E9%87%91%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E3%82%92%E8%A1%8C%E3%81%86) 40 | - [出金履歴を取得する](#%E5%87%BA%E9%87%91%E5%B1%A5%E6%AD%B4%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 41 | - [取引所ステータス](#%E5%8F%96%E5%BC%95%E6%89%80%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9) 42 | - [取引所ステータスを取得する](#%E5%8F%96%E5%BC%95%E6%89%80%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 43 | - [銘柄詳細](#%E9%8A%98%E6%9F%84%E8%A9%B3%E7%B4%B0) 44 | - [銘柄詳細一覧を取得する](#%E9%8A%98%E6%9F%84%E8%A9%B3%E7%B4%B0%E4%B8%80%E8%A6%A7%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 45 | - [プライベートストリーム](#%E3%83%97%E3%83%A9%E3%82%A4%E3%83%99%E3%83%BC%E3%83%88%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0) 46 | - [プライベートストリームのチャンネルとトークンを取得する](#%E3%83%97%E3%83%A9%E3%82%A4%E3%83%99%E3%83%BC%E3%83%88%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0%E3%81%AE%E3%83%81%E3%83%A3%E3%83%B3%E3%83%8D%E3%83%AB%E3%81%A8%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B) 47 | 48 | 49 | 50 | # Private REST API一覧 51 | 52 | ## API 概要 53 | 54 | - エンドポイント URL: **[https://api.bitbank.cc/v1](https://api.bitbank.cc/v1)** 55 | - リクエストに不正がある場合、以下のようなエラーレスポンスを返します。 56 | 57 | ```json 58 | { 59 | "success": 0, 60 | "data": { 61 | "code": 20003 62 | } 63 | } 64 | ``` 65 | 66 | - エラーコードの一覧は [errors_JP.md](errors_JP.md) を確認してください。 67 | - `GET`エンドポイントの場合、パラメータをクエリー文字列として送信してください。 68 | - `POST`エンドポイントの場合、リクエストヘッダ`Content-Type`:`application/json`で、リクエストボディにデータを記述してください。 69 | 70 | ## 認証 71 | 72 | - パブリックAPIは認証情報無しでアクセスできます。プライベートAPIでは以下の情報をHTTPリクエストヘッダーに付与してリクエストを行う必要があります。 73 | - ACCESS-NONCE、ACCESS-TIME-WINDOWどちらも指定した場合はACCESS-TIME-WINDOW方式が優先されます。 74 | 75 | ### ACCESS-TIME-WINDOW方式 76 | 77 | - ACCESS-KEY : APIキーページで取得したAPIキー。 78 | - ACCESS-SIGNATURE : 以下に記述する署名を指定します。 79 | - ACCESS-REQUEST-TIME : 整数値。通常は現在時刻のUNIXタイムスタンプ(ミリ秒)を使用してください。タイムゾーンはUTCであることにご注意ください。 80 | - ACCESS-TIME-WINDOW : 整数値。リクエストが有効になるミリ秒数を指定できます。未指定の場合デフォルトで5000が適用されます。5000以下の小さな値を使用することを推奨します。最大値は60000を超えることはできません。ロジックは以下の通りです。 81 | 82 | ```typescript 83 | if (ACCESS-REQUEST-TIME < (serverTime + 1000) && (serverTime - ACCESS-REQUEST-TIME) <= ACCESS-TIME-WINDOW) { 84 | // process request 85 | } else { 86 | // reject request 87 | } 88 | ``` 89 | 90 | ### ACCESS-NONCE方式 91 | 92 | - ACCESS-KEY : APIキーページで取得したAPIキー。 93 | - ACCESS-NONCE : 整数値。リクエスト毎に数を増加させる必要があります。通常はUNIXタイムスタンプを使用してください。 94 | - ACCESS-SIGNATURE : 以下に記述する署名を指定します。 95 | 96 | ### 署名 97 | 98 | - 署名作成は、以下の文字列を `HMAC-SHA256` 形式でAPIシークレットキーを使って署名した結果となります。 99 | - ACCESS-TIME-WINDOW方式の場合 100 | - GETの場合: 「ACCESS-REQUEST-TIME、ACCESS-TIME-WINDOW、リクエストのパス、クエリパラメータ」 を連結させたもの 101 | - POSTの場合: 「ACCESS-REQUEST-TIME、ACCESS-TIME-WINDOW、リクエストボディのJson文字列」 を連結させたもの 102 | - ACCESS-NONCE方式の場合 103 | - GETの場合: 「ACCESS-NONCE、リクエストのパス、クエリパラメータ」 を連結させたもの 104 | - POSTの場合: 「ACCESS-NONCE、リクエストボディのJson文字列」 を連結させたもの 105 | 106 | *※ GETのACCESS-SIGNATUREで使用する「リクエストのパス」には"/v1"も含める必要があります。* 107 | 108 | *※ POSTではパラメータをJson文字列にしてリクエストボディに含める必要があります。* 109 | 110 | #### サンプル 111 | 112 | ##### ACCESS-TIME-WINDOW 113 | 114 | - GET: /v1/user/assetsのケース 115 | 116 | ```bash 117 | export API_SECRET="hoge" 118 | export ACCESS_REQUEST_TIME="1721121776490" 119 | export ACCESS_TIME_WINDOW="1000" 120 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_REQUEST_TIME$ACCESS_TIME_WINDOW/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET")" 121 | 122 | 123 | echo $ACCESS_SIGNATURE 124 | 9ec5745960d05573c8fb047cdd9191bd0c6ede26f07700bb40ecf1a3920abae8 125 | ``` 126 | 127 | - POST系のエンドポイントのケース 128 | 129 | ```bash 130 | export API_SECRET="hoge" 131 | export ACCESS_REQUEST_TIME="1721121776490" 132 | export ACCESS_TIME_WINDOW="1000" 133 | export REQUEST_BODY='{"pair": "xrp_jpy", "price": "20", "amount": "1","side": "buy", "type": "limit"}' 134 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_REQUEST_TIME$ACCESS_TIME_WINDOW$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 135 | 136 | 137 | echo $ACCESS_SIGNATURE 138 | 7868665738ae3f8a796224e0413c1351ddd7ec2af121db12815c0a5b74b8764c 139 | ``` 140 | 141 | ##### ACCESS-NONCE 142 | 143 | - GET: /v1/user/assetsのケース 144 | 145 | ```bash 146 | export API_SECRET="hoge" 147 | export ACCESS_NONCE="1721121776490" 148 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET")" 149 | 150 | 151 | echo $ACCESS_SIGNATURE 152 | f957817b95c3af6cf5e2e9dfe1503ea8088f46879d4ab73051467fd7b94f1aba 153 | ``` 154 | 155 | - POST系のエンドポイントのケース 156 | 157 | ```bash 158 | export API_SECRET="hoge" 159 | export ACCESS_NONCE="1721121776490" 160 | export REQUEST_BODY='{"pair": "xrp_jpy", "price": "20", "amount": "1","side": "buy", "type": "limit"}' 161 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 162 | 163 | 164 | echo $ACCESS_SIGNATURE 165 | 8ef83c2b991765b18c95aade7678471747c06890a23a453c76238345b5c86fb8 166 | ``` 167 | 168 | ## レートリミット 169 | 170 | - ユーザごと、更新系・取得系それぞれ、1秒ごとにREST API呼び出しの頻度に制限を設けています。 171 | - 更新系とは新規注文、注文キャンセル、出金リクエストのことを指します。 172 | - 取得系はそれ以外を指します。 173 | - マッチングエンジンの過負荷を防ぐため、システム全体においてもREST API呼び出しに制限を設けています。 174 | - ただしこの制限はほとんどの場合において抵触しないくらい高く設定されています。 175 | - レートリミットに抵触した場合、HTTP 429エラーを返します。429エラーがよく返却される場合はAPI呼び出しの頻度を減らしてください。 176 | - 頻度制限について基本的に取得系は 10回/秒 、更新系は 6回/秒 としています。 177 | - 取引高等の実績に応じて引き上げが可能な場合があります。 178 | - 必要であれば[こちらのフォーム](https://support.bitbank.cc/hc/ja/requests/new?ticket_form_id=13179074196633)より送信ください。 179 | - 「問合せ内容」は「レートリミットの制限緩和について」をお選びください。 180 | 181 | ## エンドポイント一覧 182 | 183 | ### アセット 184 | 185 | #### アセット一覧を返す 186 | 187 | ```txt 188 | GET /user/assets 189 | ``` 190 | 191 | **Parameters:** 192 | None 193 | 194 | **Response:** 195 | 196 | Name | Type | Description 197 | ------------ | ------------ | ------------ 198 | asset | string | アセット名: [アセット一覧](assets.md) 199 | free_amount | string | 利用可能な量 200 | amount_precision | number | 精度 201 | onhand_amount | string | 保有量 202 | locked_amount | string | ロックされている量 203 | withdrawing_amount | string | ロックされている量のうち出金中数量 204 | withdrawal_fee | { min: string, max: string } or { under: string, over: string, threshold:string } for `jpy` | 出金手数料 205 | stop_deposit | boolean | 入金ステータス(全ネットワークが入金停止 = `true`) 206 | stop_withdrawal | boolean | 出金ステータス(全ネットワークが出金停止 = `true`) 207 | network_list | { asset: string, network: string, stop_deposit: boolean, stop_withdrawal: boolean, withdrawal_fee: string } or undefined for `jpy` | ネットワーク一覧 208 | collateral_ratio | string | 代用掛け目 209 | 210 | **サンプルコード:** 211 | 212 |
213 | Curl 214 |

215 | 216 | ```sh 217 | export API_KEY=___your api key___ 218 | export API_SECRET=___your api secret___ 219 | export ACCESS_NONCE="$(date +%s)" 220 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET")" 221 | 222 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/assets 223 | ``` 224 | 225 |

226 |
227 | 228 | 229 | **レスポンスのフォーマット:** 230 | 231 | ```json 232 | { 233 | "success": 1, 234 | "data": { 235 | "assets": [ 236 | { 237 | "asset": "string", 238 | "free_amount": "string", 239 | "amount_precision": 0, 240 | "onhand_amount": "string", 241 | "locked_amount": "string", 242 | "withdrawing_amount": "string", 243 | "withdrawal_fee": { 244 | "min": "string", 245 | "max": "string" 246 | }, 247 | "stop_deposit": false, 248 | "stop_withdrawal": false, 249 | "network_list": [ 250 | { 251 | "asset": "string", 252 | "network": "string", 253 | "stop_deposit": false, 254 | "stop_withdrawal": false, 255 | "withdrawal_fee": "string" 256 | } 257 | ], 258 | "collateral_ratio": "string" 259 | }, 260 | { 261 | "asset": "jpy", 262 | "free_amount": "string", 263 | "amount_precision": 0, 264 | "onhand_amount": "string", 265 | "locked_amount": "string", 266 | "withdrawing_amount": "string", 267 | "withdrawal_fee": { 268 | "under": "string", 269 | "over": "string", 270 | "threshold": "string" 271 | }, 272 | "stop_deposit": false, 273 | "stop_withdrawal": false, 274 | "collateral_ratio": "string" 275 | }, 276 | ] 277 | } 278 | } 279 | ``` 280 | 281 | 282 | ### 注文情報 283 | 284 | #### 注文情報を取得する 285 | 286 | ```txt 287 | GET /user/spot/order 288 | ``` 289 | 290 | **Parameters:** 291 | 292 | Name | Type | Mandatory | Description 293 | ------------ | ------------ | ------------ | ------------ 294 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 295 | order_id | number | YES | 取引ID 296 | 297 | **Response:** 298 | 299 | Name | Type | Description 300 | ------------ | ------------ | ------------ 301 | order_id | number | order id 302 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 303 | side | string | `buy` または `sell` 304 | position_side | string \| undefined | `long` または `short`(信用取引の時のみ) 305 | type | string | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 306 | start_amount | string \| null | 注文時の数量 307 | remaining_amount | string \| null | 未約定の数量 308 | executed_amount| string | 約定済み数量 309 | price | string \| undefined | 注文価格(type = `limit` または `stop_limit` 時のみ) 310 | post_only | boolean \| undefined | Post Onlyかどうか(type = `limit`時のみ) 311 | user_cancelable | boolean | ユーザがキャンセル可能な注文かどうか 312 | average_price | string | 平均約定価格 313 | ordered_at | number | 注文日時(UnixTimeのミリ秒) 314 | expire_at | number \| null | 有効期限(UnixTimeのミリ秒) 315 | triggered_at | number \| undefined | トリガー日時(UnixTimeのミリ秒)(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 316 | trigger_price | string \| undefined | トリガー価格(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 317 | status | string | 注文ステータス: `INACTIVE` 非アクティブ, `UNFILLED` 注文中, `PARTIALLY_FILLED` 注文中(一部約定), `FULLY_FILLED` 約定済み, `CANCELED_UNFILLED` 取消済, `CANCELED_PARTIALLY_FILLED` 取消済(一部約定) 318 | 319 | **注意事項:** 320 | 321 | * このAPIでは3ヶ月以上前の約定済またはキャンセル済注文を取得できません。(50009が返ります。) 322 | 3ヶ月以上前の注文情報の取得にはお手数ですが[注文履歴の抽出ページ](https://app.bitbank.cc/account/data/orders/download)をご利用ください。 323 | 324 | **サンプルコード:** 325 | 326 |
327 | Curl 328 |

329 | 330 | ```sh 331 | export API_KEY=___your api key___ 332 | export API_SECRET=___your api secret___ 333 | export ACCESS_NONCE="$(date +%s)" 334 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/spot/order?pair=btc_jpy&order_id=1" | openssl dgst -sha256 -hmac "$API_SECRET")" 335 | 336 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/spot/order?pair=btc_jpy\&order_id=1 337 | ``` 338 | 339 |

340 |
341 | 342 | 343 | **レスポンスのフォーマット:** 344 | 345 | ```json 346 | { 347 | "success": 1, 348 | "data": { 349 | "order_id": 0, 350 | "pair": "string", 351 | "side": "string", 352 | "position_side": "string", 353 | "type": "string", 354 | "start_amount": "string", 355 | "remaining_amount": "string", 356 | "executed_amount": "string", 357 | "price": "string", 358 | "post_only": false, 359 | "user_cancelable": true, 360 | "average_price": "string", 361 | "ordered_at": 0, 362 | "expire_at": 0, 363 | "triggered_at": 0, 364 | "trigger_price": "string", 365 | "status": "string" 366 | } 367 | } 368 | ``` 369 | 370 | #### 新規注文を行う 371 | 372 | ```txt 373 | POST /user/spot/order 374 | ``` 375 | 376 | **Parameters(requestBody):** 377 | 378 | Name | Type | Mandatory | Description 379 | ------------ | ------------ | ------------ | ------------ 380 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 381 | amount | string | NO | 注文量。typeが `take_profit`、`stop_loss` 以外の場合は必須 382 | price | string | NO | 価格 383 | side | string | YES | `buy` または `sell` 384 | position_side | string | NO | `long` または `short` 385 | type | string | YES | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 386 | post_only | boolean | NO | Post Onlyかどうか(type = `limit` 時のみ `true` を指定可能。デフォルト `false`) 387 | trigger_price | string | NO | トリガー価格 388 | 389 | **Response:** 390 | 391 | Name | Type | Description 392 | ------------ | ------------ | ------------ 393 | order_id | number | order id 394 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 395 | side | string | `buy` または `sell` 396 | position_side | string \| undefined | `long` または `short`(信用取引の時のみ) 397 | type | string | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 398 | start_amount | string \| null | 注文時の数量 399 | remaining_amount | string \| null | 未約定の数量 400 | executed_amount| string | 約定済み数量 401 | price | string \| undefined | 注文価格(type = `limit` または `stop_limit` 時のみ) 402 | post_only | boolean \| undefined | Post Onlyかどうか(type = `limit`時のみ) 403 | user_cancelable | boolean | ユーザがキャンセル可能な注文かどうか 404 | average_price | string | 平均約定価格 405 | ordered_at | number | 注文日時(UnixTimeのミリ秒) 406 | expire_at | number \| null | 有効期限(UnixTimeのミリ秒) 407 | trigger_price | string \| undefined | トリガー価格(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 408 | status | string | 注文ステータス: `INACTIVE` 非アクティブ, `UNFILLED` 注文中, `PARTIALLY_FILLED` 注文中(一部約定), `FULLY_FILLED` 約定済み, `CANCELED_UNFILLED` 取消済, `CANCELED_PARTIALLY_FILLED` 取消済(一部約定) 409 | 410 | **注意事項:** 411 | - circuit_break_info.mode が `NONE` 以外の場合は成行注文を行うことができず、`70020`エラーが返ります。 412 | - circuit_break_info.mode が `NONE` 以外の場合は `post_only` オプションは `false` として扱われます。 413 | 414 | **サンプルコード:** 415 | 416 |
417 | Curl 418 |

419 | 420 | ```sh 421 | export API_KEY=___your api key___ 422 | export API_SECRET=___your api secret___ 423 | export ACCESS_NONCE="$(date +%s)" 424 | export REQUEST_BODY='{"pair": "xrp_jpy", "price": "20", "amount": "1","side": "buy", "type": "limit"}' 425 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 426 | 427 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' -H "Content-Type: application/json" -d ''"$REQUEST_BODY"'' https://api.bitbank.cc/v1/user/spot/order 428 | ``` 429 | 430 |

431 |
432 | 433 | 434 | **レスポンスのフォーマット:** 435 | 436 | ```json 437 | { 438 | "success": 1, 439 | "data": { 440 | "order_id": 0, 441 | "pair": "string", 442 | "side": "string", 443 | "position_side": "string", 444 | "type": "string", 445 | "start_amount": "string", 446 | "remaining_amount": "string", 447 | "executed_amount": "string", 448 | "price": "string", 449 | "post_only": false, 450 | "user_cancelable": true, 451 | "average_price": "string", 452 | "ordered_at": 0, 453 | "expire_at": 0, 454 | "trigger_price": "string", 455 | "status": "string" 456 | } 457 | } 458 | ``` 459 | 460 | #### 注文をキャンセルする 461 | 462 | ```txt 463 | POST /user/spot/cancel_order 464 | ``` 465 | 466 | **Parameters(requestBody):** 467 | 468 | Name | Type | Mandatory | Description 469 | ------------ | ------------ | ------------ | ------------ 470 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 471 | order_id | number | YES | 注文ID 472 | 473 | **Response:** 474 | 475 | Name | Type | Description 476 | ------------ | ------------ | ------------ 477 | order_id | number | order id 478 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 479 | side | string | `buy` または `sell` 480 | position_side | string \| undefined | `long` または `short`(信用取引の時のみ) 481 | type | string | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 482 | start_amount | string \| null | 注文時の数量 483 | remaining_amount | string \| null | 未約定の数量 484 | executed_amount| string | 約定済み数量 485 | price | string \| undefined | 注文価格(type = `limit` または `stop_limit` 時のみ) 486 | post_only | boolean \| undefined | Post Onlyかどうか(type = `limit`時のみ) 487 | user_cancelable | boolean | ユーザがキャンセル可能な注文かどうか 488 | average_price | string | 平均約定価格 489 | ordered_at | number | 注文日時(UnixTimeのミリ秒) 490 | expire_at | number \| null | 有効期限(UnixTimeのミリ秒) 491 | canceled_at | number \| undefined | キャンセル日時(UnixTimeのミリ秒) 492 | triggered_at | number \| undefined | トリガー日時(UnixTimeのミリ秒)(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 493 | trigger_price | string \| undefined | トリガー価格(type = `stop`, `stop_limit`, `take_profit`, `stop_loss` 時のみ) 494 | status | string | 注文ステータス: `INACTIVE` 非アクティブ, `UNFILLED` 注文中, `PARTIALLY_FILLED` 注文中(一部約定), `FULLY_FILLED` 約定済み, `CANCELED_UNFILLED` 取消済, `CANCELED_PARTIALLY_FILLED` 取消済(一部約定) 495 | 496 | **サンプルコード:** 497 | 498 |
499 | Curl 500 |

501 | 502 | ```sh 503 | export API_KEY=___your api key___ 504 | export API_SECRET=___your api secret___ 505 | export ACCESS_NONCE="$(date +%s)" 506 | export REQUEST_BODY='{"pair": "xrp_jpy", "order_id": 1}' 507 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 508 | 509 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' -H "Content-Type: application/json" -d ''"$REQUEST_BODY"'' https://api.bitbank.cc/v1/user/spot/cancel_order 510 | ``` 511 | 512 |

513 |
514 | 515 | 516 | **レスポンスのフォーマット:** 517 | 518 | ```json 519 | { 520 | "success": 1, 521 | "data": { 522 | "order_id": 0, 523 | "pair": "string", 524 | "side": "string", 525 | "type": "string", 526 | "start_amount": "string", 527 | "remaining_amount": "string", 528 | "executed_amount": "string", 529 | "price": "string", 530 | "post_only": false, 531 | "user_cancelable": true, 532 | "average_price": "string", 533 | "ordered_at": 0, 534 | "expire_at": 0, 535 | "canceled_at": 0, 536 | "triggered_at": 0, 537 | "trigger_price": "string", 538 | "status": "string" 539 | } 540 | } 541 | ``` 542 | 543 | #### 注文をキャンセルする(複数) 544 | 545 | ```txt 546 | POST /user/spot/cancel_orders 547 | ``` 548 | 549 | **Parameters(requestBody):** 550 | 551 | Name | Type | Mandatory | Description 552 | ------------ | ------------ | ------------ | ------------ 553 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 554 | order_ids | number[] | YES | 注文ID。最大30個まで指定可能 555 | 556 | **Response:** 557 | 558 | Name | Type | Description 559 | ------------ | ------------ | ------------ 560 | orders | Array | [注文をキャンセルする](#注文をキャンセルする)のレスポンスオブジェクトのリスト 561 | 562 | **Response format:** 563 | 564 | ```json 565 | { 566 | "success": 1, 567 | "data": { 568 | "orders": [ 569 | { 570 | "order_id": 0, 571 | "pair": "string", 572 | "side": "string", 573 | "type": "string", 574 | "start_amount": "string", 575 | "remaining_amount": "string", 576 | "executed_amount": "string", 577 | "price": "string", 578 | "post_only": false, 579 | "user_cancelable": true, 580 | "average_price": "string", 581 | "ordered_at": 0, 582 | "expire_at": 0, 583 | "canceled_at": 0, 584 | "triggered_at": 0, 585 | "trigger_price": "string", 586 | "status": "string" 587 | } 588 | ] 589 | } 590 | } 591 | ``` 592 | 593 | #### 注文情報を取得する(複数) 594 | 595 | ```txt 596 | POST /user/spot/orders_info 597 | ``` 598 | 599 | *POSTメソッド注意* 600 | 601 | **Parameters (requestBody):** 602 | 603 | Name | Type | Mandatory | Description 604 | ------------ | ------------ | ------------ | ------------ 605 | pair | string | YES | 通貨ペア: [ペア一覧](pairs.md) 606 | order_ids | number[] | YES | 注文ID 607 | 608 | **注意事項:** 609 | 610 | * このAPIでは3ヶ月以上前の約定済またはキャンセル済注文を取得できません。(エラーとならず、結果に含まれません。) 611 | 3ヶ月以上前の注文情報の取得にはお手数ですが[注文履歴の抽出ページ](https://app.bitbank.cc/account/data/orders/download)をご利用ください。 612 | 613 | **サンプルコード:** 614 | 615 |
616 | Curl 617 |

618 | 619 | ```sh 620 | export API_KEY=___your api key___ 621 | export API_SECRET=___your api secret___ 622 | export ACCESS_NONCE="$(date +%s)" 623 | export REQUEST_BODY='{"pair": "xrp_jpy", "order_ids": [1]}' 624 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 625 | 626 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' -H "Content-Type: application/json" -d ''"$REQUEST_BODY"'' https://api.bitbank.cc/v1/user/spot/orders_info 627 | ``` 628 | 629 |

630 |
631 | 632 | **Response:** 633 | 634 | Name | Type | Description 635 | ------------ | ------------ | ------------ 636 | orders | Array | [注文情報を取得する](#注文情報を取得する)のレスポンスオブジェクトのリスト 637 | 638 | **レスポンスのフォーマット:** 639 | 640 | ```json 641 | { 642 | "success": 1, 643 | "data": { 644 | "orders": [ 645 | { 646 | "order_id": 0, 647 | "pair": "string", 648 | "side": "string", 649 | "position_side": "string", 650 | "type": "string", 651 | "start_amount": "string", 652 | "remaining_amount": "string", 653 | "executed_amount": "string", 654 | "price": "string", 655 | "post_only": false, 656 | "user_cancelable": true, 657 | "average_price": "string", 658 | "ordered_at": 0, 659 | "expire_at": 0, 660 | "canceled_at": 0, 661 | "triggered_at": 0, 662 | "trigger_price": "string", 663 | "status": "string" 664 | } 665 | ] 666 | } 667 | } 668 | ``` 669 | #### アクティブな注文を取得する 670 | 671 | ```txt 672 | GET /user/spot/active_orders 673 | ``` 674 | 675 | **Parameters:** 676 | 677 | Name | Type | Mandatory | Description 678 | ------------ | ------------ | ------------ | ------------ 679 | pair | string | NO | 通貨ペア: [ペア一覧](pairs.md)。注文IDを指定する場合pairの指定も必須 680 | count | number | NO | 取得する注文数 681 | from_id | number | NO | 取得開始注文ID 682 | end_id | number | NO | 取得終了注文ID 683 | since | number | NO | 開始UNIXタイムスタンプ 684 | end | number | NO | 終了UNIXタイムスタンプ 685 | 686 | **Response:** 687 | 688 | Name | Type | Description 689 | ------------ | ------------ | ------------ 690 | orders | Array | [注文情報を取得する](#注文情報を取得する)のレスポンスオブジェクトのリスト 691 | 692 | **サンプルコード:** 693 | 694 |
695 | Curl 696 |

697 | 698 | ```sh 699 | export API_KEY=___your api key___ 700 | export API_SECRET=___your api secret___ 701 | export ACCESS_NONCE="$(date +%s)" 702 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/spot/active_orders?pair=btc_jpy" | openssl dgst -sha256 -hmac "$API_SECRET")" 703 | 704 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/spot/active_orders?pair=btc_jpy 705 | ``` 706 | 707 |

708 |
709 | 710 | 711 | **レスポンスのフォーマット:** 712 | 713 | ```json 714 | { 715 | "success": 1, 716 | "data": { 717 | "orders": [ 718 | { 719 | "order_id": 0, 720 | "pair": "string", 721 | "side": "string", 722 | "position_side": "string", 723 | "type": "string", 724 | "start_amount": "string", 725 | "remaining_amount": "string", 726 | "executed_amount": "string", 727 | "price": "string", 728 | "post_only": false, 729 | "user_cancelable": true, 730 | "average_price": "string", 731 | "ordered_at": 0, 732 | "expire_at": 0, 733 | "triggered_at": 0, 734 | "trigger_price": "string", 735 | "status": "string" 736 | } 737 | ] 738 | } 739 | } 740 | ``` 741 | 742 | ### 建玉情報 743 | 744 | #### 建玉・追証・不足金額情報を取得する 745 | 746 | ```txt 747 | GET /user/margin/positions 748 | ``` 749 | 750 | **Parameters(requestBody):** 751 | None 752 | 753 | **Response:** 754 | 755 | Name | Type | Description 756 | ------------ | ------------ | ------------ 757 | notice | { what: string \| null, occurred_at: number \| null, amount: string \| null, due_date_at: number \| null } | `追証` または `不足金` または `精算` に関する情報 758 | payables | { amount: string } | 不足金額 759 | positions | [{ pair: string, position_side: string, open_amount: string, product: string, average_price: string, unrealized_fee_amount: string, unrealized_interest_amount: string }] | 建玉情報 760 | losscut_threshold | { individual: string, company: string } | 強制決済掛け目 761 | 762 | **サンプルコード:** 763 | 764 |
765 | Curl 766 |

767 | 768 | ```sh 769 | export API_KEY=___your api key___ 770 | export API_SECRET=___your api secret___ 771 | export ACCESS_NONCE="$(date +%s)" 772 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/margin/positions" | openssl dgst -sha256 -hmac "$API_SECRET")" 773 | 774 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/margin/positions 775 | ``` 776 | 777 |

778 |
779 | 780 | 781 | **レスポンスのフォーマット:** 782 | 783 | ```json 784 | { 785 | "success": 1, 786 | "data": { 787 | "notice": { 788 | "what": "string", 789 | "occurred_at": 0, 790 | "amount": "0", 791 | "due_date_at": 0 792 | }, 793 | "payables": { 794 | "amount": "0" 795 | }, 796 | "positions": [ 797 | { 798 | "pair": "string", 799 | "position_side": "string", 800 | "open_amount": "0", 801 | "product": "0", 802 | "average_price": "0", 803 | "unrealized_fee_amount": "0", 804 | "unrealized_interest_amount": "0" 805 | } 806 | ], 807 | "losscut_threshold": { 808 | "individual": "0", 809 | "company": "0" 810 | } 811 | } 812 | } 813 | ``` 814 | 815 | 816 | ### 約定履歴 817 | 818 | #### 約定履歴を取得する 819 | 820 | ```txt 821 | GET /user/spot/trade_history 822 | ``` 823 | 824 | **Parameters:** 825 | 826 | Name | Type | Mandatory | Description 827 | ------------ | ------------ | ------------ | ------------ 828 | pair | string | NO | 通貨ペア: [ペア一覧](pairs.md)。注文IDを指定する場合pairの指定も必須 829 | count | number | NO | 取得する約定数(最大1000) 830 | order_id | number | NO | 注文ID 831 | since | number | NO | 開始UNIXタイムスタンプ(ミリ秒) 832 | end | number | NO | 終了UNIXタイムスタンプ(ミリ秒) 833 | order | string | NO | 約定時刻順序(`asc`: 昇順、`desc`: 降順、デフォルト`desc`) 834 | 835 | **Response:** 836 | 837 | Name | Type | Description 838 | ------------ | ------------ | ------------ 839 | trade_id | number | trade id 840 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 841 | order_id | number | 注文ID 842 | side | string | `buy` または `sell` 843 | position_side | string \| undefined | `long` または `short`(信用取引の時のみ) 844 | type | string | `limit`、`market`、`stop`、`stop_limit`、`take_profit`、`stop_loss`, `losscut`のうちいずれか 845 | amount | string | 注文量 846 | price | string | 価格 847 | maker_taker | string | `maker` または `taker` 848 | fee_amount_base | string | base手数料 849 | fee_amount_quote | string | quote手数料 850 | fee_occurred_amount_quote | string | quote発生手数料。後ほど徴収される。現物取引ではfee_amount_quoteと同値。 851 | profit_loss | string \| undefined | 実現損益 852 | interest | string \| undefined | 利息 853 | executed_at | number | 約定日時(UnixTimeのミリ秒) 854 | 855 | **サンプルコード:** 856 | 857 |
858 | Curl 859 |

860 | 861 | ```sh 862 | export API_KEY=___your api key___ 863 | export API_SECRET=___your api secret___ 864 | export ACCESS_NONCE="$(date +%s)" 865 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/spot/trade_history?pair=btc_jpy" | openssl dgst -sha256 -hmac "$API_SECRET")" 866 | 867 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/spot/trade_history?pair=btc_jpy 868 | ``` 869 | 870 |

871 |
872 | 873 | 874 | **レスポンスのフォーマット:** 875 | 876 | ```json 877 | { 878 | "success": 1, 879 | "data": { 880 | "trades": [ 881 | { 882 | "trade_id": 0, 883 | "pair": "string", 884 | "order_id": 0, 885 | "side": "string", 886 | "position_side": "string", 887 | "type": "string", 888 | "amount": "string", 889 | "price": "string", 890 | "maker_taker": "string", 891 | "fee_amount_base": "string", 892 | "fee_amount_quote": "string", 893 | "profit_loss": "string", 894 | "interest": "string", 895 | "executed_at": 0 896 | } 897 | ] 898 | } 899 | } 900 | ``` 901 | 902 | ### 入金 903 | 904 | #### 入金履歴を取得する 905 | 906 | ```txt 907 | GET /user/deposit_history 908 | ``` 909 | 910 | **Parameters:** 911 | 912 | Name | Type | Mandatory | Description 913 | ------------ | ------------ | ------------ | ------------ 914 | asset | string | YES | アセット名: [アセット一覧](assets.md) 915 | count | number | NO | 取得する履歴数(最大100) 916 | since | number | NO | 開始UNIXタイムスタンプ(ミリ秒) 917 | end | number | NO | 終了UNIXタイムスタンプ(ミリ秒) 918 | 919 | **Response:** 920 | 921 | Name | Type | Description 922 | ------------ | ------------ | ------------ 923 | uuid | string | 入金識別uuid 924 | address | string | 入金address 925 | asset | string | アセット名: [アセット一覧](assets.md) 926 | network | string | ネットワーク名: [ネットワーク一覧](networks.md) 927 | amount | number | 入金数量 928 | txid | string \| null | 入金トランザクションID(暗号資産の時のみ) 929 | status | string | 入金状態: `FOUND`, `CONFIRMED`, `DONE` 930 | found_at | number | 検知UNIXタイムスタンプ(ミリ秒) 931 | confirmed_at | number | 承認(残高追加確定時)UNIXタイムスタンプ(ミリ秒、承認後のみ存在) 932 | 933 | **注意事項:** 934 | 935 | * 現時点では入金履歴レスポンスには宛先タグ、メモおよび銀行口座情報が含まれていません。他システムの送金・送信との突合にはtxidをお使いください。 936 | 937 | **サンプルコード:** 938 | 939 |
940 | Curl 941 |

942 | 943 | ```sh 944 | export API_KEY=___your api key___ 945 | export API_SECRET=___your api secret___ 946 | export ACCESS_NONCE="$(date +%s)" 947 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/deposit_history?asset=btc" | openssl dgst -sha256 -hmac "$API_SECRET")" 948 | 949 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/deposit_history?asset=btc 950 | ``` 951 | 952 |

953 |
954 | 955 | 956 | **レスポンスのフォーマット:** 957 | 958 | ```json 959 | { 960 | "success": 1, 961 | "data": { 962 | "deposits": [ 963 | { 964 | "uuid": "string", 965 | "asset": "string", 966 | "network": "string", 967 | "amount": "string", 968 | "txid": "string", 969 | "status": "string", 970 | "found_at": 0, 971 | "confirmed_at": 0 972 | } 973 | ] 974 | } 975 | } 976 | ``` 977 | 978 | #### 未反映入金を取得する 979 | 980 | ```txt 981 | GET /user/unconfirmed_deposits 982 | ``` 983 | 984 | **Parameters:** 985 | None 986 | 987 | **Response:** 988 | 989 | Name | Type | Description 990 | ------------ | ------------ | ------------ 991 | uuid | string | 未反映入金 uuid 992 | asset | string | アセット名: [アセット一覧](assets.md) 993 | amount | string | 入金数量 994 | network | string | ネットワーク名: [ネットワーク一覧](networks.md) 995 | txid | string | 入金トランザクションID 996 | created_at | number| 作成UNIXタイムスタンプ(ミリ秒) 997 | 998 | **Sample code:** 999 | 1000 |
1001 | Curl 1002 |

1003 | 1004 | ```sh 1005 | export API_KEY=___your api key___ 1006 | export API_SECRET=___your api secret___ 1007 | export ACCESS_NONCE="$(date +%s)" 1008 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/unconfirmed_deposits" | openssl dgst -sha256 -hmac "$API_SECRET")" 1009 | 1010 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/unconfirmed_deposits 1011 | ``` 1012 | 1013 |

1014 |
1015 | 1016 | 1017 | **Response format:** 1018 | 1019 | ```json 1020 | { 1021 | "success": 1, 1022 | "data": { 1023 | "deposits": [ 1024 | { 1025 | "uuid": "string", 1026 | "asset": "string", 1027 | "amount": "string", 1028 | "network": "string", 1029 | "txid": "string", 1030 | "created_at": 0 1031 | } 1032 | ] 1033 | } 1034 | } 1035 | ``` 1036 | 1037 | #### 送付人を取得する 1038 | 1039 | ```txt 1040 | GET /user/deposit_originators 1041 | ``` 1042 | 1043 | **Parameters:** 1044 | None 1045 | 1046 | **Response:** 1047 | 1048 | Name | Type | Description 1049 | ------------ | ------------ | ------------ 1050 | uuid | string | 送付人のuuid 1051 | label | string | 送付人ラベル 1052 | deposit_type | string | 入金元: `WALLET` プライベートウォレット, `ELSE` その他 1053 | deposit_purpose | string \| null | 入金の目的 1054 | originator_status | string | 送付人ステータス: `SCREENING` 審査中, `CONFIRMED` 審査完了, `REJECTED` 否認, `DEPRECATED` 要修正 1055 | originator_type | string | 送付人種別: `OWN` 本人, `PERSON` 本人でない個人, `COMPANY` 本人でない法人 1056 | originator_last_name | string \| null | 姓 1057 | originator_first_name | string \| null | 名 1058 | originator_country | string \| null | 国 1059 | originator_prefecture | string \| null | 都市・省・県 1060 | originator_city | string \| null | 市区町村 1061 | originator_address | string \| null | 番地 1062 | originator_building | string \| null | 建物名 1063 | originator_company_name | string \| null | 法人名称 1064 | originator_company_type | string \| null | 法人格 1065 | originator_company_type_position | string \| null | 法人格(前後) 1066 | uuid | string | 実質的支配者のuuid 1067 | name | string | 実質的支配者 1068 | country | string | 実質的支配者の居住国 1069 | prefecture | string \| null | 実質的支配者の居住地域(都市・省・県) 1070 | 1071 | **Sample code:** 1072 | 1073 |
1074 | Curl 1075 |

1076 | 1077 | ```sh 1078 | export API_KEY=___your api key___ 1079 | export API_SECRET=___your api secret___ 1080 | export ACCESS_NONCE="$(date +%s)" 1081 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/deposit_originators" | openssl dgst -sha256 -hmac "$API_SECRET")" 1082 | 1083 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/deposit_originators 1084 | ``` 1085 | 1086 |

1087 |
1088 | 1089 | 1090 | **Response format:** 1091 | 1092 | ```json 1093 | { 1094 | "success": 1, 1095 | "data": { 1096 | "originators": [ 1097 | { 1098 | "uuid": "string", 1099 | "label": "string", 1100 | "deposit_type": "string", 1101 | "deposit_purpose": "string", 1102 | "originator_status": "string", 1103 | "originator_type": "string", 1104 | "originator_last_name": null, 1105 | "originator_first_name": null, 1106 | "originator_country": "string", 1107 | "originator_preference": "string", 1108 | "originator_city": "string", 1109 | "originator_address": "string", 1110 | "originator_building": null, 1111 | "originator_company_name": "string", 1112 | "originator_company_type": "string", 1113 | "originator_company_type_position": "string", 1114 | "originator_substantial_controllers": [ 1115 | { 1116 | "uuid": "string", 1117 | "name": "string", 1118 | "country": "string", 1119 | "prefecture": null 1120 | } 1121 | ] 1122 | } 1123 | ] 1124 | } 1125 | } 1126 | ``` 1127 | 1128 | #### 未反映入金に送付人を登録する 1129 | 1130 | ```txt 1131 | POST /user/confirm_deposits 1132 | ``` 1133 | 1134 | **Parameters (requestBody):** 1135 | 1136 | Name | Type | Mandatory | Description 1137 | ------------ | ------------ | ------------ | ------------ 1138 | deposits | object[] | YES | 未反映入金uuidと送付人uuidオブジェクトの配列。内容の詳細は以下。 1139 | 1140 | **depositsの詳細** 1141 | 1142 | Name | Type | Mandatory | Description 1143 | ------------ | ------------ | ------------ | ------------ 1144 | uuid | string | YES | 未反映入金 uuid 1145 | originator_uuid | string | YES | 送付人 uuid 1146 | 1147 | **Request format:** 1148 | 1149 | ```json 1150 | { 1151 | "deposits": [ 1152 | { 1153 | "uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 1154 | "originator_uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 1155 | }, 1156 | { 1157 | "uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 1158 | "originator_uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 1159 | }, 1160 | { 1161 | … 1162 | } 1163 | ] 1164 | } 1165 | ``` 1166 | 1167 | **Response:** 1168 | None 1169 | 1170 | **Sample code:** 1171 | 1172 |
1173 | Curl 1174 |

1175 | 1176 | ```sh 1177 | export API_KEY=___your api key___ 1178 | export API_SECRET=___your api secret___ 1179 | export ACCESS_NONCE="$(date +%s)" 1180 | export REQUEST_BODY='{"deposits": [{ "uuid": "___deposit uuid___", "originator_uuid": "___originator uuid___" }]}' 1181 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 1182 | 1183 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' -H "Content-Type: application/json" -d ''"$REQUEST_BODY"'' https://api.bitbank.cc/v1/user/confirm_deposits 1184 | ``` 1185 | 1186 |

1187 |
1188 | 1189 | 1190 | **Response format:** 1191 | 1192 | ```json 1193 | { 1194 | "success": 1, 1195 | "data": {} 1196 | } 1197 | ``` 1198 | 1199 | #### 未反映入金に送付人を一括登録する 1200 | 1201 | ```txt 1202 | POST /user/confirm_deposits_all 1203 | ``` 1204 | 1205 | **Parameters (requestBody):** 1206 | 1207 | Name | Type | Mandatory | Description 1208 | ------------ | ------------ | ------------ | ------------ 1209 | originator_uuid | string | YES | 送付人uuid 1210 | 1211 | **Response:** 1212 | None 1213 | 1214 | **Sample code:** 1215 | 1216 |
1217 | Curl 1218 |

1219 | 1220 | ```sh 1221 | export API_KEY=___your api key___ 1222 | export API_SECRET=___your api secret___ 1223 | export ACCESS_NONCE="$(date +%s)" 1224 | export REQUEST_BODY='{"originator_uuid": "___originator uuid___"}' 1225 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 1226 | 1227 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' -H "Content-Type: application/json" -d ''"$REQUEST_BODY"'' https://api.bitbank.cc/v1/user/confirm_deposits_all 1228 | ``` 1229 | 1230 |

1231 |
1232 | 1233 | 1234 | **Response format:** 1235 | 1236 | ```json 1237 | { 1238 | "success": 1, 1239 | "data": {} 1240 | } 1241 | ``` 1242 | 1243 | ### 出金 1244 | 1245 | #### 出金アカウントを取得する 1246 | 1247 | ```txt 1248 | GET /user/withdrawal_account 1249 | ``` 1250 | 1251 | **Parameters:** 1252 | 1253 | Name | Type | Mandatory | Description 1254 | ------------ | ------------ | ------------ | ------------ 1255 | asset | string | YES | アセット名: [アセット一覧](assets.md) 1256 | 1257 | **Response:** 1258 | 1259 | Name | Type | Description 1260 | ------------ | ------------ | ------------ 1261 | uuid | string | 出金アカウントのID 1262 | label | string | ラベル 1263 | network | string | ネットワーク名: [ネットワーク一覧](networks.md) 1264 | address | string | 出金先アドレス 1265 | 1266 | **サンプルコード:** 1267 | 1268 |
1269 | Curl 1270 |

1271 | 1272 | ```sh 1273 | export API_KEY=___your api key___ 1274 | export API_SECRET=___your api secret___ 1275 | export ACCESS_NONCE="$(date +%s)" 1276 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/withdrawal_account?asset=btc" | openssl dgst -sha256 -hmac "$API_SECRET")" 1277 | 1278 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/withdrawal_account?asset=btc 1279 | ``` 1280 | 1281 |

1282 |
1283 | 1284 | 1285 | **レスポンスのフォーマット:** 1286 | 1287 | ```json 1288 | { 1289 | "success": 1, 1290 | "data": { 1291 | "accounts": [ 1292 | { 1293 | "uuid": "string", 1294 | "label": "string", 1295 | "network": "string", 1296 | "address": "string" 1297 | } 1298 | ] 1299 | } 1300 | } 1301 | ``` 1302 | #### 出金リクエストを行う 1303 | 1304 | ```txt 1305 | POST /user/request_withdrawal 1306 | ``` 1307 | 1308 | **Parameters (requestBody):** 1309 | 1310 | Name | Type | Mandatory | Description 1311 | ------------ | ------------ | ------------ | ------------ 1312 | asset | string | YES | アセット名: [アセット一覧](assets.md) 1313 | uuid | string | YES | 出金アカウントのuuid 1314 | amount | string | YES | 出金数量 1315 | otp_token | string | NO | 二段階認証トークン(設定している場合、otp_tokenかsms_tokenのどちらか一方を指定) 1316 | sms_token | string | NO | SMS認証トークン 1317 | 1318 | **Response:** 1319 | 1320 | Name | Type | Description 1321 | ------------ | ------------ | ------------ 1322 | uuid | string | 出金識別ID 1323 | asset | string | アセット名: [アセット一覧](assets.md) 1324 | account_uuid | string | 出金アカウントのID 1325 | amount | string | 出金数量 1326 | fee | string | 出金手数料 1327 | label | string | 出金先アドレスにつけたラベル(暗号資産の時のみ) 1328 | address | string | 出金先アドレス(暗号資産の時のみ) 1329 | network | string | ネットワーク名(暗号資産の時のみ): [ネットワーク一覧](networks.md) 1330 | destination_tag | number or string | 出金先宛先タグまたはメモ(タグまたはメモを指定した暗号資産の出金時のみ) 1331 | txid | string \| null | 出金トランザクションID(暗号資産の時のみ) 1332 | bank_name | string | 出金先銀行(法定通貨の時のみ) 1333 | branch_name | string | 出金先銀行支店(法定通貨の時のみ) 1334 | account_type | string | 出金先口座種別(法定通貨の時のみ) 1335 | account_number | string | 出金先口座番号(法定通貨の時のみ) 1336 | account_owner | string | 出金先口座名義(法定通貨の時のみ) 1337 | status | string | `CONFIRMING`, `EXAMINING`, `SENDING`, `DONE`, `REJECTED`, `CANCELED`, `CONFIRM_TIMEOUT` 1338 | requested_at | number | リクエスト日時UNIXタイムスタンプ(ミリ秒) 1339 | 1340 | **サンプルコード:** 1341 | 1342 |
1343 | Curl 1344 |

1345 | 1346 | ```sh 1347 | export API_KEY=___your api key___ 1348 | export API_SECRET=___your api secret___ 1349 | export ACCESS_NONCE="$(date +%s)" 1350 | export REQUEST_BODY='{"asset": "xrp", "uuid": "___your uuid___", "amount": "1"}' 1351 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET")" 1352 | 1353 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' -H "Content-Type: application/json" -d ''"$REQUEST_BODY"'' https://api.bitbank.cc/v1/user/request_withdrawal 1354 | ``` 1355 | 1356 |

1357 |
1358 | 1359 | 1360 | **レスポンスのフォーマット:** 1361 | 1362 | ```json 1363 | { 1364 | "success": 1, 1365 | "data": { 1366 | "uuid": "string", 1367 | "asset": "string", 1368 | "account_uuid": "string", 1369 | "amount": "string", 1370 | "fee": "string", 1371 | 1372 | "label": "string", 1373 | "address": "string", 1374 | "network": "string", 1375 | "txid": "string", 1376 | "destination_tag": 0, 1377 | 1378 | "bank_name": "string", 1379 | "branch_name": "string", 1380 | "account_type": "string", 1381 | "account_number": "string", 1382 | "account_owner": "string", 1383 | 1384 | "status": "string", 1385 | "requested_at": 0 1386 | } 1387 | } 1388 | ``` 1389 | #### 出金履歴を取得する 1390 | 1391 | ```txt 1392 | GET /user/withdrawal_history 1393 | ``` 1394 | 1395 | **Parameters:** 1396 | 1397 | Name | Type | Mandatory | Description 1398 | ------------ | ------------ | ------------ | ------------ 1399 | asset | string | YES | アセット名: [アセット一覧](assets.md) 1400 | count | number | NO | 取得する履歴数(最大100) 1401 | since | number | NO | 開始UNIXタイムスタンプ(ミリ秒) 1402 | end | number | NO | 終了UNIXタイムスタンプ(ミリ秒) 1403 | 1404 | **Response:** 1405 | 1406 | Name | Type | Description 1407 | ------------ | ------------ | ------------ 1408 | uuid | string | 出金識別ID 1409 | asset | string | アセット名: [アセット一覧](assets.md) 1410 | account_uuid | string | 出金アカウントのID 1411 | amount | string | 出金数量 1412 | fee | string | 出金手数料 1413 | label | string | 出金先アドレスにつけたラベル(暗号資産の時のみ) 1414 | address | string | 出金先アドレス(暗号資産の時のみ) 1415 | network | string | ネットワーク名(暗号資産の時のみ): [ネットワーク一覧](networks.md) 1416 | destination_tag | number or string | 出金先宛先タグまたはメモ(タグまたはメモを指定した暗号資産の出金時のみ) 1417 | txid | string \| null | 出金トランザクションID(暗号資産の時のみ) 1418 | bank_name | string | 出金先銀行(法定通貨の時のみ) 1419 | branch_name | string | 出金先銀行支店(法定通貨の時のみ) 1420 | account_type | string | 出金先口座種別(法定通貨の時のみ) 1421 | account_number | string | 出金先口座番号(法定通貨の時のみ) 1422 | account_owner | string | 出金先口座名義(法定通貨の時のみ) 1423 | status | string | `CONFIRMING`, `EXAMINING`, `SENDING`, `DONE`, `REJECTED`, `CANCELED`, `CONFIRM_TIMEOUT` 1424 | requested_at | number | リクエスト日時UNIXタイムスタンプ(ミリ秒) 1425 | 1426 | **サンプルコード:** 1427 | 1428 |
1429 | Curl 1430 |

1431 | 1432 | ```sh 1433 | export API_KEY=___your api key___ 1434 | export API_SECRET=___your api secret___ 1435 | export ACCESS_NONCE="$(date +%s)" 1436 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/withdrawal_history?asset=btc" | openssl dgst -sha256 -hmac "$API_SECRET")" 1437 | 1438 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/withdrawal_history?asset=btc 1439 | ``` 1440 | 1441 |

1442 |
1443 | 1444 | 1445 | **レスポンスのフォーマット:** 1446 | 1447 | ```json 1448 | { 1449 | "success": 1, 1450 | "data": { 1451 | "withdrawals": [ 1452 | { 1453 | "uuid": "string", 1454 | "asset": "string", 1455 | "account_uuid": "string", 1456 | "amount": "string", 1457 | "fee": "string", 1458 | 1459 | "label": "string", 1460 | "address": "string", 1461 | "network": "string", 1462 | "txid": "string", 1463 | "destination_tag": 0, 1464 | 1465 | "bank_name": "string", 1466 | "branch_name": "string", 1467 | "account_type": "string", 1468 | "account_number": "string", 1469 | "account_owner": "string", 1470 | 1471 | "status": "string", 1472 | "requested_at": 0 1473 | } 1474 | ] 1475 | } 1476 | } 1477 | ``` 1478 | 1479 | ### 取引所ステータス 1480 | 1481 | #### 取引所ステータスを取得する 1482 | 1483 | *当該APIは認証不要となります。* 1484 | 1485 | ```txt 1486 | GET /spot/status 1487 | ``` 1488 | 1489 | **Parameters:** 1490 | None 1491 | 1492 | **Response:** 1493 | 1494 | Name | Type | Description 1495 | ------------ | ------------ | ------------ 1496 | pair | string | 通貨ペア: [ペア一覧](pairs.md) 1497 | status | string | 取引所ステータス: `NORMAL`, `BUSY`, `VERY_BUSY`, `HALT` 1498 | min_amount| string | 取引所ステータスに応じた最小注文数量(負荷が高いほど大きくなります) 1499 | 1500 | **サンプルコード:** 1501 | 1502 |
1503 | Curl 1504 |

1505 | 1506 | ```sh 1507 | curl https://api.bitbank.cc/v1/spot/status 1508 | ``` 1509 | 1510 |

1511 |
1512 | 1513 | 1514 | **レスポンスのフォーマット:** 1515 | 1516 | ```json 1517 | { 1518 | "success": 1, 1519 | "data": { 1520 | "statuses": [ 1521 | { 1522 | "pair": "string", 1523 | "status": "string", 1524 | "min_amount": "string" 1525 | } 1526 | ] 1527 | } 1528 | } 1529 | ``` 1530 | 1531 | ### 銘柄詳細 1532 | 1533 | #### 銘柄詳細一覧を取得する 1534 | 1535 | *当該APIは認証不要となります。* 1536 | 1537 | ```txt 1538 | GET /spot/pairs 1539 | ``` 1540 | 1541 | **Parameters:** 1542 | None 1543 | 1544 | **Response:** 1545 | 1546 | Name | Type | Description 1547 | ------------ | ------------ | ------------ 1548 | name | string | 通貨ペア: [ペア一覧](pairs.md) 1549 | base_asset | string | 原資産 1550 | quote_asset | string | クオート資産 1551 | maker_fee_rate_base | string | メイカー手数料率(原資産) 1552 | taker_fee_rate_base | string | テイカー手数料率(原資産) 1553 | maker_fee_rate_quote | string | メイカー手数料率(クオート資産) 1554 | taker_fee_rate_quote | string | テイカー手数料率(クオート資産) 1555 | margin_open_maker_fee_rate_quote | string \| null | 新規建てmaker手数料率(クオート資産) 1556 | margin_open_taker_fee_rate_quote | string \| null | 新規建てtaker手数料率(クオート資産) 1557 | margin_close_maker_fee_rate_quote | string \| null | 決済maker手数料率(クオート資産) 1558 | margin_close_taker_fee_rate_quote | string \| null | 決済maker手数料率(クオート資産) 1559 | margin_long_interest | string \| null | ロング利息率/日 1560 | margin_short_interest | string \| null | ショート利息率/日 1561 | margin_current_individual_ratio | string \| null | 現在の個人のリスク想定比率 1562 | margin_current_individual_until | number \| null | 現在の個人のリスク想定比率の適用終了日時(UnixTimeのミリ秒) 1563 | margin_current_company_ratio | string \| null | 現在の法人のリスク想定比率 1564 | margin_current_company_until | number \| null | 現在の法人のリスク想定比率の適用終了日時(UnixTimeのミリ秒) 1565 | margin_next_individual_ratio | string \| null | 次の個人のリスク想定比率 1566 | margin_next_individual_until | number \| null | 次の個人のリスク想定比率の適用終了日時(UnixTimeのミリ秒) 1567 | margin_next_company_ratio | string \| null | 次の法人のリスク想定比率 1568 | margin_next_company_until | number \| null | 次の法人のリスク想定比率の適用終了日時(UnixTimeのミリ秒) 1569 | unit_amount | string | 最小注文数量 1570 | limit_max_amount | string | 最大注文数量 1571 | market_max_amount | string | 成行注文時の最大数量 1572 | market_allowance_rate | string | 成行買注文時の余裕率 1573 | price_digits | number | 価格切り捨て対象桁数(0起点) 1574 | amount_digits | number | 数量切り捨て対象桁数(0起点) 1575 | is_enabled | boolean | 通貨ペアステータス(有効/無効) 1576 | stop_order | boolean | 注文停止ステータス 1577 | stop_order_and_cancel | boolean | 注文および注文キャンセル停止ステータス 1578 | stop_market_order | boolean | 成行注文停止ステータス 1579 | stop_stop_order | boolean | 逆指値(成行)注文停止ステータス 1580 | stop_stop_limit_order | boolean | 逆指値(指値)注文停止ステータス 1581 | stop_margin_long_order | boolean | ロング新規建て注文停止ステータス 1582 | stop_margin_short_order | boolean | ショート新規建て注文停止ステータス 1583 | stop_buy_order | boolean | 買い注文停止ステータス 1584 | stop_sell_order | boolean | 売り注文停止ステータス 1585 | 1586 | **サンプルコード:** 1587 | 1588 |
1589 | Curl 1590 |

1591 | 1592 | ```sh 1593 | curl https://api.bitbank.cc/v1/spot/pairs 1594 | ``` 1595 | 1596 |

1597 |
1598 | 1599 | 1600 | **レスポンスのフォーマット:** 1601 | 1602 | ```json 1603 | { 1604 | "success": 1, 1605 | "data": { 1606 | "pairs": [ 1607 | { 1608 | "name": "string", 1609 | "base_asset": "string", 1610 | "maker_fee_rate_base": "string", 1611 | "taker_fee_rate_base": "string", 1612 | "maker_fee_rate_quote": "string", 1613 | "taker_fee_rate_quote": "string", 1614 | "margin_open_maker_fee_rate_quote": "string", 1615 | "margin_open_taker_fee_rate_quote": "string", 1616 | "margin_close_maker_fee_rate_quote": "string", 1617 | "margin_close_taker_fee_rate_quote": "string", 1618 | "margin_long_interest": "string", 1619 | "margin_short_interest": "string", 1620 | "margin_current_individual_ratio": "string", 1621 | "margin_current_individual_until": 0, 1622 | "margin_current_company_ratio": "string", 1623 | "margin_current_company_until": 0, 1624 | "margin_next_individual_ratio": "string", 1625 | "margin_next_individual_until": 0, 1626 | "margin_next_company_ratio": "string", 1627 | "margin_next_company_until": 0, 1628 | "unit_amount": "string", 1629 | "limit_max_amount": "string", 1630 | "market_max_amount": "string", 1631 | "market_allowance_rate": "string", 1632 | "price_digits": 0, 1633 | "amount_digits": 0, 1634 | "is_enabled": true, 1635 | "stop_order": false, 1636 | "stop_order_and_cancel": false, 1637 | "stop_market_order": false, 1638 | "stop_stop_order": false, 1639 | "stop_stop_limit_order": false, 1640 | "stop_margin_long_order": false, 1641 | "stop_margin_short_order": false, 1642 | "stop_buy_order": false, 1643 | "stop_sell_order": false 1644 | } 1645 | ] 1646 | } 1647 | } 1648 | ``` 1649 | 1650 | ### プライベートストリーム 1651 | 1652 | #### プライベートストリームのチャンネルとトークンを取得する 1653 | 1654 | プライベートストリームのチャンネルとトークンを取得します。 1655 | チャンネルとトークンの使い方は[こちら](private-stream_JP.md)を参照してください。 1656 | 1657 | pubnub_channelは、ユーザごとに異なるチャンネル名が割り当てられます。 1658 | pubnub_tokenには12時間の有効期限が設定されています。 1659 | pubnub_tokenの有効期限が切れると、PubNubとの接続が切断されるため、再度このAPIを呼び出して新しいpubnub_tokenを取得してください。 1660 | 1661 | ```txt 1662 | GET /user/subscribe 1663 | ``` 1664 | 1665 | **Parameters:** 1666 | None 1667 | 1668 | **Response:** 1669 | 1670 | Name | Type | Description 1671 | ------------ | ------------ | ------------ 1672 | pubnub_channel | string | チャンネル 1673 | pubnub_token | string | トークン 1674 | 1675 | **サンプルコード:** 1676 | 1677 |
1678 | Curl 1679 |

1680 | 1681 | ```sh 1682 | export API_KEY=___your api key___ 1683 | export API_SECRET=___your api secret___ 1684 | export ACCESS_NONCE="$(date +%s)" 1685 | export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/subscribe" | openssl dgst -sha256 -hmac "$API_SECRET")" 1686 | 1687 | curl -H 'ACCESS-KEY:'"$API_KEY"'' -H 'ACCESS-NONCE:'"$ACCESS_NONCE"'' -H 'ACCESS-SIGNATURE:'"$ACCESS_SIGNATURE"'' https://api.bitbank.cc/v1/user/subscribe 1688 | ``` 1689 | 1690 |

1691 |
1692 | 1693 | 1694 | **レスポンスのフォーマット:** 1695 | 1696 | ```json 1697 | { 1698 | "success": 1, 1699 | "data": { 1700 | "pubnub_channel": "string", 1701 | "pubnub_token": "string" 1702 | } 1703 | } 1704 | ``` 1705 | --------------------------------------------------------------------------------