HitBTC API Guide PHP
HitBTC API Guide PHP
Table of contents
SUMMARY
— Currency symbols
RESTFUL API
— Market data
— Trading
— Payment
SOCKET.IO API
— Market Data
STREAMING API
— Market data
— Trading
— Sample code
Exapmles
— PHP Library
— NodeJs
Summary
Este documento proporciona la referencia completa para la API de HitBTC.
HitBTC API tiene varias interfaces para implementarlas en un software personalizado:
Trading and payment operations require user's authentication: each request or message
should have a signature. You should get your API key and Secret key on the Settings
page. See details in RESTful API authentication and WebSocket API authentication.
Currency symbols
Size representation:
RESTful API
RESTful API provides the most functional access to HitBTC facilities. RESTful API
allows:
access to the market data: get ticker, order book, trades, etc. See Market data
RESTful API
performing trading operations: get trading balance, place or cancel orders, get
history, etc. See Trading RESTful API
managing funds: get balance of the main account, transfer funds between main
and trading accounts, create an outgoing transactions, etc. See Payment RESTful
API
HitBTC provides a demo trading option. You can enable demo mode and acquire
demo API keys on the Settings page.
Demo endpoint address: http://demo-api.hitbtc.com
Trading and payment operations require authentication. See also error codes and reports
representing order status changes.
/api/1/public/time
Example: /api/1/public/time
Example response:
{
"timestamp": 1393492619000
}
/api/1/public/symbols
Summary: Simbols returns the actual list of currency symbols traded on HitBTC
exchange with their characteristics:
Field Description
Field Description
symbol Symbol name
step Price step parameter
lot Lot size parameter
currency Value of this symbol
commodity Second value of this symbol
takeLiquidityRate Liquidity taker fee
provideLiquidityRate Liquidity provider rebate
Example: /api/1/public/symbols
Example response:
{
"symbols": [
{
"symbol": "BTCUSD",
"step": "0.01",
"lot": "0.01",
"currency": "USD",
"commodity": "BTC",
"takeLiquidityRate": "0.002",
"provideLiquidityRate": "0.002"
},
{
"symbol": "BTCEUR",
"step": "0.01",
"lot": "0.01",
"currency": "EUR",
"commodity": "BTC",
"takeLiquidityRate": "0.002",
"provideLiquidityRate": "0.002"
},
...
]
}
/api/1/public/:symbol/ticker
Summary: returns the actual data on exchange rates of the specified cryptocurrency.
Example: /api/1/public/BTCUSD/ticker
Example response:
{
"last": "550.73",
"bid": "549.56",
"ask": "554.12",
"high": "600.1",
"low": "400.7",
"volume": "567.9",
"open": "449.73",
"volume_quote": "289002.81",
"timestamp": 1393492619000
Field Description
last Last price
bid Highest buy order
ask Lowest sell order
high Highest trade price per last 24h + last incomplete minute
low Lowest trade price per last 24h + last incomplete minute
volume Volume per last 24h + last incomplete minute
open Price in which instrument open
volume_quote Volume in second currency per last 24h + last incomplete minute
timestamp Server time in UNIX timestamp format
/api/1/public/ticker
Summary: returns the actual data on exchange rates for all traded cryptocurrencies - all
tickers.
Example: /api/1/public/ticker
Example response:
{
"BCNBTC": {
"ask": "0.000000039",
"bid": "0.000000036",
"last": "0.000000037",
"low": "0.000000035",
"high": "0.000000048",
"volume": "580790000",
"volume_quote": "26.000000000",
"timestamp": 1409907025743
},
"BTCEUR": {
"ask": "378.23",
"bid": "376.28",
"last": "376.29",
"low": "362.48",
"high": "382.13",
"volume": "961.71",
"volume_quote": "361328.13",
"timestamp": 1409907025743
},
"BTCUSD": {
"ask": "489.26",
"bid": "488.08",
"last": "489.31",
"low": "478.01",
"high": "496.23",
"volume": "404.20",
"volume_quote": "197735.83",
"timestamp": 1409907025743
}
....
}
/api/1/public/:symbol/orderbook
Summary: returns a list of open orders for specified currency symbol: their prices and
sizes.
Parameters:
Example: /api/1/public/BTCUSD/orderbook
Example response:
{
"asks": [
[ "405.71", "0.09" ],
[ "406.65", "0.06" ],
[ "409.51", "0.15" ],
[ "413.93", "51.6" ],
[ "414.59", "47.1" ]
],
"bids": [
[ "398.3", "0.15" ],
[ "396.99", "0.13" ],
[ "395", "0.5" ],
[ "391.93", "42.4" ],
[ "383.67", "145.4" ]
]
}
Example:
/api/1/public/BTCUSD/orderbook?format_price=number&format_amount=numbe
r
Example response:
{
"asks": [
[ 405.71, 0.09 ],
[ 406.65, 0.06 ],
[ 409.51, 0.15 ],
[ 413.93, 51.6 ],
[ 414.59, 47.1 ]
],
"bids": [
[ 398.3, 0.15 ],
[ 396.99, 0.13 ],
[ 395, 0.5 ],
[ 391.93, 42.4 ],
[ 383.67, 145.4 ]
]
}
/api/1/public/:symbol/trades
Parameters:
Alias:
/api/1/request/:symbol/trades.json?since=<trade_id> ->
/api/1/public/:symbol/trades?from=<trade_id>&by=trade_id&start_index=0
&format_numbers=number&format_tradeid=string&format_objects=object&for
mat_timestamp=second
Example:
/api/1/public/BTCUSD/trades?from=0&by=trade_id&sort=desc&start_index=0
&max_results=100
Example response:
{
"trades": [
[ 3814483, "575.64", "0.02", 1393492619000 ],
[ 3814482, "574.3", "0.12", 1393492619000 ],
[ 3814481, "573.67", "3.8", 1393492619000 ],
[ 3814479, "571", "0.01", 1393492619000 ],
...
]
}
Example:
/api/1/public/BTCUSD/trades?from=0&by=trade_id&sort=desc&start_index=0
&max_results=100&format_item=object&format_price=number&format_amount=
number&format_tid=string&format_timestamp=second&format_wrap=false
Example response:
[
{"date": 1393492619, "price": 575.64, "amount": 0.02, "tid":
"3814483"},
{"date": 1393492619, "price": 574.3, "amount": 0.12, "tid":
"3814482"},
{"date": 1393492619, "price": 573.67, "amount": 3.8, "tid":
"3814481"},
{"date": 1393492619, "price": 571, "amount": 0.01, "tid":
"3814479"},
...
]
/api/1/public/:symbol/trades/recent
Parameters:
Example:
/api/1/public/LTCEUR/trades/recent?max_results=100&format_item=object
Example response:
{"trades":[
{"date":1411045690003,"price":"442.12","amount":"0.09","tid":1413901,"
side":"buy"},
{"date":1411045690003,"price":"442.02","amount":"0.60","tid":1413900,"
side":"buy"},
{"date":1411045690003,"price":"441.57","amount":"0.19","tid":1413899,"
side":"buy"},
{"date":1411045635556,"price":"442.00","amount":"0.42","tid":1413889,"
side":"buy"},
{"date":1411045635556,"price":"441.59","amount":"0.19","tid":1413888,"
side":"buy"},
{"date":1411045635556,"price":"441.59","amount":"0.39","tid":1413887,"
side":"buy"},
{"date":1411045621329,"price":"442.00","amount":"0.01","tid":1413882,"
side":"buy"},
{"date":1411045621329,"price":"442.00","amount":"0.32","tid":1413881,"
side":"buy"},
{"date":1411045621329,"price":"441.57","amount":"0.28","tid":1413880,"
side":"buy"},
{"date":1411045621329,"price":"441.56","amount":"0.38","tid":1413879,"
side":"buy"}
]
Error codes and reports representing order status changes are described below.
Authentication
To use this API endpoint you should get your API key and Secret key from the Settings
page.
...
Error codes
HTTP
Text Description
code
API key doesn't exist or API key is currently used on
403 Invalid API key
another endpoint (max last 15 min)
Nonce has been
403 Nonce is not monotonous
used
Nonce is not
403 Too big number or not a number
valid
Wrong
403 Specified signature is not correct
signature
500 Internal error Internal error. Try again later
Execution reports
The API uses ExecutionReport as an object that represents change of order status.
Example response:
{ "ExecutionReport": {
"orderId": "5852103",
"clientOrderId": "11111112",
"execReportType": "new",
"orderStatus": "new",
"symbol": "BTCUSD",
"side": "buy",
"timestamp": 1395236779235,
"price": 0.1,
"quantity": 100,
"type": "limit",
"timeInForce": "GTC",
"lastQuantity": 0,
"lastPrice": 0,
"leavesQuantity": 100,
"cumQuantity": 0,
"averagePrice": 0
} }
/api/1/trading/balance
Sample usage at HitBTC site: see https://hitbtc.com/terminal, the upper panel, Trading
line. The black number displays total trade balance of the currency (cash parameter),
the gray number is amount reserved against unexecuted orders and unfinished
transactions (reserved parameter).
Parameters: no parameters
Example response:
{"balance": [
{"currency_code": "BTC","cash": 0.045457701,"reserved": 0.01},
{"currency_code": "EUR","cash": 0.0445544,"reserved": 0},
{"currency_code": "LTC","cash": 0.7,"reserved": 0.1},
{"currency_code": "USD","cash": 2.9415029,"reserved": 1.001}
]}
/api/1/trading/orders/active
Summary: returns all orders in status new or partiallyFilled.
Parameters:
Example response:
{"orders": [
{
"orderId": "51521638",
"orderStatus": "new",
"lastTimestamp": 1394798401494,
"orderPrice": 1000,
"orderQuantity": 1,
"avgPrice": 0,
"quantityLeaves": 1,
"type": "limit",
"timeInForce": "GTC",
"cumQuantity": 0,
"clientOrderId": "7fb8756ec8045847c3b840e84d43bd83",
"symbol": "LTCBTC",
"side": "sell",
"execQuantity": 0
}
]}
/api/1/trading/new_order
Summary: place a new order. Returns a JSON object ExecutionReport that respresent
a status of the order.
Sample usage at HitBTC site: see https://hitbtc.com/terminal, Sell Order and Buy
Order panels.
Parameters:
Example:
post url:
/api/1/trading/new_order?nonce=1395049771755&apikey=f6ab189hd7a2007e01
d95667de3c493d
post data:
clientOrderId=11111112&symbol=BTCUSD&side=buy&price=0.1&quantity=100&t
ype=limit&timeInForce=GTC
Example response:
{ "ExecutionReport":
{ "orderId": "58521038",
"clientOrderId": "11111112",
"execReportType": "new",
"orderStatus": "new",
"symbol": "BTCUSD",
"side": "buy",
"timestamp": 1395236779235,
"price": 0.1,
"quantity": 100,
"type": "limit",
"timeInForce": "GTC",
"lastQuantity": 0,
"lastPrice": 0,
"leavesQuantity": 100,
"cumQuantity": 0,
"averagePrice": 0 } }
/api/1/trading/cancel_order
Parameters:
Example:
post url:
/api/1/trading/cancel_order?nonce=1395049771755&apikey=f6ab189hd7a2007
e01d95667de3c493d
post data:
clientOrderId=11111112&cancelRequestClientOrderId=38257825798349578945
&symbol=BTCUSD&side=buy
Example response:
{ "ExecutionReport":
{ "orderId": "58521038",
"clientOrderId": "11111112",
"execReportType": "canceled",
"orderStatus": "canceled",
"symbol": "BTCUSD",
"side": "buy",
"timestamp": 1395236779346,
"price": 0.1,
"quantity": 100,
"type": "limit",
"timeInForce": "GTC",
"lastQuantity": 0,
"lastPrice": 0,
"leavesQuantity": 0,
"cumQuantity": 0,
"averagePrice": 0 } }
CancelReject example:
{ "CancelReject": {
"cancelRequestClientOrderId": "011111112",
"clientOrderId": "11111112",
"rejectReasonCode": "orderNotFound"
} }
/api/1/trading/cancel_orders
Parameters:
Example:
post url:
/api/1/trading/cancel_orders?nonce=1395049771755&apikey=f6ab189hd7a200
7e01d95667de3c493d
post data: symbols=BTCUSD
Example response:
{
"ExecutionReport": [
{
"orderId": "411459298",
"clientOrderId": "7bd65b9cc64e436a89edef57b841f691",
"orderStatus": "canceled",
"symbol": "BTCUSD",
"side": "sell",
"price": "280.00",
"quantity": 1,
"type": "limit",
"timeInForce": "GTC",
"lastQuantity": 0,
"lastPrice": "",
"leavesQuantity": 0,
"cumQuantity": 0,
"averagePrice": "0",
"created": 1443530022688,
"execReportType": "canceled",
"timestamp": 1443530050131
},
{
"orderId": "411459299",
"clientOrderId": "a6b41105b54c4304bf7bd8bca29fb060",
"orderStatus": "canceled",
"symbol": "BTCUSD",
"side": "sell",
"price": "290.00",
"quantity": 15,
"type": "limit",
"timeInForce": "GTC",
"lastQuantity": 0,
"lastPrice": "",
"leavesQuantity": 0,
"cumQuantity": 0,
"averagePrice": "0",
"created": 1443530030502,
"execReportType": "canceled",
"timestamp": 1443530050131
}
]
}
/api/1/trading/orders/recent
Summary: returns an array of user's recent orders (order objects) for last 24 hours,
sorted by order update time.
Parameters:
Example response:
{"orders": [
{
"orderId": "1",
"orderStatus": "new",
"lastTimestamp": 1395659434845,
"orderPrice": 1,
"orderQuantity": 1,
"avgPrice": 0,
"quantityLeaves": 1,
"type": "limit",
"timeInForce": "GTC",
"clientOrderId": "111111111111111111111111",
"symbol": "BTCUSD",
"side": "buy",
"execQuantity": 0
},
{
"orderId": "2",
"orderStatus": "new",
"lastTimestamp": 1395664550770,
"orderPrice": 1,
"orderQuantity": 1,
"avgPrice": 0,
"quantityLeaves": 1,
"type": "limit",
"timeInForce": "GTC",
"clientOrderId": "111111111111111111111112",
"symbol": "BTCUSD",
"side": "sell",
"execQuantity": 0
},
{
"orderId": "3",
"orderStatus": "canceled",
"lastTimestamp": 1395664737500,
"orderPrice": 1,
"orderQuantity": 1,
"avgPrice": 0,
"quantityLeaves": 1,
"type": "limit",
"timeInForce": "GTC",
"clientOrderId": "111111111111111111111113",
"symbol": "BTCUSD",
"side": "buy",
"execQuantity": 0
}
]}
/api/1/trading/order
Parameters:
{
"orders": [
{
"orderId": 425817975,
"orderStatus": "filled",
"lastTimestamp": 1446740176886,
"orderPrice": "0.0000000729",
"orderQuantity": 10,
"avgPrice": "0.0000000810",
"quantityLeaves": 0,
"type": "market",
"timeInForce": "FOK",
"cumQuantity": 10,
"clientOrderId": "afe8b9901b0e4914991291a49175a380",
"symbol": "BCNBTC",
"side": "sell",
"execQuantity": 10
}
]
}
/api/1/trading/trades/by/order
Parameters:
Example response:
{"trades": [
{
"tradeId": 39,
"execPrice": 150,
"timestamp": 1395231854030,
"originalOrderId": "114",
"fee": 0.03,
"clientOrderId": "FTO18jd4ou41--25",
"symbol": "BTCUSD",
"side": "sell",
"execQuantity": 10
},
{
"tradeId": 38,
"execPrice": 140.1,
"timestamp": 1395231853882,
"originalOrderId": "112",
"fee": 0.028,
"clientOrderId": "FTO18jd4ou3n--15",
"symbol": "BTCUSD",
"side": "buy",
"execQuantity": 10
},
{
"tradeId": 2,
"execPrice": 150,
"timestamp": 1394789991659,
"originalOrderId": "24",
"fee": 0.03,
"clientOrderId": "FTO18ivvcbvt--25",
"symbol": "BTCUSD",
"side": "sell",
"execQuantity": 10
},
{
"tradeId": 1,
"execPrice": 140,
"timestamp": 1394789991527,
"originalOrderId": "22",
"fee": 0.028,
"clientOrderId": "FTO18ivvcbvj--15",
"symbol": "BTCUSD",
"side": "buy",
"execQuantity": 10
}
]}
/api/1/trading/trades
Summary: returns the trading history - an array of user's trades (trade objects).
Parameters:
Parameter Required Type Description
trade_id Selects if filtering and sorting is performed by
by Yes or ts trade_id or by timestamp
start_index Yes integer Zero-based index. Default value is 0
Maximum quantity of returned results, at most
max_results Yes integer
1000
symbols No string Comma-separated list of currency symbols
asc or Trades are sorted ascending (default) or
sort No desc descending
Returns trades with trade_id > specified
from No integer trade_id (if by=trade_id) or returns trades with
timestamp >= specified timestamp(ifby=ts`)
Returns trades with trade_id < specified
till No integer trade_id (if by=trade_id) or returns trades with
timestamp < specified timestamp (if by=ts)
Example response:
{"trades": [
{
"tradeId": 39,
"execPrice": 150,
"timestamp": 1395231854030,
"originalOrderId": "114",
"fee": 0.03,
"clientOrderId": "FTO18jd4ou41--25",
"symbol": "BTCUSD",
"side": "sell",
"execQuantity": 10
},
{
"tradeId": 38,
"execPrice": 140.1,
"timestamp": 1395231853882,
"originalOrderId": "112",
"fee": 0.028,
"clientOrderId": "FTO18jd4ou3n--15",
"symbol": "BTCUSD",
"side": "buy",
"execQuantity": 10
},
{
"tradeId": 2,
"execPrice": 150,
"timestamp": 1394789991659,
"originalOrderId": "24",
"fee": 0.03,
"clientOrderId": "FTO18ivvcbvt--25",
"symbol": "BTCUSD",
"side": "sell",
"execQuantity": 10
},
{
"tradeId": 1,
"execPrice": 140,
"timestamp": 1394789991527,
"originalOrderId": "22",
"fee": 0.028,
"clientOrderId": "FTO18ivvcbvj--15",
"symbol": "BTCUSD",
"side": "buy",
"execQuantity": 10
}
]}
/api/1/payment/balance
Parameters: no parameters
Example response:
{
"balance": [
{
"currency_code": "USD",
"balance": 13.12
},
{
"currency_code": "EUR",
"balance": 0
},
{
"currency_code": "LTC",
"balance": 1.07
},
{"currency_code": "BTC",
"balance": 11.9
}
]}
Summary: transfers funds between main and trading accounts; returns a transaction ID
or an error.
Parameters:
Example responses:
/api/1/payment/address/ (GET)
Summary: returns the last created incoming cryptocurrency address that can be used to
deposit cryptocurrency to your account.
Example response:
{"address":"1HDtDgG9HYpp1YJ6kFYSB6NgaG2haKnxUH"}
/api/1/payment/address/ (POST)
Parameters: no parameters
Example response:
{"address":"1HDtDgG9HYpp1YJ6kFYSB6NgaG2haKnxUH"}
/api/1/payment/payout
Parameters:
Example:
amount=0.001¤cy_code=BTC&address=1LuWvENyuPNHsHWjDgU1QYKWUYN9xxy
7n5
Example response:
{"transaction": "51545-103004-18442681"}
/api/1/payment/transactions
Parameters:
Example response:
{"transactions": [
{
"id": "49720-104765-18440728",
"type": "payin",
"status": "pending",
"created": 1397056648,
"finished": 1397056646,
"amount_from": 0.001,
"currency_code_from": "BTC",
"amount_to": 0.001,
"currency_code_to": "BTC",
"destination_data": null,
"commission_percent": 0,
"bitcoin_address": "1KnVXD1Wc1wZbTHiB1TDgMcnSRi2PnMHAV",
"bitcoin_return_address": "1QBuhFksjoWTQWJKWUPyQ37wsQohLAhJvK"
"external_data":
"0b2ac379986cd1872b6a4115ad7a6cf436bdac67080db728579b8282c129a549"
}
]}
/api/1/payment/transactions/:id
Parameters:
Parameter Required Type Description
id Yes string Transaction Id
Example response:
{
"transaction": {
"id": "89229-171-97181",
"type": "payin",
"status": "finished",
"created": 1438768402,
"finished": 1438768943,
"amount_from": 1000,
"currency_code_from": "BCN",
"amount_to": 1000,
"currency_code_to": "BCN",
"destination_data":
"b744ab8c87d83b6469770926cb5388e3f389f067730af7f506d1f08cbef46d86",
"commission_percent": 0,
"bitcoin_address": null,
"bitcoin_return_address": null,
"external_data":
"3b598fd882902d8be14bd72d2b31f692f34700bf133e62c442d487911465b72e"
}
}
Useful links:
API links:
trades namespace
Namespace: trades
URLs: /trades/:symbol e.g. /trades/BTCUSD
Event: trade
Event example:
{"price":478.33,"amount":0.15}
Streaming API
Streaming API is based on WebSocket protocol. All messages are in JSON format.
URL: ws://api.hitbtc.com:80
Demo URL: ws://demo-api.hitbtc.com:80
The application could receive the first snapshot and maintain the order book by
applying incremental updates.
It's recommended to invalidate a state of the application periodically using
snapshots.
It's recommended to check sequence numbers and to drop updates with non-
monotonous sequence numbers.
MarketDataSnapshotFullRefresh message
Example message:
{"MarketDataSnapshotFullRefresh": {
"snapshotSeqNo": 899009,
"symbol": "BTCUSD",
"exchangeStatus": "working",
"ask": [
{
"price": 101.42,
"size": 7
},
{
"price": 101.85,
"size": 5
},
{
"price": 102.59,
"size": 1
},
{
"price": 114.53,
"size": 3
},
{
"price": 114.54,
"size": 6
},
{
"price": 114.55,
"size": 19
}
],
"bid": [
{
"price": 89.72,
"size": 79
},
{
"price": 89.71,
"size": 158
},
{
"price": 89.7,
"size": 166
},
{
"price": 89.69,
"size": 231
},
{
"price": 89.68,
"size": 169
},
{
"price": 89.67,
"size": 186
},
{
"price": 89.66,
"size": 178
}
]
}}
MarketDataIncrementalRefresh message
Summary: contains incremental changes of the order book and individual trades.
Example message:
{"MarketDataIncrementalRefresh": {
"seqNo": 546693,
"timestamp": 1381394357861,
"symbol": "BTCUSD",
"exchangeStatus": "on",
"ask": [],
"bid": [
{
"price": 100.98,
"size": 3
}
],
"trade": [
{
"price": 100.98,
"size": 5,
"timestamp": 1346691273926
}
]
}}
Field Description
seqNo
Monotone increasing number of the snapshot, each symbol has its
own sequence
timestamp UTC timestamp, in milliseconds
symbol Currency symbol traded on HitBTC exchange
exchangeStatus Exchange status: on - trading is open; off - trading is suspended
An array of changes in the order book where price is a price, size is
ask, bid, trade
new size. size=0 means that the price level has been removed
Trading endpoint requires sending login message after connection established. All client
messages should be signed and should contain valid and active API key (see API keys
and message signatures).
| Type | | | --- | --- | --- | | Login | Client -> Server | | NewOrder | Client -> Server | |
OrderCancel | Client -> Server | | ExecutionReport | Server -> Client | | CancelReject |
Server -> Client |
{
"apikey": "e418f5b4a15608b78185540ef583b9fc",
"signature":
"FN6/9dnMfLh3wZj+cAFr82HcSvmwuniMQqUlRxSQ9WxRqFpYrjY2xlvDzLC5+qSZAHts8
R7KR7HbjiI3SzVxHg==",
"message":{
"nonce": 12,
"payload": {
"Login": {}
}
}
}
Fields:
Field Description
nonce
Unique monotonous number that should be generated on the client. Should
be monotonous within the same connection
signature
Signature - hash-based message authentication code: base64 hmac-sha512
(binary representation of the message)
Login
Example:
{
"apikey": "e418f5b4a15608b78185540ef583b9fc",
"signature":
"FN6/9dnMfLh3wZj+cAFr82HcSvmwuniMQqUlRxSQ9WxRqFpYrjY2xlvDzLC5+qSZAHts8
R7KR7HbjiI3SzVxHg==",
"message":{
"nonce": 12,
"payload": {
"Login": {}
}
}
}
Parameters: no parameters
If client doesn't send valid logon message in 10 second the connection will be dropped.
NewOrder
Example:
{
"apikey": "e418f5b4a15608b78185540ef583b9fc",
"signature":
"FN6/9dnMfLh3wZj+cAFr82HcSvmwuniMQqUlRxSQ9WxRqFpYrjY2xlvDzLC5+qSZAHts8
R7KR7HbjiI3SzVxHg==",
"message":{
"nonce": 12,
"payload": {
"NewOrder": {
"clientOrderId": "68f82819-723a-4b60-ad6b",
"symbol": "BTCUSD",
"side": "buy",
"quantity": 10,
"type": "limit",
"price": 788.12,
"timeInForce": "GTC"
}
}
}
}
Parameters:
OrderCancel
Example:
{
"apikey": "e418f5b4a15608b78185540ef583b9fc",
"signature":
"FN6/9dnMfLh3wZj+cAFr82HcSvmwuniMQqUlRxSQ9WxRqFpYrjY2xlvDzLC5+qSZAHts8
R7KR7HbjiI3SzVxHg==",
"message":{
"nonce": 12,
"payload": {
"OrderCancel": {
"clientOrderId": "68f82819-723a-4b60-ad6b",
"cancelRequestClientOrderId": "2c4d7127-6fbc-450c-
b851-c6c1e8954545",
"symbol": "BTCUSD",
"side": "buy"
}
}
}
}
Parameters:
ExecutionReport
Example:
{
"ExecutionReport":{
"orderId": "64283442",
"clientOrderId": "68f82819-723a-4b60-ad6b",
"execReportType": "new",
"orderStatus": "new"
"symbol": "BTCUSD",
"side": "buy",
"timestamp": 1346691273926,
"price": 690.99,
"quantity": 0.1,
"type": "limit",
"timeInForce": "GTC"
}
}
CancelReject
Example:
{"CancelReject": {
"clientOrderId": "68f82819-723a-4b60-ad6b",
"cancelRequestClientOrderId": "2c4d7127-6fbc-450c-b851",
"rejectReasonCode": "orderNotFound",
"rejectReasonText": "Order not found",
"timestamp": 726892347829
}}
Require
Field Type Description
d
cancelRequestClientOrder
cancelRequestClientOrder
Id Yes string Id parameter from
OrderCancel
clientOrderId parameter
clientOrderId Yes string
from OrderCancel
orderNotFoun
d
unknownSymbo Code of the reason why the
rejectReasonCode Yes l order was cancelled
unknownUser
other
Optional text explaining reject
rejectReasonText No string
reason
Sample code
Node.js snippet: message signature
var crypto = require('crypto');
...
var msg = {
'apikey': apikey,
'signature': '',
'message': {
'nonce': nonce,
'payload': {
'NewOrder': {
'clientOrderId': clientOrderId,
'symbol': symbol,
'side': side,
'quantity': quantity,
'type': type,
'price': price,
'timeInForce': timeInForce
}
}
}
};
msg.signature = crypto.createHmac('sha512',
secretkey).update(JSON.stringify(msg.message)).digest('base64');
return JSON.stringify(msg);