tanX Docupaper
AboutTrade
  • ABOUT
    • 📒tanX Docupaper
  • TECH
    • 👩‍💻Tech Docupaper
      • 🏨High level architecture
      • 🤔Starkware logic
      • 🌊Transactional flow
        • Off-chain accounts
        • The deposit flow
        • The withdrawal flow
        • The trade flow
        • The transfer flow
        • Full withdrawal
    • 🔌API Documentation
      • 😋Getting started
        • Test connectivity
      • 📈Market
        • 24hr Tickers Price
        • K-line/Candlestick data
        • Orderbook
        • Recent trades
      • ↔️Trading
        • Create order
        • Get order
        • List orders
        • Cancel order
        • Bulk Cancel
        • List trades
      • 🔐Account
        • Generating L2 Key Pairs
        • Login
        • Deposit
        • Withdrawal
        • Profile Information
        • Balance details
        • Profit and loss details
      • 🌏Web-socket stream
        • 🗝️Private web-socket connection
        • 👥Public websocket connection
      • ✨Internal Transfer
        • Create Internal Transfer
        • Get Internal Transfer
        • Check User Existence
        • List Internal Transfers
      • 🧪SDK Reference
        • NodeJS SDK
        • Python SDK
  • LEGAL
    • ‼️tanX Disclaimer
Powered by GitBook
On this page
  • New order nonce
  • New order

Was this helpful?

  1. TECH
  2. API Documentation
  3. Trading

Create order

PreviousTradingNextGet order

Last updated 11 months ago

Was this helpful?

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 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 .

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

Field
Type
Mandatory
Description

market

STRING

YES

ord_type

STRING

YES

allowed values: [limit, market, stop_limit, limit_maker(post-only order) ].

To place a post-only order, send limit_maker as the order type.

price

FLOAT

OPTIONAL

It is required for creating limit order

side

STRING

YES

allowed values [buy, sell]

volume

FLOAT

YES

stop_price

FLOAT

OPTIONAL

It is required for creating stop limit order

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

Field
Type
Mandatory

msg_hash

STRING

YES

signature (both r & s)

STRING

YES

nonce

INTEGER

YES

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
  }
}

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

🔌
↔️
login
support@tanx.fi
NodeJs SDK signMsgHash