Web Socket API documentation 1.0.0

Overview

Generating API Key

You will need to create an API key on the platform before you can use authenticated APIs. To create API keys, you can follow the steps below:

  • Login with your username / email and password into the website
  • Click on Account on the top right hand corner
  • Select the API tab
  • Click on New API button to create an API key and passphrase. (Note: the passphrase will only appear once)
  • Use your API key and passphrase to construct a signature.

Endpoints - wss://ws.exchange.freedx.com

Authentication

The WS Auth requires to send a payload with the Auth data in the Args key after doing the connection and before sending any other data. see Spot Authentication and Futures Authentication for details.

Status Code = 400

You might get 400 status code due to abnormal usage and we will block you for 10 minutes.

Ping/Pong handling

For connectivity checking, we will send a ping frame message every 3 minutes and you will need to respond pong frame message to us for checking, if the pong frame message doesn't correctly respond to us in 10 minutes, we will force to disconnect the connection.

  • #Spot
  • #Spot Orderbook Streaming
  • #Futures
  • #Futures Orderbook Streaming
  • #OTC
  • #Streaming

Operations

  • SUB Spot-Subscription

    Endpoint: /ws/spot

    Subscribe to a topic

    • #Spot

    Accepts the following message:

    Spot-Subscription

    To subscribe to a websocket feed

    object oneOf
    uid: subscription

    Examples

  • SUB Spot-Public-Trade-Fills

    Public Trade Fills

    Endpoint: /ws/spot

    • #Spot

    Accepts the following message:

    Spot-Public-Trade-Fills

    Subscribe to recent trade feed for a market. The topic will be tradeHistoryApi:<market> where <market> is the market symbol.
    *** response content ***

    object oneOf
    uid: publicTradeFills

    Examples

  • SUB Spot-Authentication

    Spot Authentication

    Endpoint: /ws/spot

    • #Spot

    Accepts the following message:

    Spot-Authentication

    Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:
    - request-nonce: 1624985375123
    - request-api:4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x
    - secret:848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx

    Our subscription request will be:

    Request Parameters
    Below details the arguments needed to be sent in.

    Generating a signature
    echo -n "/ws/spot1624985375123" | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
    (stdin)=c410d38c681579adb335885800cff24c66171b7cc8376cfe43da1408c581748156b89bcc5a115bb496413bda481139fb

    object oneOf
    uid: authentication

    Examples

  • SUB Spot-Notifications

    Spot Notifications

    Endpoint: /ws/spot

    • #Spot

    Accepts the following message:

    Spot-Notifications

    Receive trade notifications by subscribing to the topic notificationApiV3. The websocket feed will push trade level notifications to the subscriber. If topic is subscribed without being authenticated, no messages will be sent.
    *** response content ***

    object oneOf
    uid: notification

    Examples

  • SUB Spot-User-Trade-Fills

    Spot User Trade Fills

    Endpoint: /ws/spot

    • #Spot

    Accepts the following message:

    Spot-User-Trade-Fills

    When a trade has been transacted, this topic will send the trade information back to the subscriber.

    object oneOf
    uid: userTradeFills

    Examples

  • SUB Spot-OSS-L1-Snapshot

    OSS Level 1 Orderbook Snapshot

    Endpoint: /ws/oss/spot
    The format to subscribe to will be symbol. The L1 orderbook will be pushed immediately when orderbook changes.

    • symbol indicates the market symbol.
    • #Spot Orderbook Streaming

    Accepts the following message:

    Spot-OSS-L1-Snapshot


    *** response content ***

    object oneOf
    uid: OSSL1SnapshotByGrouping

    Examples

  • SUB Spot-Orderbook-Incremental-Updates

    Orderbook Incremental Updates

    Endpoint: /ws/oss/spot
    Subscribe to Orderbook incremental updates through the endpoint /ws/oss/spot. The topic to subscribe to will be update specifying the symbol (eg. update:BTC-USD). The first response received will be a snapshot of the current orderbook (this is indicated in the type field) and 50 levels will be returned. Incremental updates will be sent in subsequent packets with type delta.
    Bids and asks will be sent in price and size tuples. The size sent will be the new updated size for the price. If a value of 0 is sent, the price should be removed from the local copy of the orderbook.
    To ensure that the updates are received in sequence, seqNum indicates the current sequence and prevSeqNum refers to the packet before. seqNum will always be one after the prevSeqNum. If the sequence is out of order, you will need to unsubscribe and re-subscribe to the topic again.
    Also if crossed orderbook ever occurs when the best bid higher or equal to the best ask, please unsubscribe and re-subscribe to the topic again.
    *** response content ***

    • #Spot Orderbook Streaming

    Accepts the following message:

    Spot-Orderbook-Incremental-Updates


    *** response content ***

    object oneOf
    uid: orderbookIncrementalUpdates

    Examples

  • SUB Futures-Subscription

    Futures Subscription

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Futures-Subscription

    To subscribe to a websocket feed

    object oneOf
    uid: subscription

    Examples

  • SUB Futures-Public-Trade-Fills

    Futures Public Trade Fills

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Futures-Public-Trade-Fills

    Subscribe to recent trade feed for a market. The topic will be tradeHistoryApiV2:<market> where <market> is the market symbol.
    *** response content ***

    object oneOf
    uid: publicTradeFills

    Examples

  • SUB Futures-Authentication

    Futures Authentication

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Futures-Authentication

    Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:
    - request-nonce: 1624985375123
    - request-api:4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x
    - secret:848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx

    Our subscription request will be:

    Request Parameters
    Below details the arguments needed to be sent in.

    Generating a signature
    echo -n "/ws/futures1624985375123" | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
    (stdin)=bd8afb8bee58ba0a2c67f84dcfe6e64d0274f55d064bb26ea84a0fe6dd8c621b541b511982fb0c0b8c244e9521a80ea1

    object oneOf
    uid: authentication

    Examples

  • SUB Futures-Notifications

    Futures Notifications

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Futures-Notifications

    Receive trade notifications by subscribing to the topic notificationApiV4. The websocket feed will push trade level notifications to the subscriber. If topic is subscribed without being authenticated, no messages will be sent.
    *** response content ***

    object oneOf
    uid: notification

    Examples

  • SUB Futures-User-Trade-Fills

    Futures User Trade Fills

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Futures-User-Trade-Fills

    When a trade has been transacted, this topic will send the trade information back to the subscriber.

    object oneOf
    uid: userTradeFills

    Examples

  • SUB Futures-All-Position

    Futures All Position

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    All-Position

    All futures positions will be pushed periodically (per 5 secs) via this topic.
    Response Content

    object oneOf
    uid: allPosition

    Examples

  • SUB Futures-Positions

    Futures Positions

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Positions

    Publish user's current position per 5 secs. When no symbol is specified, positions for all markets will be returned.
    You will receive a record with price equals to zero when position is closed. (All-Position won't have this record)

    object oneOf
    uid: allPosition

    Examples

  • SUB Futures-Open-Orders

    Futures Open Orders

    Endpoint: /ws/futures

    • #Futures

    Accepts the following message:

    Futures-Open-Order

    Offer user's current open orders
    if subscribed, websocket will responsd at the time:

    1. after subscription

    2. after order placed, amended, cancelled, filled (notification received)

    • Only after subscribed, websocket will return SNAPSHOT, otherwise, only return UPDATE data. (check type column)
    • So that, clients should maintain their own open order snapshot.
    • For UPDATE data, if the amount is 0, that means the order is cancelled or fully filled, otherwise, order is inserted, amended or partially filled.
    • The serialId should be continuous. If a client receives non-continuous serialId, it has better to subscribe again since UPDATE datas are missed.
    object oneOf
    uid: FuturesOpenOrder

    Examples

  • SUB Futures-OSS-L1-Snapshot

    OSS Level 1 Orderbook Snapshot

    Endpoint: /ws/oss/futures
    The format to subscribe to will be symbol. The L1 orderbook will be pushed immediately when orderbook changes.

    • symbol indicates the market symbol.
    • #Futures Orderbook Streaming

    Accepts the following message:

    Futures-OSS-L1-Snapshot


    *** response content ***

    object oneOf
    uid: OSSL1SnapshotByGrouping

    Examples

  • SUB Futures-Orderbook-Incremental-Updates

    Futures Orderbook Incremental Updates

    Endpoint: /ws/oss/futures
    Subscribe to Orderbook incremental updates. The topic to subscribe to will be update specifying the symbol (eg. update:BTC-PERP). The first response received will be a snapshot of the current orderbook (this is indicated in the type field) and 50 levels will be returned. Incremental updates will be sent in subsequent packets with type delta.
    Bids and asks will be sent in price and size tuples. The size sent will be the new updated size for the price. If a value of 0is sent, the price should be removed from the local copy of the orderbook.
    To ensure that the updates are received in sequence, seqNum indicates the current sequence and prevSeqNumrefers to the packet before. seqNum will always be one after the prevSeqNum. If the sequence is out of order, you will need to unsubscribe and re-subscribe to the topic again.
    Also if crossed orderbook ever occurs when the best bid higher or equal to the best ask, please unsubscribe and re-subscribe to the topic again.

    • #Futures Orderbook Streaming

    Accepts the following message:

    Futures-Orderbook-Incremental-Updates


    *** response content ***

    object oneOf
    uid: orderbookIncrementalUpdates

    Examples

  • SUB Authentication

    OTC Authentication

    Endpoint: /ws/otc

    • #OTC
    • #Streaming

    Accepts the following message:

    Authentication

    Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:
    - request-nonce: 1624985375123
    - request-api:4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x
    - secret:848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx

    Our subscription request will be:

    Request Parameters
    Below details the arguments needed to be sent in.

    Generating a signature
    echo -n "/ws/otc1624985375123" | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
    (stdin)=971798b32585d7e63a1c2cafd261170c56caf17ff1d32a58fc2e9842292fa8ff2dbcf4fda7b4d6aed4a737c3c2930cf1

    object oneOf
    uid: authentication

    Examples

  • SUB Quote-Stream

    OTC Quote Stream

    Endpoint: /ws/otc

    • #OTC
    • #Streaming

    Accepts the following message:

    Quote-Stream

    Receive quote streams by subscribing to the quote websocket. The websocket topic will constantly push new prices to the subscriber. To accept the quote, indicate the buy or sell quote Id using the /accept API.

    object oneOf
    uid: quoteStream

    Examples