# ViteX REST API
Notice
- New v2 ViteX API is released. The v1 API is deprecated and service is stopped. Please upgrade your client.
# Overview
ViteX API enables users to complete trading operations on ViteX decentralized exchange without exposing private keys. ViteX API is categorized into trading API and market trends API. Trading API (also known as private API) requires authentication and authorization, and provides functions such as order placement and cancellation. Market trends API (also known as public API) provides market data, information query, etc. Market trends API can be accessed publicly without authentication.
# Base Endpoint
- [MainNet]:
https://api.vitex.net/
- [TestNet]:
https://buidl.vitex.net/open
# API Response
API response is returned in JSON.
HTTP code:
- HTTP
200
API returned successfully - HTTP
4XX
Wrong API request - HTTP
5XX
Service error
Response format:
Key | Value |
---|---|
code | 0 - success. An error code is returned if the API request failed |
msg | Detailed error message |
data | Return data |
Example:
Error code:
0
API returned successfully1
General error - view the specific error message inmsg
field.1001
Too frequent request - request exceeds limit.1002
Invalid parameter - this may include invalid timestamp, wrong order price, invalid amount, order too small, invalid market, insufficient permission, symbol not exist, etc.1003
Network - network jam, network broken, insufficient quota and so on.1004
Other failure - such as attempting to cancel an order of other address, attempting to cancel an order already filled, order status exception1005
Service error - unexpected API error1006
Minimum order quantity not satisfied - order quantity doesn't reach the minimal requirement in the market1007
Insufficient Exchange Balance - user's balance in the exchange is not enough
# Data Definition
# Order Status
Code | Status | Description |
---|---|---|
0 | Unknown | Status unknown |
1 | Pending Request | Order submitted. A corresponding request transaction has been created on the blockchain |
2 | Received | Order received by ViteX smart contract. Not yet dispatched into matching engine |
3 | Open | Order unfilled |
4 | Filled | Order completely filled |
5 | Partially Filled | Order partially filled |
6 | Pending Cancel | Cancel order request submitted. A corresponding request transaction has been created on the blockchain |
7 | Cancelled | Order cancelled |
8 | Partially Cancelled | Order partially cancelled (order is partially filled and then cancelled) |
9 | Failed | Order failed |
10 | Expired | Order expired |
# Order Type
Code | Status | Description |
---|---|---|
0 | Limit Order | Limit Order |
1 | Market Order | Market Order (not supported at present) |
# Side
Code | Status | Description |
---|---|---|
0 | Buy Order | Buy |
1 | Sell Order | Sell |
# Time In Force
Code | Status | Description |
---|---|---|
0 | GTC - Good till Cancel | Place an order and wait for it to be fully filled or cancelled |
1 | IOC - Immediate or Cancel | Place an order and immediately cancel unfilled (not supported at present) |
2 | FOK - Fill or Kill | Place an order only when it can be fully filled (not supported at present) |
# Private API Authorization
To use ViteX Private REST API, you must authorize at Trade Delegation (opens new window) on ViteX platform first to authorize ViteX API service to trade on behalf of you. You should fill in the delegation address, which is generated by the API service when you applied the API Key. You DO NOT need provide private key or mnemonic phrase.
- By providing API Key and API Secret to a trustworthy third party market maker (instead of private key or mnemonics), your fund is safe in your ViteX account and cannot be misappropriated.
- You should enable the API on selected trading pairs explicitly. Attempting to trade on unauthorized pairs will cause error.
- Authorization can be canceled at any time. In this case, even though the API Key and API Secret are still valid, ViteX exchange will reject API trading request eventually.
It's highly recommended to enable API authorization ONLY on specific trading pairs that you wish to trade.
Delegation Address and Quota
ViteX API service will generate a unique delegation address for each user. Orders placed by the API are signed by delegation address instead of your private key. Therefore, DO NOT give your private key or account mnemonics to anyone.
Meanwhile, quota of delegation address is zero by default. It's your responsibility to provide quota to the address.
# Trigger Limit
ViteX Private API has a trigger limit. The limit is reset in every cycle (60s). When the limit is reached, subsequent API requests in the cycle will be rejected.
# API Authentication
Private API requires signature authentication by API Key and API Secret, which you can apply for at API (opens new window) on ViteX platform. Please note that API Key and API Secret are both case sensitive.
Besides parameters defined by specific API methods, 3 additional parameters key
, timestamp
and signature
should also be included.
key
- Your API Keytimestamp
- UNIX timestamp in milliseconds. To avoid replay attack, API request will be rejected if the timestamp in request is 5,000 ms earlier or 1,000 ms later than standard time.signature
- HMAC SHA256 signature on request string, using API Secret as secret key
Sample code of timestamp checking at server side:
# Signature of Request String
- List all parameters (including
key
andtimestamp
) in alphabet order; - Generate request string by concatenating parameters with
=
and&
in above order; - Sign the request string by HMAC SHA256, using API Secret as secret key. If request string and request body are both present, put request string in ahead of request body;
- Signature is case in-sensitive;
- Attach the signature to request string in
signature
field.
# An Example
Let's place an order through API /api/v2/order
. Assume we have the following API Key and Secret:
API Key | API Secret |
---|---|
913423DE46E97751CCC734F018F09217 | F6BED9F34912C0B658B58C73B6531721 |
We place an order on market ETH-000_BTC-000 to buy 10 ETH at price 0.09 BTC. The API request has the following parameters:
Key | Value |
---|---|
symbol | ETH-000_BTC-000 |
side | 0 |
amount | 10 |
price | 0.09 |
timestamp | 1567067137937 |
The request string is:
amount=10&key=913423DE46E97751CCC734F018F09217&price=0.09&side=0&symbol=ETH-000_BTC-000×tamp=1567755178560
Create signature:
Call API to place the order:
# Private REST API
# Place Order (test)
Test placing order. The request will not be submitted to exchange. This API is generally used to verify that the signature is correct.
Quota consumption: 0 UT
Parameter:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, ETH-000_BTC-000 |
amount | STRING | YES | Order amount (in trade token) |
price | STRING | YES | Order price |
side | INT | YES | Buy - 0 , Sell - 1 |
timestamp | LONG | YES | Timestamp (s) |
key | STRING | YES | API Key |
signature | STRING | YES | HMAC SHA256 signature of request string |
Response:
# Place Order
Quota consumption: 1 UT
Parameter:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, ETH-000_BTC-000 |
amount | STRING | YES | Order amount (in trade token) |
price | STRING | YES | Order price |
side | INT | YES | Buy - 0 , Sell - 1 |
timestamp | LONG | YES | Timestamp (s) |
key | STRING | YES | API Key |
signature | STRING | YES | HMAC SHA256 signature of request string |
Response:
Name | Type | Description |
---|---|---|
symbol | STRING | Trading pair name |
orderId | STRING | Order ID |
status | INTEGER | Order status |
# Cancel Order
Quota consumption: 1 UT
Parameter:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, ETH-000_BTC-000 |
orderId | STRING | YES | Order ID |
timestamp | LONG | YES | Timestamp (s) |
key | STRING | YES | API Key |
signature | STRING | YES | HMAC SHA256 signature of request string |
Response:
Name | Type | Description |
---|---|---|
symbol | STRING | Trading pair name |
orderId | STRING | Order ID |
cancelRequest | STRING | Cancel request ID |
status | INTEGER | Order status |
# Cancel All Orders
Quota consumption: N UT (N=Orders)
Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, ETH-000_BTC-000 |
timestamp | LONG | YES | Timestamp (s) |
key | STRING | YES | API Key |
signature | STRING | YES | HMAC SHA256 signature of request string |
Response:
Name | Type | Description |
---|---|---|
symbol | STRING | Trading pair name |
orderId | STRING | Order ID |
cancelRequest | STRING | Cancel request ID |
status | INTEGER | Order status |
# Public REST API
# Get Order Limit
Get minimum order quantity for all markets
Response:
# Get All Tokens
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
category | STRING | NO | Token category, [quote ,all ], default all |
tokenSymbolLike | STRING | NO | Token symbol. For example, VITE . Fuzzy search supported. |
offset | INTEGER | NO | Search starting index, starts at 0 , default 0 |
limit | INTEGER | NO | Search limit, max 500 , default 500 |
Response:
# Get Token Detail
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
tokenSymbol | STRING | NO | Token symbol. For example, VITE |
tokenId | STRING | NO | Token id. For example, tti_5649544520544f4b454e6e40 |
Response:
# Get Listed Tokens
Get tokens that are already listed in specific market
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
quoteTokenSymbol | STRING | YES | Quote token symbol. For example, VITE |
Response:
# Get Unlisted Tokens
Get tokens that are not yet listed in specific market
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
quoteTokenSymbol | STRING | YES | Quote token symbol. For example, VITE |
Response:
# Get Trading Pair
Get trading pair in detail
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, GRIN-000_BTC-000 |
Response:
# Get All Trading Pairs
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
offset | INTEGER | NO | Search starting index, starts at 0 , default 0 |
limit | INTEGER | NO | Search limit, max 500 , default 500 |
Response:
# Get Order
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
address | STRING | YES | User's account address (not delegation address) |
orderId | STRING | YES | Order id |
Response:
# Get Open Order
Get orders that are unfilled or partially filled.
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
address | STRING | YES | User's account address (not delegation address) |
symbol | STRING | NO | Trading pair name. For example, GRIN-000_BTC-000 |
quoteTokenSymbol | STRING | NO | Quote token symbol. For example, BTC-000 |
tradeTokenSymbol | STRING | NO | Trade token symbol. For example, GRIN-000 |
offset | INTEGER | NO | Search starting index, starts at 0 , default 0 |
limit | INTEGER | NO | Search limit, default 30 , max 100 |
total | INTEGER | NO | Include total number searched in result? 0 - not included, 1 - included. Default is 0 , in this case total=-1 in response |
Response:
# Get Orders
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
address | STRING | YES | User's account address (not delegation address) |
symbol | STRING | NO | Trading pair name. For example, GRIN-000_BTC-000 |
quoteTokenSymbol | STRING | NO | Quote token symbol. For example, BTC-000 |
tradeTokenSymbol | STRING | NO | Trade token symbol. For example, GRIN-000 |
startTime | LONG | NO | Start time (s) |
endTime | LONG | NO | End time (s) |
side | INTEGER | NO | Order side. 0 - buy, 1 - sell |
status | INTEGER | NO | Order status, valid in [0-10 ]. 3 ,5 - returns orders that are unfilled or partially filled; 7 ,8 - returns orders that are cancelled or partially cancelled |
offset | INTEGER | NO | Search starting index, starts at 0 , default 0 |
limit | INTEGER | NO | Search limit, default 30 , max 100 |
total | INTEGER | NO | Include total number searched in result? 0 - not included, 1 - included. Default is 0 , in this case total=-1 in response |
Response:
# Get 24hr Ticker Price Changes
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbols | STRING | NO | Trading pairs, split by "," |
quoteTokenSymbol | STRING | NO | Quote token symbol. For example, USDT-000 . Returns all pairs if not present |
Response:
# Get Order Book Ticker
Get current best price/qty on the order book for a trading pair
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, GRIN-000_VITE |
Response:
# Get Trade Summary
Get trade records in summary
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example.GRIN-000_VITE |
limit | INTEGER | NO | Search limit, default 500 |
Response:
# Get Trade Records
Get trade records in detail
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, GRIN-000_VITE |
orderId | STRING | NO | Order id |
startTime | LONG | NO | Start time (s) |
endTime | LONG | NO | End time (s) |
side | INTEGER | NO | Order side. 0 - buy, 1 - sell |
offset | INTEGER | NO | Search starting index, starts at 0 , default 0 |
limit | INTEGER | NO | Search limit, default 30 , max 100 |
total | INTEGER | NO | Include total number searched in result? 0 - not included, 1 - included. Default is 0 , in this case total=-1 in response |
Response:
# Get Order Book Depth
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, GRIN-000_VITE |
limit | INTEGER | NO | Search limit, max 100 , default 100 |
precision | INTEGER | NO | Price Precision |
Response:
# Get Klines/Candlestick bars
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name. For example, GRIN-000_VITE |
interval | STRING | YES | Interval, [minute , hour , day , minute30 , hour6 , hour12 , week ] |
limit | INTEGER | NO | Search limit, max 1500 , default 500 |
startTime | LONG | NO | Start time (s) |
endTime | LONG | NO | End time (s) |
- Response:
Name | Type | Description |
---|---|---|
t | LONG | Timestamp |
c | STRING | Close price |
p | STRING | Open price |
h | STRING | Highest price |
l | STRING | Lowest price |
v | STRING | Trade volume |
# Get Deposit-Withdrawal Records
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
address | STRING | YES | Account address |
tokenId | STRING | YES | Token id. For example, tti_5649544520544f4b454e6e40 |
offset | INTEGER | NO | Search starting index, starts at 0 , default 0 |
limit | INTEGER | NO | Search limit, max 100 , default 100 |
Response:
# Get Exchange Rate
- Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
tokenSymbols | STRING | NO | Trading pairs, split by ",". For example, VITE,ETH-000 |
tokenIds | STRING | NO | Token ids, split by ",". For example, tti_5649544520544f4b454e6e40,tti_5649544520544f4b454e6e40 |
Response:
# Get USD-CNY Rate
Parameters: None
Response:
# Get Exchange Balance
Parameters:
Name | Type | Is Required? | Description |
---|---|---|---|
address | STRING | YES | Account address |
Response:
Name | Type | Description |
---|---|---|
available | STRING | Available balance |
locked | STRING | Balance locked by open order |
# Get Trade Mining Info
Get the current cycle's trade mining pool size and real-time fees accumulated
Response:
Name | Type | Description |
---|---|---|
tradePoolVx | OBJECT | Minable VX to be distributed in 4 markets at the cycle end |
tradePoolFee | OBJECT | Real-time cumulative trading fees in 4 markets |
1: VITE 2: ETH-000 3: BTC-000 4: USDT-000
# Get Server Time
Parameters: None
Response: