You should use this endpoint before any exchange operations for following reasons:
1.Get available directions for exchange through 0xpay (tickers).
2.Get 0xpay exchange limitations (min, max).
3.Find the way how you should format your swaps (precision, step).
In response you'll get an array of two objects: target and exchange with info about available assets, limits, and amount precision.
amountStep indicates the smallest portion of asset that can be added/substracted from the exchange amount, any smaller digits will not be accepted for the exchange.
For example: if amountStep=0.001, then valid amount: 5.005, and anything containing smaller digits is not valid: 1.0005 .
[ {"target": {"ticker":"BNB",//asset to receive"amountStep":"0.01000000",//exchange amount can be changed by at least 0.01 BNB },"exchange": {"ticker":"BUSD",//asset to spend"amountStep":"0.00010000",//exchange amount can be changed by at least 0.0001 BUSD "max":"10000",//maximum exchange amount in BUSD"min":"0.00010000"//minimum exchange amount in BUSD } }, {"target": {"ticker":"BUSD","amountStep":"0.00010000" },"exchange": {"ticker":"BNB","amountStep":"0.01000000","max":"1000","min":"0.01000000" } }}
You can use this endpoint to estimate your exchange for later creation
Query Parameters
In response, you'll get details for your upcoming exchange:
{"price": { //object"value":"40",// price of the exchange pair"pair": ["UAH","USDT"] // "Pair" is array of two "ticker" strings, values can be found in API reference },"exchange": { // detailed summary of operation"amount":"4030",//amount to be exchanged"ticker":"UAH",//ticker to spend for exchange"fee":"20"// transaction fee },"target": {"amount":"100",// amount to receive to balance"ticker":"USDT"// ticker to receive to balance },"spend": {"amount":"4020",// amount to spend, including fees"ticker":"UAH"// ticker to spend }}
//List of Error codes with descriptions//0 – Order validation error//1 – Ticker pair not allowed//2 – Not enough liquidity{"code": 1,"description": "Ticker pair not allowed"}
Use this endpoint to create an exchange of two assets.
Status Notifications: After the Success response, 0xpay API will produce notifications according to status updates on your exchange.
Request Body
{"id": "123e4567-e89b-12d3-a456-426614174000"//internal ID has been assigned to the exchange}
//List of all error codes for exchange operations//0 – Local id already placed//1 – Not enough balance//3 – Order validation error//4 – Ticker pair not allowed//5 – Withdraw amount too low//6 – Not enough liquidity{"code": 5,"description": "Withdraw amount too low"}
Asset that you want to receive to your balance. Find values using "List all supported assets" request + Fiat ticker KZT
spendTicker*
string
Asset that you want to spend from your balance. Find values using "List all supported assets" request + Fiat ticker KZT
amount*
string
amount in decimal format
side*
string
Your chosen direction, two possible values: target or spend
price
string
actual price of the pair
spendTicker*
string
Ticker you want to spend (exchange) from your balance.
Find values using "List all supported assets" request + Fiat ticker UAH
amount*
string
decimal format number presented as a string
targetTicker*
string
Asset that you want to receive to your balance. Find values using "List all supported assets" request + Fiat ticker UAH
side*
string
Your chosen direction, two possible values: target or spend
fee*
string
you can specify withdrawal fees that have to be greater than the actual fee, which can be useful for better fee calculation options on your side. If not the specified –fee will be set automatically
price*
string
actual price of the pairs
localId
string
if was specified error will be thrown if not unique, can be useful on your side to avoid the issue
meta
string
metadata that you can define and catch it back later with notification