Create order

To place an order, grab the nonce and msg hash from the nonce api orders/nonce/ and provide them to the create order api /orders/create/.

Note: You will need to include the JWT Auth token to request headers to access this endpoint. To get the JWT Auth Token, refer the login section of this document.

If you are affiliated with the tanX organization, please ensure that you add the organization_key and api_key to the request body in both the nonce and create endpoints. This field is entirely optional. To obtain these keys, please reach out to tanX at support@tanx.fi.

New order nonce

Before creating a new order, youโ€™d be required to obtain a nonce and a msg hash by making use of this endpoint. Please note that this is a Private ๐Ÿ”’ route which means it needs to be authorized by the account initiating this request.

Endpoint

POST /sapi/v1/orders/nonce/

Request Headers

{
  "Authorization": "JWT ***"
}

Request Body

FieldTypeMandatoryDescription

market

STRING

YES

ord_type

STRING

YES

allowed values [limit, market]

price

FLOAT

OPTIONAL

It is required for creating limit order

side

STRING

YES

allowed values [buy, sell]

volume

FLOAT

YES

Example

{
  "market": "btcusdt",
  "ord_type": "limit",
  "price": 29580.51,
  "side": "sell",
  "volume": 0.015
}

Response

{
  "status": "success",
  "message": "order nonce created successfully, please sign the msg_hash to place the order",
  "payload": {
    "nonce": 931,
    "msg_hash": "0x5f128faa6e96360629b1fcb4f24fe9bc547f0d79c7a3aed056d824baa786755"
  }
}

New order

Create a new order. (Private ๐Ÿ”’)

Before creating a new order, youโ€™d be required to obtain a nonce by making use of this endpoint. Please note that this is a Private ๐Ÿ”’ route which means it needs to be authorized by the account initiating this request.

Endpoint

POST /sapi/v1/orders/create/

Request Headers

{
  "Authorization": "JWT ***"
}

Request Body

FieldTypeMandatory

msg_hash

STRING

YES

signature (both r & s)

STRING

YES

nonce

INTEGER

YES

To sign the msg hash obtained after accessing the nonce API, use the NodeJs SDK signMsgHash function.

import { signMsgHash } from '@tanx-libs/tanx-connector'

const sign = signMsgHash(createOrderNoncePayload, privateKey); 

After successfully generating the signature, you may send it together with additional parameters to create the order, as shown below.

Example

{
  "msg_hash": "0x5f128faa6e96360629b1fcb4f24fe9bc547f0d79c7a3aed056d824baa786755",
  "signature": {
    "r": "",
    "s": ""
  },
  "nonce": 931
}

Response

{
  "status": "success",
  "message": "Created Order Successfully",
  "payload": {
    "id": 904,
    "uuid": "6c79cde4-1e8f-4446-9b4a-ba176d50f08b",
    "side": "sell",
    "ord_type": "limit",
    "price": "29580.51",
    "avg_price": "0.0",
    "state": "pending",
    "market": "btcusdt",
    "created_at": "2022-05-27T12:36:57+02:00",
    "updated_at": "2022-05-27T12:36:57+02:00",
    "origin_volume": "0.015",
    "remaining_volume": "0.015",
    "executed_volume": "0.0",
    "maker_fee": "0.0",
    "taker_fee": "0.0",
    "trades_count": 0
  }
}

Last updated