Brine's Docupaper
AboutTrade
  • ABOUT
    • ๐Ÿ“’Brine Docupaper
    • ๐Ÿช™Tokenomics
  • ๐Ÿ—ž๏ธBrine Bytes
    • ๐ŸงตOctober Edition
  • 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
        • List trades
      • ๐Ÿ”Account
        • Login
        • 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
  • FOR USERS
    • ๐Ÿ“’User Docuguide
      • ๐Ÿ’ปWeb App
        • Sign up through Metamask
        • Sign up through Wallet Connect
        • Place a Market Order Trade
        • Place a Limit Order Trade
        • Refer Brine to a Friend
        • Deposit with Metamask
        • Withdraw to Metamask
  • LEGAL
    • โ€ผ๏ธ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 1 year 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 Brine 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 Brine 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]

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

Field
Type
Mandatory

msg_hash

STRING

YES

signature (both r & s)

STRING

YES

nonce

INTEGER

YES

import { signMsgHash } from '@brine-fi/brine-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@brine.fi
NodeJs SDK signMsgHash