Introduction
VHCEx public API offers our procedural functions, operating system, applications and other services in order to create real-time market data. It would invoke the market tickers, time stamp, specified market pairs and OHLC graph bars of a specific market.
It also provides the private API for account details, orders, creating a buy/sell order, cancellation of orders and trade histories that will be vital in the creation of any application of functions.
Authentication
To use private API, you need to get your access/secret key first. After signed up and verified, please visit API Tokens page to get your keys. All private API requires 3 authentication parameters and zero or more API specific parameters. The 3 authentication parameters are:
Parameter | Description |
---|---|
access_key | Your access key. |
tonce | tonce is a timestamp in integer, stands for milliseconds elapsed since Unix epoch. Tonce must be within 30 seconds of server's current time. Each tonce can only be used once. |
signature | Signature of the API request, generated by you, with your secret key. |
Signature is a hash of the request in (canonical string form):
hash = OpenSSL::HMAC.hexdigest 'SHA256', secret_key, payload
Payload is a combination of HTTP verb, uri, and query string:
- canonical_verb is HTTP verb like GET/POST in upcase.
- canonical_uri is the request path like /api/v2/markets.
- canonical_query is the request query sorted in alphabetical order, including access_key and tonce, signature.
Public API
Get all market
{ "id": "btcusd", "name": "BTC/USD" }, { "id": "ethusd", "name": "ETH/USD" }, ]The endpoint returns JSON structured like this:
This endpoint retrieves all market.
HTTP Request
GET http://www.vhcex.com/api/v2/markets
Query Parameters
None
Get all market tickers
The endpoint returns JSON structured like this:
{
"btcusd": {
"at": 1553250317,
"ticker": {
"buy": "0.0",
"sell": "0.0",
"low": "0.0",
"high": "0.0",
"last": "0.0",
"name": "BTC/USD",
"id": "btcusd",
"open": "0.0",
"volume": "0.0",
"chg": null
}
},
"ethusd": {
"at": 1553250317,
"ticker": {
"buy": "0.0",
"sell": "0.0",
"low": "0.0",
"high": "0.0",
"last": "0.0",
"name": "ETH/USD",
"id": "ethusd",
"open": "0.0",
"volume": "0.0",
"chg": null
}
},
}
This endpoint retrieves all tickers.
HTTP Request
GET http://www.vhcex.com/api/v2/tickers/
URL Parameters
None
Get all market tickers
The endpoint returns String structured like this:
{
"btcusd": {
"at": 1553250317,
"ticker": {
"buy": "0.0",
"sell": "0.0",
"low": "0.0",
"high": "0.0",
"last": "0.0",
"name": "BTC/USD",
"id": "btcusd",
"open": "0.0",
"volume": "0.0",
"chg": null
}
}
}
This endpoint retrieves a specific market ticker.
HTTP Request
GET http://www.vhcex.com/api/v2/tickers/btcusd
URL Parameters
None
Parameter | Description |
---|---|
ID | The ID of the kitten to retrieve |
Get timestamp
The endpoint returns JSON structured like this:
1553250662
This endpoint retrieve the server current timestamp.
HTTP Request
GET http://www.vhcex.com/api/v2/tickers/timestamp
URL Parameters
None
Get all trades of specific market pair
The endpoint returns JSON structured like this:
[
{
"id": 46,
"price": "3414.501561037658",
"volume": "0.7728380000000001",
"funds": null,
"market": "btcusd",
"created_at": "2019-02-07T00:42:49+02:00",
"trend": "up",
"side": null
},
]
This endpoint retrieves recent trades on a market, each trade is included only once. Trades are sorted in reverse creation order.
HTTP Request
GET http://www.vhcex.com/api/v2/trades?market=btcusd
Query Parameters
Parameter | Description |
---|---|
market | ID of the specific market e.g. "btcusd" |
Get graph OHLC(k line)
The endpoint returns JSON structured like this:
[
[
1552891080,
3414.501561037658,
3414.501561037658,
3414.501561037658,
3414.501561037658,
0
],
]
This endpoint retrieves OHLC(k line) of specific market.
HTTP Request
GET http://www.vhcex.com/api/v2/k?market=btcusd
Query Parameters
Parameter | Description |
---|---|
market | ID of the specific market e.g. "btcusd" |
limit | Limit the number of returned data points, default to 30. |
period | Time period of K line, default to 1. You can choose between 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080 |
timestamp | An integer represents the seconds elapsed since Unix epoch. If set, only k-line data after that time will be returned. |
endtime | End time of graph |
Private API
Get account detail
The endpoint returns JSON structured like this:
{
"sn": "VHCFOOBAREX"
"name": "Snoopy"
"email": "[email protected]"
"activated": true
"accounts": [
{
"currency": "vhc",
"balance": "50.0",
"locked": "2.0",
"currency_icon": "/icon-vhc.png",
"decimal": "8"
}
]
}
This endpoint return your account details.
HTTP Request
GET http://www.vhcex.com/api/v2/members/me
Query Parameters
None
Get orders
The endpoint returns JSON structured like this:
{
"total_page": "VHCFOOBAREX"
"orders": [
{
"id": "5",
"side": "buy",
"ord_type": "limit",
"price": "3950.0",
"avg_price": "3950.0",
"state": "wait",
"market": "btcusd",
"created_at": "2019-03-07T15:42:11Z",
"volume": "8.0",
"remaining_volume": "1.0",
"executed_volume": "0.0",
"trade_count": 0
}
]
}
This endpoint return orders in a specific market. State include wait, done, and cancel.
HTTP Request
GET http://www.vhcex.com/api/v2/orders?market=btcusd&limit=1&page=1
Query Parameters
market | ID of the specific market e.g. "btcusd" limit | Limit the number of returned data points, default to 100. page | Specify the page of paginated results, default to 1.
Get a specific order
The endpoint returns JSON structured like this:
{
"id": "5",
"side": "sell",
"ord_type": "limit",
"price": "3950.0",
"avg_price": "3950.0",
"state": "wait",
"market": "btcusd",
"created_at": "2019-03-07T15:42:11Z",
"volume": "8.0",
"remaining_volume": "1.0",
"executed_volume": "0.0",
"trade_count": 1
"trades": [
{
"id": "25",
"price": "3950.0",
"volume": "1",
"funds": "3950.0",
"market": "btcusd",
"created_at": "2019-03-07T15:42:11Z",
"trend": "up",
"side": "sell",
}
]
}
This endpoint return specific order.
HTTP Request
GET http://www.vhcex.com/api/v2/orders?id=5
Query Parameters
id | Order id
Create a BUY/SELL order
The endpoint returns JSON structured like this:
{
"id":1519,
"side":"sell",
"ord_type":"limit",
"price":"4000.0",
"avg_price":"0.0",
"state":"wait",
"market":"btcusd",
"created_at":"2019-03-25T16:09:51+08:00",
"volume":"1.0",
"remaining_volume":"1.0",
"executed_volume":"0.0",
"trades_count":0
}
This endpoint create a buy/sell order.
HTTP Request
POST http://www.vhcex.com/api/v2/order?market=btcusd&price=4000&side=sell&volume=1
Query Parameters
market | ID of the specific market e.g. "btcusd" price | Price per unit side | Buy or sell order volume | Order volume
Cancel an order
The endpoint returns JSON structured like this:
{
"id": "5",
"side": "sell",
"ord_type": "limit",
"price": "3950.0",
"avg_price": "3950.0",
"state": "wait",
"market": "btcusd",
"created_at": "2019-03-07T15:42:11Z",
"volume": "8.0",
"remaining_volume": "1.0",
"executed_volume": "0.0",
"trade_count": 1
}
This endpoint cancel specific order.
HTTP Request
POST http://www.vhcex.com/api/v2/order/delete?id=5
Query Parameters
id | Order id
Get trade histories
The endpoint returns JSON structured like this:
[
{
"id":719,
"price":"4004.0",
"volume":"0.01255",
"funds":"50.2502",
"market":"btcusd",
"created_at":"2019-03-20T11:33:21+08:00",
"trend":"up",
"side":null
}
]
This endpoint retrieves trade hitories.
HTTP Request
POST http://www.vhcex.com/api/v2/trades/my?market=btcusd
Query Parameters
market | ID of the specific market e.g. "btcusd" limit | Limit the number of returned trades. Default to 50. order_by | If set, returned trades will be sorted in specific order, default to 'desc'.