# ViteX REST API
Note
- New v2 ViteX API is released. The v1 API is deprecated and service has been suspended. Please upgrade your client accordingly.
# Overview
ViteX API enables users to trade on ViteX DEX 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 placing and canceling orders. 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, invalid ticker, etc.1003
Network - network jam, network issues, insufficient Quota and so on.1004
Other failures - such as attempting to cancel an order of another address, attempting to cancel a filled order, 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 stored on 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 but not yet dispatched into the 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 (to be added in 7th Mainnet upgrade) |
# 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 yet) |
2 | FOK - Fill or Kill | Place an order only when it can be fully filled (not supported yet) |
# Private API Authorization
To use ViteX Private REST API, you must authorize it on Trade Delegation (opens new window) first in order for ViteX API to trade on your behalf. You need to fill in the delegation address, which is generated by the API service when you applied for the API Key on ViteX API (opens new window). You DO NOT need to provide your private key or mnemonic phrase.
Step 1: Create API Key on ViteX API (opens new window)
Step 2: Connect Vite Wallet
- By providing API Key and API Secret (instead of private key or mnemonics) to a trustworthy third party market-maker, your fund remains safe in your ViteX account and it cannot be misappropriated.
- You need to enable the API on selected trading pairs. Attempting to trade on unauthorized pairs will cause error.
- Authorization can be canceled at any time. In this case, ViteX can still reject API trading requests even if the API Key and API Secret are still valid.
It's highly recommended to enable API authorization ONLY on specific trading pairs that you wish to trade.
Delegation Address and Quota
ViteX API will generate a unique delegation address for each user. Orders placed by the API are signed by the delegation address instead of your private key. Therefore, DO NOT give your private key or account mnemonics to anyone.
Meanwhile, Quota in the delegation address is zero by default. Users need to provide Quota to the address.
# Trigger Limit
ViteX Private API has a trigger limit. The limit is reset 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 on ViteX API (opens new window). Please note that API Key and API Secret are both case sensitive.
Besides parameters defined by the specific API methods, 3 additional parameters key
, timestamp
and signature
also need to be included.
key
- Your API Keytimestamp
- UNIX timestamp in milliseconds. To avoid replay attacks, 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 alphabetical order; - Generate request string by concatenating parameters with
=
and&
in above order; - Sign the request string by HMAC SHA256, using API Secret as the secret key. If request string and request body are both available, put the request string ahead of the request body;
- Signature is case in-sensitive;
- Attach the signature to request string in
signature
field.
# Example
Let's place an order through API /api/v2/order
and assume that we have the following API Key and API 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)
The request will not be submitted to the exchange for order testing. This API is generally used to verify if the signature is correct.
Quota consumption: 0 UT
Parameter:
Name | Type | 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 | 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 | 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 | 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 | 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 | 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 a specific market
- Parameters:
Name | Type | Required? | Description |
---|---|---|---|
quoteTokenSymbol | STRING | YES | Quote token symbol, for example, VITE |
Response:
# Get Unlisted Tokens
Get tokens that are not yet listed in a specific market
- Parameters:
Name | Type | Required? | Description |
---|---|---|---|
quoteTokenSymbol | STRING | YES | Quote token symbol, for example, VITE |
Response:
# Get Trading Pair
Get trading pair in detail
- Parameters:
Name | Type | Required? | Description |
---|---|---|---|
symbol | STRING | YES | Trading pair name, for example, GRIN-000_BTC-000 |
Response:
# Get All Trading Pairs
- Parameters:
Name | Type | 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 | 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 | 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 | 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 24H Price Changes
- Parameters:
Name | Type | Required? | Description |
---|---|---|---|
symbols | STRING | NO | Trading pairs, split by "," |
quoteTokenSymbol | STRING | NO | Quote token symbol, for example, USDT-000 . Returns all pairs if unavailable |
Response:
# Get Order Book Ticker
Get current best price/qty on the order book for a trading pair
- Parameters:
Name | Type | 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 | 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 | 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 | 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 Chart
- Parameters:
Name | Type | 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 | 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 | 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 | 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 accumulated fees
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: