json

Change Log

Version 1.0 (19th November 2021)

Overview

Generating API Key

You will need to create an API key on the BTSE platform before you can use authenticated APIs. To create API keys, you can follow the steps below:

Endpoints

Streaming OTC quote

Authentication

Workflow

Streaming OTC

Websocket Streams

Authentication

Request

{
  "op":"authKeyExpires",
  "args":["APIKey", "nonce", "signature"]}
}

Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:

Our subscription request will be:

{
  "op":"authKeyExpires",
  "args":["4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x", "1624985375123", "c410d38c681579adb335885800cff24c66171b7cc8376cfe43da1408c581748156b89bcc5a115bb496413bda481139fb"]}
}

Request Parameters

Below details the arguments needed to be sent in.

Index Type Required Description
0 string Yes First argument is the API key
1 long Yes Nonce which is the current timestamp
2 string Yes Generated signature

Generating a signature

echo -n "/ws/otc1624985375123"  | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
(stdin)= c410d38c681579adb335885800cff24c66171b7cc8376cfe43da1408c581748156b89bcc5a115bb496413bda481139fb

Quote Stream

Request

{
  "op": "quote",
  "symbol": "BTC-USD",
  "clOrderId": "ClientOrder1",
  "quantity": {
    "quantity": 1,
    "currency": "BTC"
  }
}

Response

{
  "topic": "quote",
  "buyQuoteId": "015f05ba-1d55-46d7-94d9-214229414ae7",
  "sellQuoteId": "0683a41a-a2ad-467b-99b3-241f3ab0cec4",
  "clOrderId": null,
  "buyQuantity": 10,
  "buyUnitPrice": 47865.580838,
  "buyTotalAmount": 478655.80838,
  "sellQuantity": 10,
  "sellUnitPrice": 47649.40351972,
  "sellTotalAmount": 476494.0352,
  "status": null,
  "reason": null
}

Receive quote streams by subscribing to the quote websocket. The websocket topic will constantly push new prices to the subscriber. To accept the quote, indicate the buy or sell quote Id using the /accept API.

Request Parameters

Name Type Required Description
op string Yes Operation, in this case its quote
symbol string Yes Market symbol, refer to getMarkets API
clOrderId string No Client custom order Id
quantity double Yes Order quantity
currency string Yes Can be either in the base or quote currency. If specified in the base currency, then the quote stream will respond with

Response Content

Name Type Required Description
topic string Yes Websocket topic
buyQuoteId string Yes Quote Id for the buy side. If the value is empty / null, it means that you websocket stream is not authenticated
sellQuoteId string Yes Quote Id for the sell side. If the value is empty / null, it means that you websocket stream is not authenticated
clOrderId string Yes User customer Order Id
buyQuantity double Yes Quantity to purchase based on the quote request
buyUnitPrice double Yes Unit price per unit of the base symbol
buyTotalAmount double Yes Total price to pay in quote currency
sellQuantity double Yes Quantity to sell based on the quote request
sellUnitPrice double Yes Unit price per unit of the base symbol
sellTotalAmount double Yes Total price to pay in quote currency
status string No Status of the response
reason string No If an error is returned, the reason field will contain the reasons for the error