WebSocket API
API
There are two types of channels: * Public: accessible by anyone * Private: accessible only by given member
GET request parameters:
Field | Description | Multiple allowed |
| List of streams to be subscribed on | Yes |
List of supported public streams: * <market>.ob-inc
market order-book update * <market>.trades
* <market>.kline-PERIOD
(available periods are "1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w") * global.tickers
List of supported private streams (requires authentication): * order
* trade
You can find a format of these events below in the doc.
Authentication
JS Example
1.Use API Key for the private WebSockets connection. Example:
3.If authentication was done, server will respond successfully.
Otherwise server will return an error:
Status Code: 401 Unauthorized
If other error occurred during the message handling server throws an error:
Streams subscription
Using parameters
You can specify streams to subscribe to by passing the stream
GET parameter in the connection URL. The parameter can be specified multiple times for subscribing to multiple streams.
example:
This will subscribe you to tickers and trades events from ethusd market once the connection is established.
Subscribe and unsubscribe events
You can manage the connection subscriptions by send the following events after the connection is established:
Subscribe event will subscribe you to the list of streams provided:
The server confirms the subscription with the following message and provides the new list of your current subscriptions:
Unsubscribe event will unsubscribe you to the list of streams provided:
The server confirms the unsubscription with the following message and provides the new list of your current subscriptions:
Public streams
Order-Book
This stream sends a snapshot of the order-book at the subscription time, then it sends increments. Volumes information in increments replace the previous values. If the volume is zero the price point should be removed from the order-book.
Register to stream <market>.ob-inc
to receive snapshot and increments messages.
Example of order-book snapshot:
Example of order-book increment message:
Trades
Here is structure of <market>.trades
event expose as array with trades:
Field | Description |
| Unique trade tid. |
| Taker type of trade, either |
| Price for the trade. |
| The amount of trade. |
| Trade create time. |
Kline point
Kline point as array of numbers:
Timestamp.
Open price.
Max price.
Min price.
Last price.
Period volume
Example:
Tickers
Here is structure of global.tickers
event expose as array with all markets pairs:
Field | Description |
| Date of current ticker. |
| Market pair name. |
| Base currency. |
| Quote currency. |
| Lowest price in 24 hours. |
| Highest price in 24 hours. |
| Last trade price. |
| Last trade from last timestamp. |
| Last trade price. |
| Volume in 24 hours. |
| Best price per unit. |
| Best price per unit. |
| Average price for last 24 hours. |
| Average price change in percent. |
Private streams
Order
Here is structure of Order
event:
Field | Description |
| Unique order id. |
| The market in which the order is placed. (In backend |
| Order type, either |
| Order price. |
| Order average price. |
| One of |
| The amount user want to sell/buy. |
| Remaining amount user want to sell/buy. |
| Executed amount for current order. |
| Order create time. |
| Order create time. |
| Trades with this order. |
| Type of order, either |
| Order create time. (Deprecated) (In backend |
Trade
Here is structure of Trade
event:
Field | Description |
| Unique trade identifier. |
| Price for each unit. |
| The amount of trade. |
| The total of trade (volume * price). |
| The market in which the trade is placed. (In backend market_id) |
| Type of order in trade that related to current user |
| Order side of the taker for the trade, either |
| Trade create time. |
| User order identifier in trade. |
Subscribe to streams
Websocket API is located at https://nebulaecn.com/api/v2/trading
. If you pass a JWT header, your connection will be authenticated, otherwise it will be considered anonymous.
Example
Get your open orders
Order response schema
Field | Example |
Market | "btcusd" |
ID | 97 |
UUID | "6dcc2c8e-c295-11ea-b7ad-1831bf9834b0" |
Side | "sell" |
State | "w" |
Type | "l" |
Price | "9120" |
Avg. Price | "0" |
Volume | "0.25" |
Orig. Volume | "0.25" |
Executed Volume | "0" |
Trades Count | 0 |
Timestamp | 1594386563 |
Get order by uuids
Get order trades
Trade response schema
Field | Example |
Market | "btcusd" |
ID | 33 |
Price | "9120" |
Amount | "0.25" |
Total | "2280" |
OrderID | 100 |
OrderUUID | "ab224fef-c2a2-11ea-b670-1831bf9834b0" |
OrderSide | "buy" |
TakerSide | "buy" |
Fee | "0.0005" |
Fee Unit | "btc" |
Timestamp | 1594392250 |
Create order
Arguments:
Arg | Comment |
Market | |
Type | M is Market L is Limit P is PostOnly |
Side | buy or sell |
amount | sting, int, float |
price | ignored for market order |
Responds with ok and uuid of new order if order is pushed to engine. Response with error and short description in case of failure.
Example
Response
Cancel order
Arguments:
Arg | Desc |
Mode | id, uuid, market, all(any market) |
ID | ID, UUID or market ID respectively |
NOTE: cancels multiple orders for "market" and "all"
Example
Response
Bulk order create
Arguments: array or Create order params
Responds with array of:
uuid for crated order
"error" if some error ocurred
Example
Response
Bulk order cancel
Arguments:
Arg | Desc |
Mode | id or uuid |
[ID] | List of IDs or UUIDs respectively |
Echoes argument or puts error for argument which could not be parsed.
Example
Response
Last updated