OpenOcean API 2.0
OpenOcean API 2.0 stoped updating, so it will be better for developer to use OpenOcean API 3.0
1. Quote price
Method: Get
Parameters:
Parameter name | Type | Example | Description |
exChange | string | 1inch | platform(openoceanv1,openoceanv2,1inch,matcha,paraswap) |
chainId | number | 56 | chain id (1/56/100/137/250/42161/43114) In particular, we have defined Terra as 400 |
inTokenSymbol | string | USDT | sell token name |
inTokenAddress | string | 0x55d398326f99059ff775485246999027b3197955 | sell token address |
outTokenSymbol | string | BNB | buy token name |
outTokenAddress | string | 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE | buy token address |
amount | number | 1 | sell amount |
gasPrice | number | 5 | you can set it yourself or get it through GetGasPrice |
slippage | number | 1 | 1 equals 1%, ranges 0.01% to100% |
in_token_decimals | number? | 18 | you can define it according to the market |
out_token_decimals | number? | 18 | you can define it according to the market |
withRoute | string? | routes | default null |
Example:
Request:
Response:
2. Get token list
Method: Get
Parameters:
Parameter | Type | Example | Description |
chainId | number | 56 | chain id (1/56/100/137/250/42161/43114) |
Example:
Request:
Response:
3. Create wallet
Method: Get
Parameters:
Parameter | Type | Example | Description |
chainId | number | 56 | chain id (1/56/137/43114) |
Example:
Request:
Response:
4. Get balance
Method: Get
Parameters:
Parameter | Type | Example | Description |
account | string | optional | wallet address |
chainId | number | 56 | chain id (1/56/137/43114) |
inTokenAddress | string | 0x55d398326f99059ff775485246999027b3197955,0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE | token address |
Example:
Request:
Response:
5. Swap
Method: Get
Parameters:
Parameter | Type | Parameter | Description |
exChange | string | openoceanv2 | platform |
chainId | number | 56 | chainId 56 |
inTokenSymbol | string | USDT | sell token name |
inTokenAddress | string | sell token address | 0x55d398326f99059ff775485246999027b3197955 |
outTokenSymbol | string | USDC | buy token name |
outTokenAddress | string | 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d | buy token address |
amount | number | 50 | sell token amount |
gasPrice | number | 5 | you can set it yourself or get it through GetGasPrice |
slippage | number | 1 | 1 equals 1%, ranges 0.01% to100% |
account | string | wallet address | It can be read from the configuration file |
referrer | stringοΌ | 0x0000000000000000000000000000000000000000 | Please contact us for a unique referrer parameter |
in_token_decimals | number? | 18 | you can define it according to the market |
out_token_decimals | number? | 18 | you can define it according to the market |
withoutCheckBalance | boolean? | true | default null |
Example:
Request:
Response:
6. Get transaction
Method: Get
Parameters:
Parameter | Type | Example | Description |
chainId | number | 56 | chain id (1/56/137/43114) |
hash | string | 0xa4733659e9a9496b30228f98b8d862062e93e58d7e9b8f208c5215228fc5b858 | hash value |
exChange | string | openoceanv2 | openoceanv1/openoceanv2 |
type | string | transfer | transfer/swap |
Example:
Request:
Response:
7. Get transaction receipt
Method: Get
Parameters:
Parameter | Type | Example | Description |
chainId | number | 56 | chain id (1/56/137/43114) |
hash | string | 0xa4733659e9a9496b30228f98b8d862062e93e58d7e9b8f208c5215228fc5b858 | hash value |
exChange | string | openoceanv2 | platform(openoceanv1/openoceanv2) |
Example:
Request:
Response:
8. Transfer
Method: Get
Parameters:
Parameter | Type | Example | Description |
chainId | number | 56 | chain id |
inTokenAddress | string | 0x55d398326f99059ff775485246999027b3197955 | transfer token address |
inTokenSymbol | string | USDT | transfer token name |
decimals | number | 18 | unit conversion |
amount | number | 5 | transfer number |
gasPrice | number | 5 | you can set it yourself or get it through GetGasPrice |
targetAddress | string | 0x929B44e589AC4dD99c0282614e9a844Ea9483C69 | wallet address |
Example:
Request:
Response:
9. GetGasPrice
Method: get
Url: https://open-api.openocean.finance/v1/:chainId/getGasPrice
Parameters:
parameter | type | example | description |
---|---|---|---|
chainId | number | 56 | chain id (1/56/100/137/250/42161/43114) |
Example:
request:
response:
10. Swap quote
Method: Get
Parameters:
Parameter | Type | Parameter | Description |
exChange | string | 1inch | platform |
chainId | number | 56 | chain id (1/56/100/137/250/42161/43114) In particular, we have defined Terra as 400 |
inTokenSymbol | string | USDT | sell token name |
inTokenAddress | string | sell token address | 0x55d398326f99059ff775485246999027b3197955 |
outTokenSymbol | string | USDC | buy token name |
outTokenAddress | string | 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d | buy token address |
amount | number | 50 | sell token amount |
gasPrice | number | 5 | you can set it yourself or get it through GetGasPrice |
slippage | number | 1 | 1 equals 1%, ranges 0.01% to100% |
account | string | wallet address | It can be read from the configuration file |
referrer | string? | 0x0000000000000000000000000000000000000000 | Please contact us for a unique referrer parameter |
in_token_decimals | number? | 18 | you can define it according to the market |
out_token_decimals | number? | 18 | you can define it according to the market |
withoutCheckBalance | boolean? | true | default null |
Example:
request:
response:
11. GetAllowance
Method: Get
URL: https://open-api.openocean.finance/v1/cross/getAllowance
Parameters:
Parameter | Type | Parameter | Description |
account | string | 0xf8953d8671644348303cfa8Ae408F5d9fb884761 | wallet address |
chainId | number | 56 | chain id (1/56/100/137/250/42161/43114) In particular, we have defined Terra as 400 |
inTokenAddress | string | 0x9029FdFAe9A03135846381c7cE16595C3554e10A,0x08ba0619b1e7a582e0bce5bbe9843322c954c340 | token address |
contractAddress | string | 0x6352a56caadC4F1E25CD6c75970Fa768A3304e64 | contract address |
Example:
request:
response:
Common error codes
Codes | Error description |
---|---|
201 | Invalid request format |
202 | Set token decimals |
204 | Insufficient balance |
205 | Suspend trading |
206 | Fail to approve token |
500 | Internal server error |
Last updated