Enterprise API
View Github examples for Backend and Frontend. Check out the current supported chains here and relevant contract addresses.
Quote
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/quote - Method: GET
Params:
| Name | Type | Description |
|---|---|---|
| chain* | string | Chain name or Chain ID (supported chains) |
| inTokenAddress* | string | Input token address |
| outTokenAddress* | string | Output token address |
| amountDecimals* | string | Token amount with decimals. e.g. 1 USDT → 1000000 (1 * 10^6) |
| gasPriceDecimals* | string | GasPrice with decimals |
| slippage | string | Define acceptable slippage within the range of 0.05 to 50. e.g. 1% slippage set as 1, default value 1 |
| disabledDexIds | string | Enter the 'index' number of dexs through dexList endpoint to disable single or multiple dexs separated by commas, e.g. disabledDexIds: "2,6,9". |
| enabledDexIds | string | Dex index from dexList to enable. Has higher priority than disabledDexIds |
Note
We are deprecating amount and gasPrice. Use amountDecimals and gasPriceDecimals respectively. All values must be passed with full decimals.
Example request (with decimals)
1 https://open-api-enterprise.openocean.finance/v4/bsc/quote?inTokenAddress=0x55d398326f99059ff775485246999027b3197955&outTokenAddress=0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d&amountDecimals=5000000000000000000&gasPriceDecimals=1000000000
Example request (without decimals, deprecated)
1 https://open-api-enterprise.openocean.finance/v4/bsc/quote?inTokenAddress=0x55d398326f99059ff775485246999027b3197955&outTokenAddress=0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d&amount=5&gasPrice=1
Response
1 { 2 "code": 200, 3 "data": { 4 "inToken": { "address": "...", "decimals": 18, "symbol": "USDT", "name": "Tether USD", "usd": "0.998546", "volume": 4.99273 }, 5 "outToken": { "address": "...", "decimals": 18, "symbol": "USDC", "name": "USD Coin", "usd": "0.999955", "volume": 4.99 }, 6 "inAmount": "5000000000000000000", 7 "outAmount": "4993921938787056372", 8 "estimatedGas": "129211", 9 "dexes": [ { "dexIndex": 0, "dexCode": "Pancake", "swapAmount": "..." }, ... ], 10 "path": { "from": "...", "to": "...", "parts": 10, "routes": [ ... ] }, 11 "save": -0.0018, 12 "price_impact": "0.01%", 13 "exchange": "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64" 14 } 15 }
price_impact
The price_impact field indicates estimated price deviation. OpenOcean does not enforce execution blocks by price impact. It is the integrator's responsibility to evaluate it and implement checks. We recommend setting a price impact threshold and aborting if exceeded.
JavaScript Demo
1 const axios = require('axios'); 2 const chain = 'bsc'; 3 const url = `https://open-api-enterprise.openocean.finance/v4/${chain}/quote`; 4 const params = { 5 inTokenAddress: '0x55d398326f99059ff775485246999027b3197955', 6 outTokenAddress: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', 7 amount: 1, 8 gasPrice: 3 9 }; 10 async function main() { 11 try { 12 const { data } = await axios.get(url, { params }); 13 if (data?.code === 200) console.log('quote success'); 14 } catch (error) { 15 console.log(data); 16 } 17 } 18 main();
Python Demo
1 import requests 2 chain = 'bsc' 3 url = f'https://open-api-enterprise.openocean.finance/v4/{chain}/quote' 4 params = { 5 'inTokenAddress': '0x55d398326f99059ff775485246999027b3197955', 6 'outTokenAddress': '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', 7 'amount': 1, 8 'gasPrice': 3 9 } 10 def main(): 11 response = requests.get(url, params=params) 12 if response.status_code == 200: 13 data = response.json() 14 print(data) 15 else: 16 print("Error occurred:", response.text) 17 if __name__ == "__main__": 18 main()
Go Demo
1 package main 2 import ("fmt"; "net/http"; "encoding/json") 3 func main() { 4 chain := "bsc" 5 url := fmt.Sprintf("https://open-api-enterprise.openocean.finance/v4/%s/quote", chain) 6 params := map[string]string{ 7 "inTokenAddress": "0x55d398326f99059ff775485246999027b3197955", 8 "outTokenAddress": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", 9 "amount": "1", "gasPrice": "3", 10 } 11 resp, _ := http.Get(url) 12 defer resp.Body.Close() 13 var data map[string]interface{} 14 json.NewDecoder(resp.Body).Decode(&data) 15 if code, ok := data["code"].(float64); ok && code == 200 { 16 fmt.Println("quote success") 17 } 18 }
Java Demo
1 String chain = "bsc"; 2 String url = "https://open-api-enterprise.openocean.finance/v4/" + chain + "/quote"; 3 Map<String, Object> params = new HashMap<>(); 4 params.put("inTokenAddress", "0x55d398326f99059ff775485246999027b3197955"); 5 params.put("outTokenAddress", "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"); 6 params.put("amount", 1); 7 params.put("gasPrice", 3); 8 // Use URL + query string or HttpURLConnection to GET; then check data.get("code") == 200
ReverseQuote (Optional)
For /reverseQuote it is a buy flow: you specify how much inToken you want to receive, and we calculate how much outToken you need to sell. In the request URL, inToken and outToken are reversed compared to the frontend. We use real-time quote price to perform reverse quote and determine the required inToken amount. Read above before using this endpoint.
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/reverseQuote - Method: GET
Example: user wants to receive 1 BNB. On frontend: inToken=USDC, outToken=BNB. In the request: inToken=BNB, outToken=USDC, amount=1 (target BNB to receive).
1 https://open-api-enterprise.openocean.finance/v4/bsc/reverseQuote?inTokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&outTokenAddress=0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d&amount=1&gasPrice=1
Response structure is similar to Quote, with an additional reverseAmount field.
SwapQuote
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/swap - Method: GET
Params:
| parameter | type | description |
|---|---|---|
| chain* | string | Chain name or Chain ID (supported chains) |
| inTokenAddress* | string | Input token address |
| outTokenAddress* | string | Output token address |
| amountDecimals* | string | Token amount with decimals |
| gasPriceDecimals* | string | GasPrice with decimals |
| slippage | string | Define acceptable slippage within the range of 0.05 to 50. e.g. 1% slippage set as 1, default value 1 |
| account* | string | User wallet address. If omitted, response returns only quotes without calldata/transaction body |
| referrer | string | An EOA wallet address used to identify integrators and optionally receive trading fees. If no fee is set up, it serves purely as a tracking tool to help us provide better support and insights. |
| referrerFee | number | Specify the percentage of in-token you wish to receive from the transaction as trading fee, within the range of 0.01% to 5%. e.g. 1.2% fee set as 1.2. By default, OpenOcean shares 20% of the fee. Please contact us if you wish to modify this rate. |
| enabledDexIds / disabledDexIds | string | Dex index from dexList |
| sender | string | Caller address. If set, sender=caller and account=receiver; else account is both |
| minOutput | number | Min target tokens (with decimals). Supported: Base/BNB/ETH |
Deprecation
Use amountDecimals and gasPriceDecimals instead of amount and gasPrice.
Example request (with decimals)
1 https://open-api-enterprise.openocean.finance/v4/bsc/swap?inTokenAddress=0x55d398326f99059ff775485246999027b3197955&outTokenAddress=0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d&amountDecimals=5000000000000000000&gasPriceDecimals=1000000000&slippage=1&account=0x9116780aEf4B376499358fa7dEeC00cCF64fA801&referrer=0xD4eb4cbB1ECbf96a1F0C67D958Ff6fBbB7B037BB
Response
1 { 2 "code": 200, 3 "data": { 4 "inToken": { ... }, "outToken": { ... }, 5 "inAmount": "5000000000000000000", 6 "outAmount": "4993921938787056372", 7 "estimatedGas": 516812, 8 "minOutAmount": "4943982719399185808", 9 "from": "0x9116780aEf4B376499358fa7dEeC00cCF64fA801", 10 "to": "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64", 11 "value": "0", "gasPrice": "1000000000", 12 "data": "0x90411a32...", 13 "chainId": 56, "rfqDeadline": 0, "gmxFee": 0, 14 "price_impact": "0.01%" 15 } 16 }
estimatedGas
estimatedGas in the response is only a reference. We recommend calculating gas on your end (e.g. eth_estimateGas * 1.25–2.5). Update gasPrice to avoid failures due to on-chain gas fluctuations.
Example with minOutput (Base/BNB/ETH)
1 https://open-api-enterprise.openocean.finance/v4/1/swap?amountDecimals=10000000&gasPriceDecimals=1900000000&slippage=1&referrer=0x39041f1b366fe33f9a5a79de5120f2aee2577ebc&account=0xceCfC852f8cE51D92A5A291f6999DEE147bc2169&disableRfq=true&referrerFee=1&inTokenAddress=0xdac17f958d2ee523a2206206994597c13d831ec7&outTokenAddress=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&minOutput=9900000
minOutput
minOutput is with decimals. e.g. 9.9 USDC (6 decimals) → minOutput=9900000. If actual output is less than minOutput, the transaction will fail (protection).
Get TokenList
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/tokenList - Method: GET. Params: chain* (string)
1 https://open-api-enterprise.openocean.finance/v4/bsc/tokenList
Response: code 200, data array of tokens (id, code, name, address, decimals, symbol, icon, chain, etc.).
Get Dexes List
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/dexList - Method: GET. Params: chain* (string)
1 https://open-api-enterprise.openocean.finance/v4/avax/dexList
1 { "code": 200, "data": [ { "index": 1, "code": "SushiSwap", "name": "SushiSwap" }, { "index": 2, "code": "Pangolin", "name": "Pangolin" }, ... ] }
Get GasPrice
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/gasPrice - Method: GET. Params: chain* (string)
1 https://open-api-enterprise.openocean.finance/v4/bsc/gasPrice
Response (EVM): data.base, data.standard/fast/instant/low with legacyGasPrice, maxPriorityFeePerGas, maxFeePerGas, waitTimeEstimate; and without_decimals. For other EVM chains: data.standard, data.fast, data.instant (with and without_decimals).
When using /quote and /swap, gasPrice should be set in GWEI with decimals (e.g. 14 GWEI → use value from this API with decimals).
Get Transaction
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/getTransaction - Method: GET. Params: chain*, hash* (OpenOcean contract tx hash)
1 https://open-api-enterprise.openocean.finance/v4/bsc/getTransaction?hash=0x756b98a89714be5c640ea9922aba12e0c94bc30e5a17e111d1aa40373cc24782
Response: code 200, data with id, block_number, tx_hash, sender, receiver, in_token_address, out_token_address, in_amount, out_amount, referrer, tx_fee, status, etc.
DecodeInputData By Get
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/decodeInputData - Method: GET. Params: chain*, data* (inputData), method* (e.g. swap)
1 https://open-api-enterprise.openocean.finance/v4/bsc/decodeInputData?data=000000xxxxxx&method=swap
Response: caller, desc (srcToken, dstToken, srcReceiver, dstReceiver, amount, minReturnAmount, guaranteedAmount, flags, referrer, permit), calls array.
DecodeInputData By Post
- URL:
https://open-api-enterprise.openocean.finance/v4/:chain/decodeInputData - Method: POST. URL params: chain*. Body: data* (inputData), method* (e.g. swap)
1 POST https://open-api-enterprise.openocean.finance/v4/bsc/decodeInputData 2 Body: { "data": "000000xxxxxx", "method": "swap" }
Response: same as DecodeInputData By Get.