Search…
⌃K

API Reference

Quote

Parameter name
Type
Example
Description
chain
string
bsc
eth, bsc, polygon, avax, arbitrum, fantom, xdai, heco, boba, moonriver, aurora, cronos, harmony, sifchain, osmosis, optimism, ont, tron, terra, okex
inTokenAddress
string
0x55d398326f99059ff775485246999027b3197955
sell token address
outTokenAddress
string
0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d
buy token address
amount
number
1
sell amount(without decimals)
gasPrice
number
5
The target gas price (in wei) for the swap transaction. If the price is too low to achieve the quote, an error will be returned
  • Example:
Request:
https://api.0xgen.io/v1/bsc/quote?inTokenAddress=0x55d398326f99059ff775485246999027b3197955&outTokenAddress=0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d&amount=5&gasPrice=5
Response:
{
"code": 200,
"data": {
"dexes": [
{
"name": "openOcean",
"amount": "4995642973232943774",
"useTime": 397
},
{
"name": "1inch",
"amount": "4984061907198958392",
"useTime": 1033
},
{
"name": "matcha",
"amount": "4984061907198958392",
"useTime": 1261
}
],
"maxOutAmount": "4995642973232943774",
"minOutAmount": "4984061907198958392",
"inToken": {
"symbol": "USDT",
"name": "Binance-Peg USD (T)",
"decimals": 18,
"address": "0x55d398326f99059ff775485246999027b3197955"
},
"outToken": {
"symbol": "USDC",
"name": "Binance-Peg USD Coin",
"address": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
"decimals": 18
},
"inAmount": "5000000000000000000",
"useTime": 1284
}
}

Swap

Parameter name
Type
Example
Description
chain
string
avax
eth, bsc, polygon, avax, arbitrum, fantom, xdai, heco, boba, moonriver, aurora, cronos, harmony, sifchain, osmosis, optimism, ont, tron, terra, okex
dex
string
1inch
openOcean, 1inch, matcha, jupiter
inTokenAddress
string
0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB
sell token address
outTokenAddress
string
0xf693248f96fe03422fea95ac0afbbbc4a8fdd172
buy token address
amount
number
1
sell amount(without decimals)
gasPrice
number
5
The target gas price (in wei) for the swap transaction. If the price is too low to achieve the quote, an error will be returned
slippage
number
1
0-50, 1 equal 1%
account
string
0x929B44e589AC4dD99c0282614e9a844Ea9483C69
wallet address
disableEstimate
bool
true
true/false
  • Example:
Request:
https://api.0xgen.io/v1/avax/openOcean/swap_quote?inTokenAddress=0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB&outTokenAddress=0xf693248f96fe03422fea95ac0afbbbc4a8fdd172&amount=50000&&gasPrice=0.001&slippage=1.251&account=0x929B44e589AC4dD99c0282614e9a844Ea9483C69&disableEstimate=true
Response:
{
"code": 200,
"data": {
"inToken": {
"address": "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
"decimals": 18,
"name": "Wrapped Ether",
"symbol": "WETH.e"
},
"outToken": {
"address": "0xf693248F96Fe03422FEa95aC0aFbBBc4a8FdD172",
"decimals": 18,
"symbol": "TUS",
"name": "Treasure Under Sea"
},
"inAmount": "50000000000000000000000",
"outAmount": "106528459642362063142601203",
"estimatedGas": "627382",
"minOutAmount": "105196853896832537353318688",
"from": "0x929B44e589AC4dD99c0282614e9a844Ea9483C69",
"to": "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
"value": "0",
"gasPrice": "1000000",
"data": "0x90411a3200000000000000000000000012cfe671e9b186f21d9852d69bdbfe3f8ac9ecb1000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000049d5c2bdffac6ce2bfdb6640f4f80f226bc10bab000000000000000000000000f693248f96fe03422fea95ac0afbbbc4a8fdd1720000000000000000000000009ab2de34a33fb459b538c43f251eb825645e8595000000000000000000000000929b44e589ac4dd99c0282614e9a844ea9483c69000000000000000000000000000000000000000000000a968163f0a57b40000000000000000000000000000000000000000000000057044ce06e0e0327a8f120000000000000000000000000000000000000000000581e475e68f781931941f30000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000007c000000000000000000000000000000000000000000000000000000000000008e00000000000000000000000009ab2de34a33fb459b538c43f251eb825645e859500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000649331621200000000000000000000000049d5c2bdffac6ce2bfdb6640f4f80f226bc10bab000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000012cfe671e9b186f21d9852d69bdbfe3f8ac9ecb100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000000000002000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000bced3b6d759b9ca8fc7706e46aa81627b2e9eae80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064cac460ee00000000000000003b6d0340bced3b6d759b9ca8fc7706e46aa81627b2e9eae8000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000012cfe671e9b186f21d9852d69bdbfe3f8ac9ecb100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000000000012000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000565d20bd591b00ead0c927e4b6d7dd8a33b0b3190000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064cac460ee00000000000000003b6d0340565d20bd591b00ead0c927e4b6d7dd8a33b0b319000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000012cfe671e9b186f21d9852d69bdbfe3f8ac9ecb100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000f693248f96fe03422fea95ac0afbbbc4a8fdd17200000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000f693248f96fe03422fea95ac0afbbbc4a8fdd172000000000000000000000000929b44e589ac4dd99c0282614e9a844ea9483c6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
}