Skip to content

012security_authorization

jiangrui edited this page Jun 29, 2021 · 22 revisions

API Invocation Instruction

  1. All requests based on the Https protocol should set the request header information Content-Type as:'application/json’.
  2. All input and output data are in JSON format.
  3. Visit Root URL: https://api.coinex.com/v1
  4. Signature is required for Account API and trading API related interfaces. The signature data is placed in the authorization header of the HTTP header and authorization is the signature result string. No signature is required for market API related interfaces.
  5. Request header information must be declared: User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
  6. Rate limit: Please refer to the specific instruction of each interface. The general speed limit of the sockets is 200 times per 10 second per IP (for Trading and Account API); no limit on Market API

Acquire access_id and secret_key

# to CoinEx before invoking API and get Acquire access_id/secret_key in Account > API.

access_id: To mark identity of API invoker

secret_key: Key to sign the request parameters

Note: access_id/secret_key is equivalent to your account/password. For your asset security, please keep it safe and change it regularly. Once lost, please # to CoinEx for reset.

Generate String To Sign

Request parameters should include access_id and all parameters need to be signed.

1. Sort all parameters in alphabetic order.

E.g. Relevant parameters of a request are as follows:

POST:

{
    "access_id": "4DA36FFC61334695A66F8D29020EB589",
    "market": "BTCBCH",
    "type" : "buy",
    "price": "10",
    "amount": "1.0",
    "tonce": 1513746038205
}; 

GET:

access_id=4DA36FFC61334695A66F8D29020EB589&market=BTCBCH&type=buy&price=680&amount=1.0&tonce=1513746038205

Sort field names alphabetically as follows:

POST:

{
    "access_id": "4DA36FFC61334695A66F8D29020EB589",
    "amount": "1.0",
    "market": "BTCBCH",
    "price": "10",
    "tonce": 1513746038205,
    "type: "buy"
}; 

GET:

access_id=4DA36FFC61334695A66F8D29020EB589&amount=1.0&market=BTCBCH&price=680&tonce=1513746038205&type=buy

2. Generate String To Sign

Use & match the sorted parameters as follows:

access_id=4DA36FFC61334695A66F8D29020EB589&amount=1.0&market=BTCBCH&price=680&tonce=1513746038205&type=buy

Add secret_key to the last string to sign, supposing this is a secret_key: B51068CF10B34E7789C374AB932696A05E0A629BE7BFC62F:

access_id=4DA36FFC61334695A66F8D29020EB589&amount=1.0&market=BTCBCH&price=680&tonce=1513746038205&type=buy&secret_key=B51068CF10B34E7789C374AB932696A05E0A629BE7BFC62F

Use 32-bit MD5 Algorithm Signature

Use MD5 algorithm to encrypt the signature string, convert encrypted result to uppercase, get signature data and put signature data in HTTP Header - authorization:

authorization: 610AB90A1D31D45901D173E4F59C9384

Support Market List

https://api.coinex.com/v1/market/list

Return to Data Structure Description

# Response
{
  "code": 0,       # Refer to code error description.
  "data": {},      # Return data as list or dictionary.
  "message": "Ok"  # Code error description.
}

HTTP API Introduction

Common API

Market API

Account API

Trading API

Margin API

Contract API

WebSocket API Introduction

Clone this wiki locally