Submit an order version 3

Rate limit: 3 every second

API Overview


HTTP method

POST

Path

/api/v3/order

Summary

Please follow the following steps to submit an order:

  1. Get the next orderId through /api/v2/orderId. If you maintain order IDs on the client side, you can skip this step.
  2. Choose reasonable values for validSince andvalidUntil. We recommend that validSince is set to the current system time, and validUntil is set to be at least one month later than the current time.
  3. Choose a reasonable MaxFeeBips. We recommend setting this value to 63.
  4. UseclientOrderId and/or channelId for better client-side tracking.
  5. Sign the order.
  6. Submit the order and receive the order's hash and status.

API description


HTTP Header

Field Type Required Description Example
X-API-KEY string Y ApiKey "HlkcGxbqBeaF76j4rvPaOasyfPwnkQ
6B6DQ6THZWbvrAGxzEdulXQvOKLrRW
ZLnN"

Request parameters

Field Type Required Description Example
exchangeId integer Y Exchange ID 1
orderId integer Y Order ID 1
accountId integer Y Account ID 1
tokenSId integer Y The ID of the token to be sold 0
tokenBId integer Y The ID of the token to be bought 2
amountS string Y Number of tokens to be sold "1000000000000000000"
amountB string Y Number of tokens to be bought "1000000000000000000"
allOrNone string N Whether the order can only be filled completely or 0 deals, currently only supports false "false"
buy string Y Buy until buy or sell until buy "true"
validSince integer Y Order effective time, accuracy is in seconds 1567053142
validUntil integer Y Order expiration time, accuracy is in seconds 1567053142
maxFeeBips integer Y Maximum order fee that the user can accept, value range (in ten thousandths) 1 ~ 63 20
label integer Y Order label, used to indicate the order attribute or source, etc., to participate in order signature, value range 0 ~ 65535 20
signatureRx string Y Rx part of order signed result "13375450901292179417
15497484957179306991
15173547203971250276
33242680470075859"
signatureRy string Y Ry part of order signed result "13375450901292179417
15497484957179306991
15173547203971250276
33242680470075859"
signatureS string Y S part of order signed result "13375450901292179417
15497484957179306991
15173547203971250276
33242680470075859"
clientOrderId string N The unique order ID of the client "1"
channelId string N Order channel ID, used to indicate from which channel the order was submitted "hebao::subchannel::0
001"
orderType string N Order type
Allowable : ['LIMIT_ORDER', 'TAKER_ONLY', 'MAKER_ONLY']
"LIMIT_ORDER"

Request example

HTTP
CURL
POST https://api.loopring.io/api/v3/order HTTP/1.1
Host: api.loopring.io
Connection: keep-alive
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: zh,en;q=0.9
X-API-KEY: sra1aavfa
Content-Type: application/json

{
    "exchangeId" : 1,
    "orderId" : 1,
    "accountId" : 1,
    "tokenSId" : 0,
    "tokenBId" : 2,
    "amountS" : "1000000000000000000",
    "amountB" : "1000000000000000000",
    "allOrNone" : "false",
    "buy" : "true",
    "validSince" : 1567053142,
    "validUntil" : 1567053142,
    "maxFeeBips" : 20,
    "label" : 20,
    "signatureRx" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
    "signatureRy" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
    "signatureS" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
    "clientOrderId" : "1",
    "channelId" : "hebao::subchannel::0001",
    "orderType" : "LIMIT_ORDER"
}
curl -X POST -H "X-API-KEY:sra1aavfa" -H "Content-Type:application/json" https://api.loopring.io/api/v3/order -d \
'{
    "exchangeId" : 1,
    "orderId" : 1,
    "accountId" : 1,
    "tokenSId" : 0,
    "tokenBId" : 2,
    "amountS" : "1000000000000000000",
    "amountB" : "1000000000000000000",
    "allOrNone" : "false",
    "buy" : "true",
    "validSince" : 1567053142,
    "validUntil" : 1567053142,
    "maxFeeBips" : 20,
    "label" : 20,
    "signatureRx" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
    "signatureRy" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
    "signatureS" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
    "clientOrderId" : "1",
    "channelId" : "hebao::subchannel::0001",
    "orderType" : "LIMIT_ORDER"
}'

Response fields

Field Type Required Description Example
resultInfo ResultInfo Y Information returned by the API /
data SubmitOrderResponseV3Item Y Result of the newly submitted order /

Response example

{
    "resultInfo" : {
        "code" : 0,
        "message" : "SUCCESS"
    },
    "data" : {
        "orderHash" : "13375450901292179417154974849571793069911517354720397125027633242680470075859",
        "status" : "NEW_ACTIVED, SUBMIT_ORDER_FAIL",
        "isIdempotent" : true
    }
}

Status code

Value Description
100000 Unknown error
102001 Exchange ID is incorrect
102002 Unsupported TokenId in the order
102003 Invalid account ID
102004 Invalid order ID
102005 Market does not support
102006 Illegal rate field
102007 Order already exists
102008 Order has expired
102010 Order is missing signature information
102011 Insufficient user balance
102012 The order amount is too small
102014 Failed to freeze the amount, please try again later
102020 Exceeded the maximum order amount
102027 Submit order fail
102120 Order is not valid
104001 Empty ApiKey
104002 Invalid ApiKey
104003 Invalid Account ID
104004 No signature information provided
104005 Wrong signature information

Model


SubmitOrderResponseV3Item

Submit order response detail

Field Type Required Description Example
orderHash string Y Order hash of submit order response "13375450901292179417
15497484957179306991
15173547203971250276
33242680470075859"
status string Y Order status of submit order response
Allowable : ['NEW_ACTIVED', 'SUBMIT_ORDER_FAIL', 'UNKNOWN']
"NEW_ACTIVED, SUBMIT_ORDER_FAIL"
isIdempotent boolean Y Idempotent of submit order response, submit same order again when order was UNKNOWN or WAIT_FREEZE_BALANCE in relayer, idempotent will be true
Allowable : [True, False]
"true"

results matching ""

    No results matching ""