OpenOcean CEX API
Instruction of OpenOcean CEX API for Centralized users
1. Preparation
Before you use API, you need to login the website to create API Key with proper permissions.
Please remember below information after creation:
AccessKey
It is used in API requestSecretKey
It is used to generate the signature (only visible once after creation)
2. Authentication instruction
The API request may be tampered during internet, therefore all private API must be signed by your API Key (Secrete Key).
Each API Key has permission property, please check the API permission, and make sure your API key has proper permission.
A valid request consists of below parts:
API Path: open-api.openocean.finance/exchange/spot/open/v1/createOrder
API Access Key: The 'AccessKey' in your API Key
Signature Method: The Hash method that is used to sign, it uses HmacSHA256
Signature Version: The version for the signature protocol, it uses 2
Timestamp: The UTC time when the request is sent, e.g. 2017-05-11T16:22:06. It is useful to prevent the request to be intercepted by third-party.
Parameters: Each API Method has a group of parameters, you can refer to detailed document for each of them.
For GET request, all the parameters must be signed.
For POST request, the parameters needn't be signed and they should be put in request body.
Signature: The value after signed, it is guarantee the signature is valid and the request is not be tempered.
example:
3. Signature method
The signature may be different if the request text is different, therefore the request should be normalized before signing.
Below signing steps take the order query as an example:
The request Method (GET or POST, WebSocket use GET), append line break "\n"
The host with lower case, append line break "\n"
The path, append line break "\n"
The parameters are URL encoded, and ordered based on ASCII
For example below is the original parameters:
Then above parameter should be ordered like below:
Use char "&" to concatenate all parameters
Assemble the pre-signed text
Use the pre-signed text and your Secret Key to generate a signature
Use the pre-signed text in step 6 and your API Secret Key to generate hash code by HmacSHA256 hash function.
Encode the hash code with base-64 to generate the signature.
Put the signature into request URL
For Rest interface:
Put all the parameters in the URL
Encode signature by URL encoding and append in the URL with parameter name "Signature".
Finally, the request sent to API should be:
4. API docs
1. Create order
Request:
Method: POST
URL:/exchange/spot/open/v1/createOrder
Parameter:
Parameter Name | Type | Example | Description |
exchangeCode | String | binance | exchange code |
pairCode | String | BNB/BUSD | |
direction | String | 0 | 0:buy 1:sell |
orderType | String | 1 | 1:market 2:limit |
price | String | 10 | price |
volume | String | 10 |
Response:
2. Cancel order
Request:
Method: POST
URL:/exchange/spot/open/v1/cancelOrder
Parameter:
Parameter Name | Type | Example | Description |
localOrderId | String | 1 | local order id |
Response:
3. List funds
Request:
Method: GET
URL:/exchange/spot/open/v1/listFunds
Parameter:
Parameter Name | Type | Example | Description |
pairCode | String | BNB/BUSD | pair code |
Response:
Field Name | Type | Example | Description |
coinType | String | BNB | coin type |
available | String | 390.70 | |
frozen | String | 0 |
|
4. List current order
Request:
Method: GET
URL:/exchange/spot/open/v1/listCurrentOrder
Parameter:
Parameter Name | Type | Example | Description |
page | Number | 1 | pageNum |
length | Number | 10 | pageSize |
Response:
Field Name | Type | Example | Description |
localOrderId | String | 1774y3812418 | local order id |
exchangeSymbol | String | Binance | exchange symbol |
pairCode | String | BNB/USDT | pair code |
direction | String | Buy | |
orderType | String | Limit | |
orderStatus | String | Canceled | NotFilled、PartFilled |
orderPrice | String | 0.000357 | order price |
orderVolume | String | 350.000000 | order volume |
tradePrice | String | 0.000000 | trade price |
tradeVolume | String | 0.000000 | trade volume |
tradeAmount | String | 0.000000 | trade amount |
fee | String | 0.000000 | fee |
orderTime | String | 1611755902000 | order time |
5. List history order
Request:
Method: GET
URL:/exchange/spot/open/v1/listHistoryOrder
Parameter:
Parameter Name | Type | Example | Description |
page | Number | 1 | pageNum |
length | Number | 10 | pageSize |
pairCode | String | BNB/USDT | pair code |
startTime | String | 1611755902000 | timestamp |
endTime | String | 1611755902000 | timestamp |
Response
Last updated