General Info
General API Information
- The base endpoint is: https://api.hepbit.com
- All endpoints return either a JSON object or array.
HTTP Return Codes
- HTTP 200 return code is used for successful results
- HTTP 400 return code is used for malformed requests; the issue is on the sender's side.
- HTTP 500 return code is used for internal errors; the issue is on Hepbit's side. It is important to NOT treat this as a failure operation; the execution status is UNKNOWN and could have been a success.
- HTTP 503 return code is used when Hepbit is under maintenance
General Information on Endpoints
- Specific error codes and messages defined in Errors.
- For GET, POST, DELETE endpoints, the parameters should be sent as a query string
- Parameters may be sent in any order.
Endpoint Security
- API-keys are passed into the Rest API via the X-FX-APIKEY header.
- Signatures are passed into the Rest API via the X-FX-SIGNATURE header.
- Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation. Use your private key as the key and totalParams as the value for the HMAC operation
- totalParams is defined as the query string.
- The signature is not case sensitive.
Timing Security
- A private endpoint also requires a parameter, timestamp, to be sent which should be the millisecond timestamp of when the request was created and sent.
- An additional parameter, recvWindow, may be sent to specify the number of milliseconds after timestamp the request is valid for. If recvWindow is not sent, it defaults to 5000.
The logic is as follows:
if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow) {
// process request
} else {
// reject request
}
It is recommended to use a small recvWindow of 5000 or less! The max cannot go beyond 60,000!
ENUM Definitions
- side
- BUY
- SELL
- type
- LIMIT
- MARKET
- STOP_LIMIT
- status
- NEW
- PARTIAL
- FILLED
- CANCELED
- condition
- LTE
- GTE
Examples
New Order
Key | Value |
---|---|
API Key | d0e099421b55261d4a147a339bc6312424b7a6a798bb3a770ee12170077ba79c |
Private Key | f59176a2c363c6cba321256b4ccd246e9b0366429a2bb8ebb8fc696bc536e241 |
Parameter | Value |
---|---|
symbol | BTCTRY |
side | SELL |
type | MARKET |
quantity | 0.002 |
timestamp | 1587032846796 |
- queryString
- symbol=BTCTRY&side=SELL&type=MARKET&quantity=0.002×tamp=1587032846796
HMAC SHA256 signature
[linux]$ echo -n "symbol=BTCTRY&side=SELL&type=MARKET&quantity=0.002×tamp=1587032846796" | openssl dgst -sha256 -hmac "f59176a2c363c6cba321256b4ccd246e9b0366429a2bb8ebb8fc696bc536e241"
(stdin)= 8bbc50b18c7d66480bfc5aca3d920d164baac5a7d37922702128e673ec8cb696
CURL Command
(HMAC SHA256)
[linux]$ curl -H "X-FX-APIKEY: d0e099421b55261d4a147a339bc6312424b7a6a798bb3a770ee12170077ba79c" -H "X-FX-SIGNATURE: 8bbc50b18c7d66480bfc5aca3d920d164baac5a7d37922702128e673ec8cb696" -X POST 'https://api.hepbit.com/v1/order?symbol=BTCTRY&side=SELL&type=MARKET&quantity=0.002×tamp=158703284679'
Private Endpoints
Account Balance
GET /v1/account/balances (HMAC SHA256)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | STRING | NO | Default 5000; max 60000 |
timestamp | LONG | YES |
Response
[
{
"symbol": "BTC",
"free": "8.12",
"locked": "0"
},
{
"symbol": "USDT",
"free": "7931.24",
"locked": "0"
}
]
Open Orders
GET /v1/openorders (HMAC SHA256)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | STRING | NO | Default 5000; max 60000 |
timestamp | LONG | YES | |
symbol | STRING | YES |
Response
[
{
"id": "94A38E2E-D180-EA11-B821-000C29C6002A",
"time": 1587144651584,
"updateTime": 1587144681584,
"symbol": "BTCTRY",
"side": "BUY",
"type": "LIMIT",
"price": "43140",
"stopPrice": "0",
"amount": "0.5",
"filled": "0.409772",
"status": "PARTIAL",
"condition": null
},
{
"id": "EDCA8A78-CF80-EA11-B821-000C29C6002A",
"time": 1587143916716,
"updateTime": 1587143916716,
"symbol": "BTCTRY",
"side": "BUY",
"type": "LIMIT",
"price": "43104",
"stopPrice": "0",
"amount": "0.005",
"filled": "0",
"status": "NEW",
"condition": null
},
]
All Orders
GET /v1/order/all (HMAC SHA256)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | STRING | NO | Default 5000; max 60000 |
timestamp | LONG | YES | |
symbol | STRING | YES | |
limit | INT | NO | Default 100; max 1000 |
startTime | LONG | NO | |
endTime | LONG | NO |
Response
[
{
"id": "94A38E2E-D180-EA11-B821-000C29C6002A",
"time": 1587144651584,
"updateTime": 1587144655584,
"symbol": "BTCTRY",
"side": "BUY",
"type": "LIMIT",
"price": "43140",
"stopPrice": "0",
"amount": "0.5",
"filled": "0.409772",
"status": "PARTIAL",
"condition": null
},
{
"id": "EDCA8A78-CF80-EA11-B821-000C29C6002A",
"time": 1587143916716,
"updateTime": 1587143916716,
"symbol": "BTCTRY",
"side": "BUY",
"type": "LIMIT",
"price": "43104",
"stopPrice": "0",
"amount": "0.005",
"filled": "0",
"status": "NEW",
"condition": null
},
{
"id": "ABCD23E2-FF80-AB11-B821-888C29C6002A",
"time": 1587142916716,
"updateTime": 1587142956716,
"symbol": "BTCTRY",
"side": "SELL",
"type": "LIMIT",
"price": "39000",
"stopPrice": "0",
"amount": "0.05",
"filled": "0",
"status": "CANCELLED",
"condition": null
},
]
Order Summary
GET /v1/order/summary (HMAC SHA256)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | STRING | NO | Default 5000; max 60000 |
timestamp | LONG | YES | |
symbol | STRING | YES | |
orderId | GUID | YES |
Response
{
"pair": "BTCUSDT",
"orderId": "A98FA6D0-CF23-4FEE-9135-3DE640438452",
"type": "MARKET",
"side": "SELL",
"price": null,
"stopPrice": null,
"condition": null,
"quantity": "19743.00000000",
"filled": "19743.00000000",
"status": "FILLED",
"averagePrice": "0.00000069"
}
New order
POST /v1/order (HMAC SHA256)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | STRING | NO | Default 5000; max 60000 |
timestamp | LONG | YES | |
symbol | STRING | YES | |
side | ENUM | YES | BUY, SELL |
type | ENUM | YES | MARKET, LIMIT, STOP_LIMIT |
quantity | DECIMAL | YES | Used with MARKET, LIMIT, STOP_LIMIT |
price | DECIMAL | NO | Used with LIMIT, STOP_LIMIT |
stopPrice | DECIMAL | NO | Used with STOP_LIMIT |
Response
{
"id": "3644E26C-B083-EA11-B822-000C29C6002A",
"time": 1587460436247,
"status": "NEW",
"filled": "0",
"price": "41535",
"quantity": "0.004",
"stopPrice": "41510",
"condition": "LTE",
"symbol": "BTCTRY",
"type": "STOP_LIMIT",
"side": "BUY"
}
Cancel order
DELETE /v1/order (HMAC SHA256)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | STRING | NO | Default 5000; max 60000 |
timestamp | LONG | YES | |
symbol | STRING | YES | |
orderId | GUID | YES |
Response
{
"symbol": "BTCTRY",
"orderId": "430D6D08-D080-EA11-B821-000C29C6002A"
}
Public Endpoints
Check Server Time
GET /v1/time
Parameters: NONE
Response
{
"serverTime": 1587374802853
}
Ticker
GET /v1/ticker
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
Response
[
{
"pair": "BTCTRY",
"lastPrice": "43140.00000000",
"openPrice": "43140.00000000",
"highPrice": "43140.00000000",
"lowPrice": "43140.00000000",
"volume": "0.00000000",
"bid": "43140.00000000",
"ask": "43176.00000000",
"timestamp": 1587377957316
}
]
Order book
GET /v1/orderbook
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
limit | INT | NO | Default 100; max 1000. Valid limits:[5, 10, 20, 50, 100, 500, 1000] |
Response
{
"timestamp": 1587378162,
"asks": [
[
43176,
0.235832
],
[
43212,
0.297798
],
[
43247,
0.111559
],
[
43283,
0.22527
],
[
43318,
0.363617
]
],
"bids": [
[
43140,
0.090228
],
[
43105,
0.08530048
],
[
43104,
0.395
],
[
42604,
0.257821
],
[
42568,
0.479183
]
]
}
Exchange Info
GET /v1/exchangeInfo
Parameters: NONE
Response
[
{
"symbol": "BTCTRY",
"status": "TRADING",
"baseAsset": "BTC",
"baseFractionDigits": "6",
"baseMinAmount": "0.001",
"quoteAsset": "TRY",
"quoteFractionDigits": "2",
"quoteMinAmount": "100",
"minPriceMultiplier": 0.1,
"maxPriceMultiplier": 10,
"orderTypes": [ "MARKET", "LIMIT", "STOP_LIMIT" ]
},
{
"symbol": "BCZTRY",
"status": "CLOSED",
"baseAsset": "BCZ",
"baseFractionDigits": "0",
"baseMinAmount": "250",
"quoteAsset": "TRY",
"quoteFractionDigits": "3",
"quoteMinAmount": "10",
"minPriceMultiplier": 0.1,
"maxPriceMultiplier": 10,
"orderTypes": [ "MARKET", "LIMIT", "STOP_LIMIT" ]
}
]
Errors
- General server or network issues
Code | Meaning |
---|---|
-1000 | An unknown error occured while processing the request |
-1010 | Timestamp for this request was 1000ms ahead of the server's time |
-1011 | Timestamp for this request is outside of the recvWindow |
-1012 | Service unavailable |
- Request issues
Code | Meaning |
---|---|
-2000 | API-key format invalid |
-2001 | Invalid API-key, IP, or permissions for action |
-2002 | Signature for this request is not valid |
-2200 | Illegal characters found in parameter '{parameter}' |
-2201 | Mandatory parameter '{parameter}' was not sent, was empty/null, or malformed |
-2203 | '{parameter}' must be less than or equal to '{value}' |
-2204 | Invalid '{parameter}' |
-2205 | '{parameter}' cannot be lower than '{value}' |
-2206 | '{parameter}' cannot be higher than '{value}' |
-2207 | Total must be at least '{value}' |
- Matching engine
Code | Meaning |
---|---|
-4001 | Order not found |
-4002 | Market is closed |
-4003 | Not enough funds to complete the action |
-4004 | No orders found to complete the action |
-4005 | You cannot enter orders at this price. Cancel your current order(s) and try again. |