### ACCESS-TIME-WINDOW Example (GET) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Demonstrates how to generate a signature for a GET request using the ACCESS-TIME-WINDOW authentication method. This involves setting environment variables for API secret, request time, and time window, then calculating the signature. ```APIDOC ## ACCESS-TIME-WINDOW Example (GET) ### Description This example shows how to construct a signature for a GET request using the `ACCESS-TIME-WINDOW` authentication parameter. It involves setting up environment variables for your API secret, the current request time, and a time window, then using these to generate a SHA256 HMAC signature. ### Method GET ### Endpoint /v1/user/assets ### Parameters None explicitly shown for this example, but authentication parameters are required. ### Request Example ```bash export API_SECRET="hoge" export ACCESS_REQUEST_TIME="1721121776490" export ACCESS_TIME_WINDOW="1000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_REQUEST_TIME$ACCESS_TIME_WINDOW/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" echo $ACCESS_SIGNATURE ``` ### Response Example ``` 9ec5745960d05573c8fb047cdd9191bd0c6ede26f07700bb40ecf1a3920abae8 ``` ``` -------------------------------- ### ACCESS-NONCE Example (GET) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Shows how to create a signature for a GET request using the ACCESS-NONCE authentication. This method uses a nonce value instead of a timestamp for signature generation. ```APIDOC ## ACCESS-NONCE Example (GET) ### Description This example illustrates the process of generating a signature for a GET request using the `ACCESS-NONCE` authentication method. Instead of a timestamp, a nonce value is used in the signature calculation. ### Method GET ### Endpoint /v1/user/assets ### Parameters None explicitly shown for this GET request, but authentication parameters are required. ### Request Example ```bash export API_SECRET="hoge" export ACCESS_NONCE="1721121776490" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" echo $ACCESS_SIGNATURE ``` ### Response Example ``` f957817b95c3af6cf5e2e9dfe1503ea8088f46879d4ab73051467fd7b94f1aba ``` ``` -------------------------------- ### ACCESS-NONCE Example (POST) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Provides an example of generating a signature for a POST request using ACCESS-NONCE, incorporating the request body into the signature calculation. ```APIDOC ## ACCESS-NONCE Example (POST) ### Description This example demonstrates how to generate a signature for a POST request using the `ACCESS-NONCE` authentication. The request body is included in the signature calculation along with the nonce. ### Method POST ### Endpoint (Example POST endpoint, specific path not provided in source) ### Parameters None explicitly shown for this example, but authentication parameters and a request body are required. ### Request Example ```bash export API_SECRET="hoge" export ACCESS_NONCE="1721121776490" export REQUEST_BODY='{"pair": "xrp_jpy", "price": "20", "amount": "1","side": "buy", "type": "limit"}' export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" echo $ACCESS_SIGNATURE ``` ### Response Example ``` 8ef83c2b991765b18c95aade7678471747c06890a23a453c76238345b5c86fb8 ``` ``` -------------------------------- ### Get All Spot Pairs Info Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Retrieves comprehensive information about all available spot trading pairs. This endpoint does not require authentication. ```txt GET /spot/pairs ``` ```sh curl "https://api.bitbank.cc/v1/spot/pairs" ``` -------------------------------- ### Connect to Private Stream and Receive User Data Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/private-stream.md This JavaScript code demonstrates how to connect to a private stream using PubNub to receive user data. It includes setup for API keys, PubNub subscription, and real-time order status updates. Ensure you have the 'pubnub' package installed. ```javascript // npm install pubnub const PubNub = require('pubnub'); const crypto = require('crypto'); const API_KEY = ''; const API_SECRET = ''; const PUBNUB_SUB_KEY = 'sub-c-ecebae8e-dd60-11e6-b6b1-02ee2ddab7fe'; const store = new Map(); // status only changes in the direction from 0 to 3 const STATUS_STAGE = { INACTIVE: 0, UNFILLED: 1, PARTIALLY_FILLED: 2, FULLY_FILLED: 3, CANCELED_PARTIALLY_FILLED: 3, CANCELED_UNFILLED: 3, } const main = async () => { const { channel, token } = await getChannelAndToken(); const pubnub = getPubNubAndAddListener(channel, token); subscribePrivateChannel(pubnub, channel, token); // If the status becomes 3 (inactive), remove it from the store after 1 minute setInterval(() => { const now = new Date().getTime(); store.forEach((value, key) => { if (now - value.last_update_at > 60 * 1000 && STATUS_STAGE[value.status] === 3) { store.delete(key); } }); console.log('store:', store); }, 60 * 1000); } const toSha256 = (key, value) =>{ return crypto .createHmac('sha256', key) .update(Buffer.from(value)) .digest('hex') .toString(); } const getPubNubAndAddListener = (channel, token) => { const pubnub = new PubNub({ subscribeKey: PUBNUB_SUB_KEY, userId: channel, ssl: true, }); /** * Note: In some SDKs, there are separate message receiving methods on the subscription instance in addition to addListener. * Using both may result in messages being delivered to only one handler. * It is recommended to handle both status and message events within addListener. * * The following are not recommended: * JavaScript: subscription.onMessage * Java: subscription.setOnMessage * C#: subscription.OnMessage * Ruby: subscription.on_message * etc. */ pubnub.addListener({ status: async (status) => { switch (status.category) { /** * When pubnub channel connection established successfully. * This is called once after trying to start to connect. */ case 'PNConnectedCategory': { console.info('pubnub connection established'); break; } /** * When connection restored. */ case 'PNNetworkUpCategory': case 'PNReconnectedCategory': { console.info('pubnub connection restored'); // When network down, pubnub disposes subscribers so we need to re-subscribe manually. subscribePrivateChannel(pubnub_channel, token); break; } /** * When connection failed by timeout. * In this case, we need to reconnect manually. */ case 'PNTimeoutCategory': { console.warn('pubnub connection Failed by timeout.'); await reconnect(); break; } /** * When connection failed due to network error. */ case 'PNNetworkDownCategory': case 'PNNetworkIssuesCategory': { console.error('pubnub connection network error', status); await reconnect(); break; } /** * This will be called when token is expired. */ case 'PNAccessDeniedCategory': { console.error('pubnub access denied', status); await reconnect(); break; } /** * This will not be called. * Maybe pubnub-library is not implement these events. */ case 'PNBadRequestCategory': case 'PNMalformedResponseCategory': case 'PNDecryptionErrorCategory': { console.error('pubnub connection failed', status); break; } /** * This will not be called. * If this called, implement new handling for the event. */ default: { console.warn('default'); } } }, // Since message order is not guaranteed, only the most up-to-date order status should remain in the store, even if order messages arrive out of sequence. // When an order message arrives, check the store: if it doesn't exist, add it; if it does, update only if the order status has progressed. message: (data) => { if (data && data.message) { console.info('message received', JSON.stringify(data.message)); } if (data.message.method === 'spot_order_new' || data.message.method === 'spot_order') { const order = data.message.params[0]; if (!store.has(order.order_id)) { store.set(order.order_id, { status: order.status, remaining_amount: order.remaining_amount, last_update_at: new Date().getTime(), }); } else { const last = store.get(order.order_id); ``` -------------------------------- ### Generate ACCESS-TIME-WINDOW Signature for GET Request Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md This snippet shows how to generate a signature for a GET request using ACCESS-TIME-WINDOW. Ensure API_SECRET, ACCESS_REQUEST_TIME, and the endpoint path are correctly set. ```bash export API_SECRET="hoge" export ACCESS_REQUEST_TIME="1721121776490" export ACCESS_TIME_WINDOW="1000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_REQUEST_TIME$ACCESS_TIME_WINDOW/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" echo $ACCESS_SIGNATURE 9ec5745960d05573c8fb047cdd9191bd0c6ede26f07700bb40ecf1a3920abae8 ``` -------------------------------- ### ACCESS-TIME-WINDOW Example (POST) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Illustrates signature generation for a POST request using ACCESS-TIME-WINDOW. It includes the request body in the signature calculation, alongside the request time and time window. ```APIDOC ## ACCESS-TIME-WINDOW Example (POST) ### Description This example demonstrates how to generate a signature for a POST request using the `ACCESS-TIME-WINDOW` authentication. The request body is included in the signature calculation along with the request time and time window. ### Method POST ### Endpoint (Example POST endpoint, specific path not provided in source) ### Parameters None explicitly shown for this example, but authentication parameters and a request body are required. ### Request Example ```bash export API_SECRET="hoge" export ACCESS_REQUEST_TIME="1721121776490" export ACCESS_TIME_WINDOW="1000" export REQUEST_BODY='{"pair": "xrp_jpy", "price": "20", "amount": "1","side": "buy", "type": "limit"}' export ACCESS_SIGNATURE="$(echo -n "$ACCESS_REQUEST_TIME$ACCESS_TIME_WINDOW$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" echo $ACCESS_SIGNATURE ``` ### Response Example ``` 7868665738ae3f8a796224e0413c1351ddd7ec2af121db12815c0a5b74b8764c ``` ``` -------------------------------- ### Generate ACCESS-NONCE Signature for GET Request Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md This snippet shows how to generate a signature for a GET request using ACCESS-NONCE. Ensure API_SECRET, ACCESS_NONCE, and the endpoint path are correctly set. ```bash export API_SECRET="hoge" export ACCESS_NONCE="1721121776490" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" echo $ACCESS_SIGNATURE f957817b95c3af6cf5e2e9dfe1503ea8088f46879d4ab73051467fd7b94f1aba ``` -------------------------------- ### Curl Request to Get User Assets Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md This is a sample cURL command to fetch the user's asset list. It requires setting API_KEY, API_SECRET, and generating ACCESS_NONCE and ACCESS_SIGNATURE. ```bash export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" curl -H "ACCESS-KEY: $API_KEY" -H "ACCESS-NONCE: $ACCESS_NONCE" -H "ACCESS-SIGNATURE: $ACCESS_SIGNATURE" "https://api.bitbank.cc/v1/user/assets" ``` -------------------------------- ### Connect to WebSocket and Subscribe to Circuit Break Info Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-stream.md Connect to the Bitbank WebSocket stream and subscribe to circuit break information for a specific trading pair. This example uses wscat to demonstrate the connection and message flow. ```shell $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' connected (press CTRL+C to quit) < 0{"sid":"PG3FbI0WrKIP7hKMABH_","upgrades":[],"pingInterval":25000,"pingTimeout":60000} > 40 < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} > 42["join-room","circuit_break_info_xrp_jpy"] < 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}}}] < 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}}}] ... ``` -------------------------------- ### Get all pairs info Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Retrieves information about all available trading pairs on the bitbank platform. This endpoint does not require authentication. ```APIDOC ## GET /spot/pairs ### Description Retrieves information about all available trading pairs on the bitbank platform. ### Method GET ### Endpoint /spot/pairs ### Parameters None ### Response #### Success Response (200) - **name** (string) - pair enum: [pair list](pairs.md) - **base_asset** (string) - base asset - **quote_asset** (string) - quote asset - **maker_fee_rate_base** (string) - maker fee (base asset) - **taker_fee_rate_base** (string) - taker fee (base asset) - **maker_fee_rate_quote** (string) - maker fee (quote asset) - **taker_fee_rate_quote** (string) - taker fee (quote asset) - **margin_open_maker_fee_rate_quote** (string | null) - open maker fee (quote asset) - **margin_open_taker_fee_rate_quote** (string | null) - open taker fee (quote asset) - **margin_close_maker_fee_rate_quote** (string | null) - close maker fee (quote asset) - **margin_close_taker_fee_rate_quote** (string | null) - close taker fee (quote asset) - **margin_long_interest** (string | null) - long position interest/day - **margin_short_interest** (string | null) - short position interest/day - **margin_current_individual_ratio** (string | null) - current individual risk assumption ratio - **margin_current_individual_until** (number | null) - current application end date and time of individual risk assumption ratio(unix timestamp milliseconds) - **margin_current_company_ratio** (string | null) - current company risk assumption ratio - **margin_current_company_until** (number | null) - current application end date and time of company risk assumption ratio(unix timestamp milliseconds) - **margin_next_individual_ratio** (string | null) - next individual risk assumption ratio - **margin_next_individual_until** (number | null) - next application end date and time of individual risk assumption ratio(unix timestamp milliseconds) - **margin_next_company_ratio** (string | null) - next company risk assumption ratio - **margin_next_company_until** (number | null) - curnextrent application end date and time of company risk assumption ratio(unix timestamp milliseconds) - **unit_amount** (string) - minimum order amount - **limit_max_amount** (string) - max order amount - **market_max_amount** (string) - market order max amount - **market_allowance_rate** (string) - market order allowance rate - **price_digits** (number) - price digits count - **amount_digits** (number) - amount digits count - **is_enabled** (boolean) - pair enable flag - **stop_order** (boolean) - order suspended flag - **stop_order_and_cancel** (boolean) - order and cancel suspended flag - **stop_market_order** (boolean) - "market order" suspended flag - **stop_stop_order** (boolean) - "stop (market) order" suspended flag - **stop_stop_limit_order** (boolean) - "stop limit order" suspended flag - **stop_margin_long_order** (boolean) - open long positions suspended flag - **stop_margin_short_order** (boolean) - open short positions suspended flag - **stop_buy_order** (boolean) - "buy order" suspended flag - **stop_sell_order** (boolean) - "sell order" suspended flag #### Response Example ```json { "success": 1, "data": { "pairs": [ { "name": "string", "base_asset": "string", "maker_fee_rate_base": "string", "taker_fee_rate_base": "string", "maker_fee_rate_quote": "string", "taker_fee_rate_quote": "string", "margin_open_maker_fee_rate_quote": "string", "margin_open_taker_fee_rate_quote": "string", "margin_close_maker_fee_rate_quote": "string", "margin_close_taker_fee_rate_quote": "string", "margin_long_interest": "string", "margin_short_interest": "string", "margin_current_individual_ratio": "string", "margin_current_individual_until": 0, "margin_current_company_ratio": "string", "margin_current_company_until": 0, "margin_next_individual_ratio": "string", "margin_next_individual_until": 0, "margin_next_company_ratio": "string", "margin_next_company_until": 0, "unit_amount": "string", "limit_max_amount": "string", "market_max_amount": "string", "market_allowance_rate": "string", "price_digits": 0, "amount_digits": 0, "is_enabled": true, "stop_order": false, "stop_order_and_cancel": false, "stop_market_order": false, "stop_stop_order": false, "stop_stop_limit_order": false, "stop_margin_long_order": false, "stop_margin_short_order": false, "stop_buy_order": false, "stop_sell_order": false } ] } } ``` ``` -------------------------------- ### Get Private Channel and Token Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/private-stream_JP.md Fetches the private channel and token required for subscribing to real-time updates. Ensure API_KEY and API_SECRET are correctly configured. ```javascript const getChannelAndToken = async () => { const nonce = new Date().getTime(); const timeWindow = '5000'; const message = `${nonce}${timeWindow}/v1/user/subscribe`; // Get channel and token from API const res = await fetch('https://api.bitbank.cc/v1/user/subscribe', { method: 'GET', headers: { 'Content-Type': 'application/json', 'ACCESS-KEY': API_KEY, 'ACCESS-REQUEST-TIME': nonce.toString(), 'ACCESS-TIME-WINDOW': timeWindow, 'ACCESS-SIGNATURE': toSha256(API_SECRET, message), }, }).then((res) => res.json()); const channel = res.data.pubnub_channel; const token = res.data.pubnub_token; return { channel, token }; } ``` -------------------------------- ### GET /:pair/। Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-api_JP.md Retrieves circuit breaker information for a specific trading pair. ```APIDOC ## GET /:pair/circuit_break ### Description Retrieves circuit breaker information for a specific trading pair. ### Method GET ### Endpoint `https://public.bitbank.cc/:pair/circuit_break` ### Parameters #### Path Parameters - **pair** (string) - Required - Trading pair (e.g., btc_jpy) ### Response #### Success Response (200) - **mode** (string) - The current circuit breaker mode. - **।** (string) - Estimated price. #### Response Example ```json { "success": 1, "data": { "mode": "string", "।": "string" } } ``` ``` -------------------------------- ### Fetch Active Orders (Curl) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md This snippet demonstrates how to fetch active orders using a GET request. You can filter by pair, count, order ID, and time range. ```shell export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/spot/active_orders?pair=btc_jpy" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" 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" ``` -------------------------------- ### GET /user/assets Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Retrieves a list of the user's assets, including their free amounts, locked amounts, and withdrawal details. This endpoint is used for querying asset information. ```APIDOC ## GET /user/assets ### Description This endpoint returns a list of the user's assets. It provides details such as the available free amount, the locked amount, and information related to withdrawals and deposits, including network-specific statuses and fees. ### Method GET ### Endpoint /v1/user/assets ### Parameters None ### Request Example ```sh export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/assets" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" curl -H "ACCESS-KEY: $API_KEY" -H "ACCESS-NONCE: $ACCESS_NONCE" -H "ACCESS-SIGNATURE: $ACCESS_SIGNATURE" "https://api.bitbank.cc/v1/user/assets" ``` ### Response #### Success Response (200) - **assets** (array) - List of user's assets. - **asset** (string) - Asset enum: [asset list](assets.md) - **free_amount** (string) - Free amount available. - **amount_precision** (number) - Precision for the amount. - **onhand_amount** (string) - Total amount on hand. - **locked_amount** (string) - Amount that is currently locked. - **withdrawing_amount** (string) - Amount currently being withdrawn. - **withdrawal_fee** (object) - Withdrawal fee details. Can be `{ min: string, max: string }` or `{ under: string, over: string, threshold: string }` for `jpy`. - **stop_deposit** (boolean) - Deposit status. `true` indicates deposits are stopped for all networks. - **stop_withdrawal** (boolean) - Withdrawal status. `true` indicates withdrawals are stopped for all networks. - **network_list** (array or undefined) - Network list for the asset. Contains objects with `asset`, `network`, `stop_deposit`, `stop_withdrawal`, and `withdrawal_fee`. Undefined for `jpy`. - **collateral_ratio** (string) - Collateral ratio. #### Response Example ```json { "success": 1, "data": { "assets": [ { "asset": "string", "free_amount": "string", "amount_precision": 0, "onhand_amount": "string", "locked_amount": "string", "withdrawing_amount": "string", "withdrawal_fee": { "min": "string", "max": "string" }, "stop_deposit": false, "stop_withdrawal": false, "network_list": [ { "asset": "string", "network": "string", "stop_deposit": false, "stop_withdrawal": false, "withdrawal_fee": "string" } ], "collateral_ratio": "string" }, { "asset": "jpy", "free_amount": "string", "amount_precision": 0, "onhand_amount": "string", "locked_amount": "string", "withdrawing_amount": "string", "withdrawal_fee": { "under": "string", "over": "string", "threshold": "string" }, "stop_deposit": false, "stop_withdrawal": false, "collateral_ratio": "string" } ] } } ``` ``` -------------------------------- ### Get Private Channel and Token Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/private-stream.md Fetches the PubNub channel and token from the Bitbank API for private channel subscription. Requires API key and secret for authentication. ```javascript const getChannelAndToken = async () => { const nonce = new Date().getTime(); const timeWindow = '5000'; const message = `${nonce}${timeWindow}/v1/user/subscribe`; const res = await fetch('https://api.bitbank.cc/v1/user/subscribe', { method: 'GET', headers: { 'Content-Type': 'application/json', 'ACCESS-KEY': API_KEY, 'ACCESS-REQUEST-TIME': nonce.toString(), 'ACCESS-TIME-WINDOW': timeWindow, 'ACCESS-SIGNATURE': toSha256(API_SECRET, message), }, }).then((res) => res.json()); const channel = res.data.pubnub_channel; const token = res.data.pubnub_token; return { channel, token }; } ``` -------------------------------- ### Get Channel and Token for Private Stream (Curl) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Use this cURL command to authenticate and request a channel and token for private streams. Ensure your API key, secret, and nonce are correctly set. The token has a TTL of 12 hours and requires re-acquisition upon expiration. ```sh export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/subscribe" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" curl -H "ACCESS-KEY: $API_KEY" -H "ACCESS-NONCE: $ACCESS_NONCE" -H "ACCESS-SIGNATURE: $ACCESS_SIGNATURE" "https://api.bitbank.cc/v1/user/subscribe" ``` -------------------------------- ### Get Ticker Data for All Pairs Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-api_JP.md Retrieve ticker information for all available currency pairs. Similar to single-pair tickers, sell prices might be less than or equal to buy prices in certain modes. ```http GET /tickers ``` -------------------------------- ### Get Circuit Break Info Endpoint Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-api.md Use this GET request to retrieve circuit break status for a specific trading pair. The pair must be specified in the URL. ```http GET /{pair}/circuit_break_info ``` -------------------------------- ### Create Spot Order using cURL Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md This snippet demonstrates how to create a new spot order using cURL. Ensure your API key, secret, and nonce are set as environment variables. The request body specifies order details like pair, price, amount, side, and type. ```sh export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export REQUEST_BODY='{"pair": "xrp_jpy", "price": "20", "amount": "1","side": "buy", "type": "limit"}' export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" 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" ``` -------------------------------- ### GET /user/unconfirmed_deposits Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Fetches a list of unconfirmed deposits. This endpoint does not require any parameters. ```APIDOC ## GET /user/unconfirmed_deposits ### Description Fetches a list of unconfirmed deposits. This endpoint does not require any parameters. ### Method GET ### Endpoint /user/unconfirmed_deposits ### Response #### Success Response (200) - **uuid** (string) - deposit uuid - **asset** (string) - enum: [asset list](assets.md) - **amount** (string) - deposit amount - **network** (string) - enum: [network list](networks.md) - **txid** (string) - deposit transaction id - **created_at** (number) - created at unix timestamp (milliseconds) #### Response Example { "success": 1, "data": { "deposits": [ { "uuid": "string", "asset": "string", "amount": "string", "network": "string", "txid": "string", "created_at": 0 } ] } } ``` -------------------------------- ### Subscribe to Private Channel with PubNub Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/private-stream.md Initializes PubNub, adds listeners, and subscribes to a private channel using provided channel and token. Requires PubNub SDK. ```javascript const getPubNubAndAddListener = (channel, token) => { const pubnub = new PubNub({ publishKey: "demo", subscribeKey: "demo", uuid: "my-uuid", }); pubnub.addListener({ message: (payload) => { const last = store.get(payload.message.order_id); if (!last) { store.set(payload.message.order_id, { status: payload.message.status, remaining_amount: payload.message.remaining_amount, last_update_at: new Date().getTime(), }); } else if (STATUS_STAGE[last.status] < STATUS_STAGE[payload.message.status] || (STATUS_STAGE[last.status] === STATUS_STAGE[payload.message.status] && last.remaining_amount > payload.message.remaining_amount)) { store.set(payload.message.order_id, { status: payload.message.status, remaining_amount: payload.message.remaining_amount, last_update_at: new Date().getTime(), }); } }, }); pubnub.subscribe({ channels: [channel], }); return pubnub; } ``` -------------------------------- ### Fetch Order Information using Curl Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md This snippet demonstrates how to fetch order information using cURL. Ensure your API key, secret, and nonce are correctly set, and the signature is generated properly. This API cannot fetch orders older than 3 months. ```shell export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE/v1/user/spot/order?pair=btc_jpy&order_id=1" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" 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" ``` -------------------------------- ### GET /:pair/executions Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-api_JP.md Retrieves the trade execution history for a specific trading pair. ```APIDOC ## GET /:pair/executions ### Description Retrieves the trade execution history for a specific trading pair. ### Method GET ### Endpoint `https://public.bitbank.cc/:pair/executions` ### Parameters #### Path Parameters - **pair** (string) - Required - Trading pair (e.g., btc_jpy) ### Response #### Success Response (200) - **executions** (array) - An array of trade executions, each with price, size, and timestamp. - **।** (boolean) - Whether there are more executions available. #### Response Example ```json { "success": 1, "data": { "executions": [ { "price": "string", "size": "string", "।": 0 } ], "।": true } } ``` ``` -------------------------------- ### GET /:pair/candlestick Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-api_JP.md Retrieves candlestick (OHLCV) data for a specific trading pair over a specified period. ```APIDOC ## GET /:pair/candlestick ### Description Retrieves candlestick (OHLCV) data for a specific trading pair over a specified period. ### Method GET ### Endpoint `https://public.bitbank.cc/:pair/candlestick` ### Parameters #### Path Parameters - **pair** (string) - Required - Trading pair (e.g., btc_jpy) #### Query Parameters - **।** (string) - Required - Candlestick interval (e.g., 1min, 5min, 15min, 30min, 1hour, 4hour, 12hour, 1day, 1week, 1month). - **।** (number) - Optional - Unix timestamp (milliseconds) for the start of the period. - **।** (number) - Optional - Unix timestamp (milliseconds) for the end of the period. ### Response #### Success Response (200) - **candlestick** (array) - An array of candlestick data, each containing open, high, low, close, volume, and timestamp. #### Response Example ```json { "success": 1, "data": { "candlestick": [ { "open": "string", "high": "string", "low": "string", "close": "string", "।": "string", "timestamp": 0 } ] } } ``` ``` -------------------------------- ### Subscribe to Real-time Depth Data with wscat Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-stream.md Connect to the Bitbank WebSocket API to receive real-time depth updates for a specified trading pair. Ensure the EIO and transport parameters are correctly set in the WebSocket URL. ```sh $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' connected (press CTRL+C to quit) < 0{"sid":"PR6GLrwlEFjzHIPrABBM","upgrades":[],"pingInterval":25000,"pingTimeout":60000} > 40 < 40{"sid":"lUkRb31kqoS9cLMc0W"} > 42["join-room","depth_whole_xrp_jpy"] < 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"], ...]}}}] ``` -------------------------------- ### Confirm All Deposits (cURL) Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Use this cURL command to confirm all deposits for a given originator UUID. Ensure your API key, secret, and nonce are set as environment variables. ```sh export API_KEY=___your api key___ export API_SECRET=___your api secret___ export ACCESS_NONCE="$(date +%s)000" export REQUEST_BODY='{"originator_uuid": "___originator uuid___"}' export ACCESS_SIGNATURE="$(echo -n "$ACCESS_NONCE$REQUEST_BODY" | openssl dgst -sha256 -hmac "$API_SECRET" | awk '{print $NF}')" 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" ``` -------------------------------- ### Create new order Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/rest-api.md Allows users to create a new spot order. Supports various order types including limit, market, stop, and more. Includes options for post-only orders and specifies details about the order parameters and response structure. ```APIDOC ## POST /user/spot/order ### Description Creates a new spot order with specified details. This endpoint supports various order types and configurations, including optional parameters like `post_only` and `trigger_price`. ### Method POST ### Endpoint /user/spot/order ### Parameters #### Request Body - **pair** (string) - YES - pair enum: [pair list](pairs.md) - **amount** (string) - NO - amount. required if type is other than `take_profit`, `stop_loss` - **price** (string) - NO - price - **side** (string) - YES - `buy` or `sell` - **position_side** (string) - NO - `long` or `short` - **type** (string) - YES - one of `limit`, `market`, `stop`, `stop_limit`, `take_profit`, `stop_loss`, `losscut` - **post_only** (boolean) - NO - Post Only (`true` can be specified only if type = `limit`. default `false`) - **trigger_price** (string) - NO - trigger price ### Response #### Success Response (200) - **order_id** (number) - order id - **pair** (string) - pair enum: [pair list](pairs.md) - **side** (string) - `buy` or `sell` - **position_side** (string | undefined) - `long` or `short`(only for margin trading) - **type** (string) - one of `limit`, `market`, `stop`, `stop_limit`, `take_profit`, `stop_loss`, `losscut` - **start_amount** (string | null) - order qty when placed - **remaining_amount** (string | null) - qty not executed - **executed_amount** (string) - qty executed - **price** (string | undefined) - order price (present only if type = `limit` or `stop_limit`) - **post_only** (boolean | undefined) - whether Post Only or not (present only if type = `limit`) - **user_cancelable** (boolean) - whether cancelable order or not - **average_price** (string) - avg executed price - **ordered_at** (number) - ordered at unix timestamp (milliseconds) - **expire_at** (number | null) - expiration time in unix timestamp (milliseconds) - **trigger_price** (string | undefined) - trigger price (present only if type = `stop`, `stop_limit`, `take_profit`, `stop_loss`) - **status** (string) - status enum: `INACTIVE`, `UNFILLED`, `PARTIALLY_FILLED`, `FULLY_FILLED`, `CANCELED_UNFILLED`, `CANCELED_PARTIALLY_FILLED` ### Request Example ```json { "pair": "xrp_jpy", "price": "20", "amount": "1", "side": "buy", "type": "limit" } ``` ### Response Example ```json { "success": 1, "data": { "order_id": 0, "pair": "string", "side": "string", "position_side": "string", "type": "string", "start_amount": "string", "remaining_amount": "string", "executed_amount": "string", "price": "string", "post_only": false, "user_cancelable": true, "average_price": "string", "ordered_at": 0, "expire_at": 0, "trigger_price": "string", "status": "string" } } ``` ### Caveats - Except for circuit_break_info.mode is `NONE`, market orders are restricted. If restricted, it returns 70020 error code. - `post_only` option is treated as `false` except, circuit_break_info.mode is `NONE`. ``` -------------------------------- ### GET /candlestick/{candle-type}/{YYYY} Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-api.md Retrieves candlestick information for a given trading pair, candle type, and date. ```APIDOC ## GET /{pair}/candlestick/{candle-type}/{YYYY} ### Description Get candlestick information. ### Method GET ### Endpoint `/{pair}/candlestick/{candle-type}/{YYYY}` ### Parameters #### Path Parameters - **pair** (string) - Required - pair enum: [pair list](pairs.md) - **candle-type** (string) - Required - candle type enum: `1min`, `5min`, `15min`, `30min`, `1hour`, `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` - **YYYY** (string) - Required - date formatted as `YYYY` or `YYYYMMDD` **Note:** YYYY Format depends on the candle-type: - `YYYYMMDD`: `1min`, `5min`, `15min`, `30min`, `1hour` - `YYYY`: `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` ### Response #### Success Response (200) - **type** (string) - candle type enum: `1min`, `5min`, `15min`, `30min`, `1hour`, `4hour`, `8hour`, `12hour`, `1day`, `1week`, `1month` - **ohlcv** (string[][], number[]) - [open, high, low, close, volume, **unix timestamp (milliseconds)**] - **timestamp** (number) - published at unix timestamp (milliseconds) #### Response Example ```json { "success": 1, "data": { "candlestick": [ { "type": "string", "ohlcv": [ [ "string", "string", "string", "string", "string", 0 ] ], "timestamp": 0 } ] } } ``` ``` -------------------------------- ### Connect to Depth Diff Channel with wscat Source: https://github.com/bitbankinc/bitbank-api-docs/blob/master/public-stream.md Use this command to connect to the Depth Diff WebSocket channel using wscat. Subscribe to a specific pair like 'depth_diff_xrp_jpy' to receive updates. ```sh $ wscat -c 'wss://stream.bitbank.cc/socket.io/?EIO=4&transport=websocket' connected (press CTRL+C to quit) < 0{"sid":"9-zd3P1G-BNu_w37ABMX","upgrades":[],"pingInterval":25000,"pingTimeout":60000} > 40 < 40{"sid":"lUkRb31kqoS9cLPNMc0W"} > 42["join-room","depth_diff_xrp_jpy"] < 42["message",{"room_name":"depth_diff_xrp_jpy","message":{"data":{"a":[],"b":[["26.758","20000.0000"],["26.212","0"]],"t":1570080269609,"s":"1234567890"}}}] < 42["message",{"room_name":"depth_diff_xrp_jpy","message":{"data":{"a":[],"b":[["26.212","1000.0000"],["26.815","0"]],"t":1570080270100,"s":"1234567893"}}}] ... ```