NAV

CoinFLEX Trade Engine APIs

CoinFLEX's application programming interfaces (APIs) provide our clients programmatic access to control aspects of their accounts and to place orders on CoinFLEX's trading platforms.

CoinFLEX provides several APIs:

Using these interfaces it is possible to make both authenticated and unauthenticated API calls, with the exception of the Futures Event Stream which is authenticated only.

Access keys are available on the CoinFLEX logged-in dashboard page for verified users which, in conjunction with your account password, allow authenticated use these APIs.

General notes

To protect the performance of the system, CoinFLEX imposes certain limits on the rates at which you may issue commands to the API. Please see Request Limits.

All quantities and prices are transmitted and received as integers with implicit scale factors. For scale information, please see Scaling.

CoinFLEX has published client libraries for several popular languages to aid you in implementing your client application.

Getting started with the WebSocket API

The WebSocket API is accessible via WebSocket connection to the following URLs:

DEMO/STAGE site

wss://stgapi.coinflex.com/v1 (encrypted)

LIVE site

wss://api.coinflex.com/v1 (encrypted)

Commands, replies, and notifications traverse the WebSocket in text frames with JSON-formatted payloads.

Click here for more details on how to use the WebSocket API

CoinFLEX Authentication Process

WebSocket clients authenticate by sending an authentication message containing a numeric user identifier, a cookie (described as an API key on the CoinFLEX website), a nonce chosen by the client, and an ECDSA signature. The signature covers the user identifier, a nonce chosen by the server (which is transmitted to the client upon its connecting to the server), and the nonce chosen by the client. The connection is secured using TLS.

Protocol

Example

Suppose a client whose user identifier is 1 and whose passphrase is "opensesame" wishes to authenticate to the WebSocket server.

1. The client connects to the server and performs the WebSocket handshake.

2. The server sends a Welcome notification and a randomly generated 16-bytes server nonce:

{
    "notice": "Welcome",
    "nonce": "azRzAi5rm1ry/l0drnz1vw=="
}

3. The client decodes the server nonce into these 16 bytes:

0x6b347302 2e6b9b5a f2fe5d1d ae7cf5bf

N.B: Spaces are shown for the sake of clarity and do not denote elements of the actual value.

4. The client randomly generates a 16-byte client nonce:

0xf08c98ca f1fd82e8 cea9825d bff04fd0

5. The client encodes the client nonce using base64:

8IyYyvH9gujOqYJdv/BP0A==

6. The client's cookie is:

HGREqcILTz8blHa/jsUTVTNBJlg=

7. The client constructs a 40-byte message to sign, consisting of its user_id, the server nonce, and the client nonce:

0x00000000 00000001
0x6b347302 2e6b9b5a f2fe5d1d ae7cf5bf
0xf08c98ca f1fd82e8 cea9825d bff04fd0

8. The client constructs a seed for its private key, consisting of its user_id and UTF-8-encoded passphrase:

0x00000000 00000001
0x6f70656e 73657361 6d65

9. The client hashes its seed using SHA-224 to obtain its private key:

0xb89ea7fc d22cc059 c2673dc2 4ff40b97 83074646 86560d0a d7561b83

10. The client signs the 28-byte SHA-224 digest of the 40-byte message using its private key under secp224k1 and obtains, for example:

r = 0x3fb77a9d 7b5b2a68 209e76f6 872078c5 791340d5 989854ad a3ab735e
s = 0x34b84341 2f18a910 f18a7d4c e1d35978 60e6345b 22bf7894 cf67780a

The sign_secp224k1 utility may be used to produce the signature.

N.B: The signature (r, s) generated by the ECDSA is non-deterministic. Furthermore, the signature (r, s) is still non-deterministic if you use the deterministic server nonce and client nonce to build the codes, this is due to the nature of ECDSA.

11. The client encodes the signature using base64:

P7d6nXtbKmggnnb2hyB4xXkTQNWYmFSto6tzXg==
NLhDQS8YqRDxin1M4dNZeGDmNFsiv3iUz2d4Cg==

12. The client sends an Authenticate command to the server:

{
    "method": "Authenticate",
    "user_id": 1,
    "cookie": "HGREqcILTz8blHa/jsUTVTNBJlg=",
    "nonce": "8IyYyvH9gujOqYJdv/BP0A==",
    "signature": [
        "P7d6nXtbKmggnnb2hyB4xXkTQNWYmFSto6tzXg==",
        "NLhDQS8YqRDxin1M4dNZeGDmNFsiv3iUz2d4Cg=="
    ]
}

13. The server verifies the cookie and signature and returns a success response:

{
    "error_code": 0
}

Authentication to the WebSocket server is by a Welcome notification sent to the client and an Authenticate command sent by the client.

CoinFLEX BIST API

BIST is no longer supported by CoinFLEX.

Contracts

Dates

Futures contracts will run for 2 months and end at midday (UTC) on the final Friday of the named month. There will also be a ramp-up period that starts on Wednesday at midday (UTC) leading up to the final Friday of the named month.

In the 24 hours starting from the Wednesday at 12pm (UTC) until 12pm (UTC) on Thursday, CoinFLEX will increase the margin requirement for all users. In the final 24 hours leading to the final Friday of the month, this margin requirement will be maintained.

Month 2020 (ramp-up start) 2020 (expiry) code
JAN Wed, 29th Jan Fri, 31st Jan F
FEB Wed, 26th Feb Fri, 28th Feb G
MAR Wed, 25th Mar Fri, 27th Mar H
APR Wed, 22nd Apr Fri, 24th Apr J
MAY Wed, 27th May Fri, 29th May K
JUN Wed, 24th Jul Fri, 26th Jun M
JUL Wed, 29th Jul Fri, 31st Jul N
AUG Wed, 26th Aug Fri, 28th Aug Q
SEP Wed, 23rd Sep Fri, 25th Sep U
OCT Wed, 28th Oct Fri, 30th Oct V
NOV Wed, 25th Nov Fri, 27th Nov X
DEC Wed, 23rd Dec Fri, 25th Dec Z

Event Stream

DEMO/STAGE site

LIVE site

CoinFLEX offers an Event Stream resource that complies with the Server-Sent Events specification by the W3C. This resource delivers a continuous, consistent stream of events related to market and account activity on the CoinFLEX platform. It is offered as a simpler alternative to CoinFLEX's WebSocket API for clients that do not require bidirectional communication with the platform.

The Event Stream resource supports the standard Last-Event-ID request header to enable transiently disconnected clients to reconnect and resume the event stream without missing any events. See the Server-Sent Events specification for details.

Authentication

[[ Version 2: The Event Stream resource may be requested without authentication, in which case only public events (order book and ticker changes) are returned. ]]

Requests for the Event Stream resource [[ Version 1: must ]] [[ Version 2: may ]] authenticate using HTTP Basic Authentication, wherein the user-id is the concatenation of user's numeric ID, a slash, and the user's Base64-encoded API key, and the password is the user's password or the Base64 encoding of the user's 28-byte private key that is derived from the user's ID and password. Authenticated requests will receive account-private events (balance changes and more details on the user's own order events) in addition to the public events.

BalanceChanged

[[ Version 1:

event: BalanceChanged
data: {
data:   "asset": <integer>,
data:   "balance": <integer>
data: }

]]

[[ Version 2:

event: BalanceChanged
data: {
data:   "asset": <integer>,
data:   "available": <integer>,
data:   "reserved": <integer>
data: }

]]

OrderOpened

event: OrderOpened
data: {
data:   "base": <integer>,
data:   "counter": <integer>,
data:   "id": <integer>,
data:   "tonce": <integer>,
data:   "quantity": <integer>,
data:   "price": <integer>,
data:   "time": <integer>
data: }

OrdersMatched

event: OrdersMatched
data: {
data:   "base": <integer>,
data:   "counter": <integer>,
data:   "bid": <integer>,
data:   "bid_tonce": <integer>,
data:   "ask": <integer>,
data:   "ask_tonce": <integer>,
data:   "quantity": <integer>,
data:   "price": <integer>,
data:   "total": <integer>,
data:   "bid_rem": <integer>,
data:   "ask_rem": <integer>,
data:   "time": <integer>,
data:   "bid_base_fee": <integer>,
data:   "bid_counter_fee": <integer>,
data:   "ask_base_fee": <integer>,
data:   "ask_counter_fee": <integer>
data: }

OrderClosed

event: OrderClosed
data: {
data:   "base": <integer>,
data:   "counter": <integer>,
data:   "id": <integer>,
data:   "tonce": <integer>,
data:   "quantity": <integer>,
data:   "price": <integer>
data: }

TickerChanged

event: TickerChanged
data: {
data:   "base": <integer>,
data:   "counter": <integer>,
data:   "last": <integer>,
data:   "bid": <integer>,
data:   "ask": <integer>,
data:   "low": <integer>,
data:   "high": <integer>,
data:   "volume": <integer>
data: }

UserTradeVolumeChanged

[[ Version 2:

event: UserTradeVolumeChanged
data: {
data:   "asset": <integer>,
data:   "volume": <integer>
data: }

]]

Futures API Specification

DEMO/STAGE site

API endpoint URL: https://stgwebapi.coinflex.com/

LIVE site

API endpoint URL: https://webapi.coinflex.com/

Contents

Currently, the Futures API supports the following endpoints:

Authentication

All method calls require HTTP Basic authentication. The username portion of the Basic credentials is constructed by concatenating the numeric user ID, a slash, and the user's API authentication cookie. The password portion is simply the user's login passphrase.

Common Record Types

<collateral>

{
    "asset_id": <integer>,
    "available": <integer>
    "total": <integer>
}

<offer>

{
    "id": <integer>,
    "created": <integer>,
    "rescinded": <integer>,
    "asset_id": <integer>,
    "amount": <integer>,
    "min_amount": <integer>,
    "max_amount": <integer>,
    "term": <integer>,
    "initial_margin": <integer>,
    "maintenance_margin": <integer>,
    "apr": <integer>,
    "qualifiers": ["<string>", ]
}

<loan>

{
    "id": <integer>,
    "offer_id": <integer>,
    "initiated": <integer>,
    "asset_id": <integer>,
    "principal": <float>,
    "term": <integer>,
    "initial_margin": <integer>,
    "maintenance_margin": <integer>,
    "apr": <integer>,
    "qualifiers": ["<string>", ]
}

GET /borrower/events

Request

GET '/borrower/events' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: text/event-stream; charset=UTF-8

event: Collateral
data: [<collateral>, ]

event: Offers
data: [<offer>, ]

event: OfferOpened
data: <offer>

event: OfferUpdated
data: <offer>

event: OfferClosed
data: {"id": <integer>}

event: Loans
data: [<loan>, ]

event: LoanInitiated
data: <loan>

event: LoanUpdated
data: <loan>

event: LoanTerminated
data: {"id": <integer>}

Returns a stream of events pertaining to the user's borrowing activity. The response body is an indefinitely long document in text/event-stream format.

Optionally, the Base64-encoded HTTP Basic authentication string may be passed to this resource in an auth query string parameter rather than in the standard Authorization request header. This option is provided as a workaround for a deficiency in some EventSource client implementations.

GET /borrower/conversion/

Request

GET '/borrower/conversion/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[
    {
        "asset_from": <integer>,
        "asset_to": <integer>
    },
    
]
  • asset_from: (integer) The numeric code of the asset to convert from.
  • asset_to: (integer) The numeric code of the asset to convert to.

Returns the list of asset pairs available for conversion.

POST /borrower/conversion/

Request

POST '/borrower/conversion/' HTTP/1.1
Content-Type: application/x-www-form-urlencoded

asset_from=<integer>&asset_to=<integer>&amount=<integer>

Initiates a conversion of assets.

Response

HTTP/1.1 201 Created
Content-Type: application/json; charset=US-ASCII
{
    "asset_from": <integer>,
    "asset_to": <integer>,
    "amount": <integer>
}
  • asset_from: (integer) .
  • asset_to: (integer) .
  • amount: (integer) The scaled amount of the asset to convert from.

The Location response header contains the numeric identifier of the newly initiated loan.

Errors

  • If the asset code specified in asset_from or asset_to was not found:
HTTP/1.1 404 Not Found
Content-Length: 0

<explanation>
  • If the request is invalid (e.g. missing attributes, not enough balance) this method returns:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=US-ASCII

<explanation>

GET /borrower/converted_totals/

Request

GET '/borrower/converted_totals/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[
    {
        "asset_from": <integer>,
        "asset_to": <integer>,
        "total": <integer>
    },
    
]
  • asset_from: (integer) The numeric code of the asset to convert from.
  • asset_to: (integer) The numeric code of the asset to convert to.
  • total: (integer) The total quantity of the asset which has been converted.

Returns the list of total converted quantities for each valid asset pair.

GET /borrower/collateral/

Request

GET '/borrower/collateral/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<collateral>, ]

Returns the collateral available to the user in various assets.

GET /borrower/collateral/<id>

Request

GET '/borrower/collateral/<id>' HTTP/1.1
  • id: (integer) The numeric asset code of the asset in which to report available collateral.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<collateral>

Errors

  • If the specified asset was not found, then this method returns:
HTTP/1.1 404 Not Found
Content-Length: 0

Returns the collateral available to the user in the specified asset.

GET /borrower/offers/

Request

GET '/borrower/offers/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<offer>, ]

Returns the loan offers available to the user.

GET /borrower/offers/<id>

Request

GET '/borrower/offers/<id>' HTTP/1.1
  • id: (integer) The numeric identifier of the loan offer to return.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<offer>

Errors

  • If the specified loan offer was not found, then this method returns:
HTTP/1.1 404 Not Found
Content-Length: 0
  • If the specified loan offer is not visible to the user, then this method returns:
HTTP/1.1 403 Forbidden
Content-Length: 0

Returns the specified loan offer.

GET /borrower/loans/

Request

GET '/borrower/loans/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<loan>, ]

Returns the borrower's outstanding loans.

GET /borrower/loans/<id>

Request

GET '/borrower/loans/<id>' HTTP/1.1
  • id: (integer) The numeric identifier of the loan to return.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<loan>

Errors

  • If the specified loan was not found, then this method returns:
HTTP/1.1 404 Not Found
Content-Length: 0
  • If the specified loan is not visible to the user, then this method returns:
HTTP/1.1 403 Forbidden
Content-Length: 0

Returns the borrower's specified outstanding loan.

POST /borrower/loans/

Request

POST '/borrower/loans/' HTTP/1.1
Content-Type: application/x-www-form-urlencoded

offer_id=<integer>&amount=<integer>
  • offer_id: (integer) The numeric identifier of an available loan offer.
  • amount: (integer) The scaled amount of the offered asset to borrow.

Response

HTTP/1.1 201 Created
Location: <id>
Content-Type: application/json; charset=US-ASCII
<loan>

The Location response header contains the numeric identifier of the newly initiated loan.

Errors

  • If the specified loan offer was not found, then this method returns:
HTTP/1.1 404 Not Found
Content-Length: 0
  • If the requested loan was not allowed, then this method returns:
HTTP/1.1 403 Forbidden
Content-Type: text/plain; charset=US-ASCII
<explanation>

Initiates a loan.

POST /borrower/loans/<id>

Request

POST '/borrower/loans/<id>' HTTP/1.1
Content-Type: application/x-www-form-urlencoded

amount=<integer>
  • id: (integer) The numeric identifier of the outstanding loan to repay.
  • amount: (integer) The scaled amount to repay.

Response

HTTP/1.1 204 No Content

Errors

  • If the specified loan was not found, then this method returns:
HTTP/1.1 404 Not Found
Content-Length: 0
  • If the requested repayment was not allowed, then this method returns:
HTTP/1.1 403 Forbidden
Content-Type: text/plain; charset=US-ASCII
<explanation>

Partially repays an outstanding loan.

DELETE /borrower/loans/<id>

Request

DELETE '/borrower/loans/<id>' HTTP/1.1
  • id: (integer) The numeric identifier of the outstanding loan to repay.

Response

HTTP/1.1 204 No Content

Errors

  • If the specified loan was not found, then this method returns:
HTTP/1.1 404 Not Found
Content-Length: 0
  • If the requested repayment was not allowed, then this method returns:
HTTP/1.1 403 Forbidden
Content-Type: text/plain; charset=US-ASCII
<explanation>

Fully repays an outstanding loan.

GET /borrower/margin_ratios/

Request

GET '/borrower/margin_ratios/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
{
    "asset_id": <integer>,
    "collateral": <integer>,
    "loan": <integer>,
    "ratio": <float>
}
  • asset_id: (integer) The numeric asset code of an asset in which the user's margin ratio is reported.
  • collateral: (integer) The scaled amount of the user's available collateral in the asset.
  • loan: (integer) The scaled amount of the asset borrowed.
  • ratio: (float) The margin ratio of the asset.

Returns the margin ratio of the user for all assets where leverage funding has been taken out. However it is recommended that users should connect to the Event Stream resource at /borrower/events and perform the necessary calculations on the data provided therein.

CoinFLEX API Client Implementation Guide

This document supplements the CoinFLEX WebSocket API reference to provide non-normative recommendations to implementers of CoinFLEX API client software. This document assumes no particular programming language, model, or library and simply discusses the message flow between the client and the server at a network protocol level.

Authenticating

Client authentication to the CoinFLEX API is in the form of an elliptic-curve digital signature, where the private key is derived from the user's numeric ID and textual passphrase and the message that is signed encompasses the numeric user ID and two nonces, one generated by the server and the other generated by the client. Although the mathematics involved comprise only simple arithmetic, they are rather cumbersome, and so a library implementation is suggested. The CoinFLEX JavaScript client library supplies a pure-JavaScript implementation of the necessary algorithms, and the CoinFLEX Java client library makes use of the standard Java Cryptography Architecture or the Bouncy Castle library, depending on the Java release.

Details of the signature generation procedure are provided in the CoinFLEX Authentication Process document. To summarise, the signature algorithm to use is "SHA-224 with ECDSA," and the elliptic curve to use is secp224k1.

This structure is defined in Appendix C of SEC 1: Elliptic Curve Cryptography and is reproduced here for convenience:

ECDSA-Sig-Value ::= SEQUENCE {
        r INTEGER,
        s INTEGER,
        a INTEGER OPTIONAL,
        y CHOICE { b BOOLEAN, f FieldElement } OPTIONAL
}

One challenge that often arises when using external cryptography libraries to generate the digital signature is that the two numeric components of the signature may not be directly exposed by the library's API. Instead, often the library will return a DER-encoded structure containing the signature components.

In practice, libraries omit the optional fields a and y and encode only the r and s integers. These integers are what must be transmitted to CoinFLEX in the signature field of the Authenticate command message. An algorithm for extracting these integer values from the DER-encoded ECDSA-Sig-Value follows:

  1. The value of the first byte of the DER encoding must be 0x30 (the ASN.1 tag for a SEQUENCE), and the value of the second byte must be equal to the number of bytes remaining in the encoding after these first two bytes.
  2. The value of the third byte must be 0x02 (the ASN.1 tag for an INTEGER), and the value of the fourth byte gives the length (in bytes) of the encoding of the first integer, r. Capture this number of bytes (following the length byte) as r, the first component of the signature.
  3. The value of the next byte (after the bytes captured as r) must be 0x02, and the value of the following byte gives the length (in bytes) of the encoding of the second integer, s. Capture this number of bytes (following the length byte) as s, the second component of the signature.
  4. The bytes captured as s must extend to the end of the overall encoding, assuming the optional a and y fields are omitted.
  5. The Authenticate command expects each of the two signature components, r and s, to be 28 bytes in length. The DER encoding of each of these components may have spanned fewer than 28 bytes, in which case you must zero-extend (with 0x00 bytes) the encoding on the left to exactly 28 bytes, or the encoding may have been 29 bytes in length, in which case you must truncate the encoding on the left to exactly 28 bytes, and the value of the removed byte must have been 0x00.
  6. With r and s now exactly 28 bytes in length, encode these byte strings using Base64 and place the encoded character strings into an array of two elements. This array becomes the value of the signature field in the Authenticate message.

Maintaining a Local View of an Order Book

Implementers may wish to maintain a local view of an order book. This can be effected by capturing a snapshot of the live order book and then incrementally applying incoming notices to keep the view current. Maintaining such a view incrementally is vastly more efficient than repeatedly polling the server for the complete order book, and your view is guaranteed to remain perfectly consistent with the live order book on the server if you exactly implement these rules:

Tracking Fills of Your Orders

When you place an order, you will likely want to know when it fills, at what price, and by what quantity. The OrdersMatched notice provides all of this information, but there is a caveat that you must account for. You may receive one or more OrdersMatched notices pertaining to your order before you have received the reply to your PlaceOrder command. Because you won't learn the ID of your new order until you receive the reply message, you may not recognise the notices as pertaining to your order. What follows are two strategies for dealing with this.

Note that it is possible to place an order that matches against one of your own open orders. In this case the emitted OrdersMatched notice will contain both bid_tonce and ask_tonce fields, indicating that both orders belonged to you. Such "self-trades" are never assessed any trade fees, and they do not contribute to trade volumes.

How Balance Reservations Work

When you place an order, some quantity of your available balance becomes reserved. A bid order takes its reservation from your counter asset balance, while an ask order takes its reservation from your base asset balance. The reserved amount is the amount that you would trade away if your order were to be matched. Cancelling your order causes its reservation to be returned to your available balance.

The amount of an ask order's reservation is simply the quantity of the base asset that the order is seeking to sell. The amount of a bid order's reservation is calculated by the formula ceil(quantity * price / 10000), where quantity and price are the scaled values given in the PlaceOrder command, and the result of the formula has the scale of the counter asset. As an example, an order to buy 12345 units of the base asset at a price of 1234500 would reserve 1523991 units of the counter asset.

Stochastic Rounding

When the trade engine computes a trade total (the amount of the counter asset that changes hands in a trade) or a trading fee, it must round the exact number to a whole number of asset units. Rather than following a deterministic rounding rule — such as "round to the nearest integer" or "always round up" — which could be gamed by savvy users to the detriment of others, the trade engine performs stochastic rounding: real numbers very close to the next lower integer are very likely to be rounded down, and real numbers very close to the next higher integer are very likely to be rounded up. The exact probability of rounding up is precisely equal to the fractional part of the real number. For example, 43.21 has a 21% chance of being rounded up to 44 (and a 79% chance of being rounded down to 43). Stochastic rounding minimizes the cumulative rounding error in the long run, resulting in fairer trades and fairer fees for all users.

How Fees Affect Trade Quantities

At the time of this writing, CoinFLEX charges trading fees only on the counter asset in a trade. On the seller's side the trading fee is taken from the proceeds of the sale, meaning the seller receives slightly less of the counter asset from the sale than the amount of the counter asset that was traded. The situation on the buyer's side is less clear: the buyer receives an amount of the base asset in the trade but must pay the trading fee in the counter asset and may have insufficient available balance in the counter asset to pay the fee. In this scenario, the buyer's trading fee is taken out of the bid order's reservation, leaving a lesser amount of the reservation remaining to be traded. As an example, an order to buy Ƀ1.0000 might end up buying only Ƀ0.9997 because the reserved funds that would have gone to buy the other Ƀ0.0003 were consumed by the trading fee instead. In the usual case, the buyer has sufficient available balance in the counter asset to pay the fee, so no reserved funds are consumed by the fee.

In a partial fill scenario, the quantity remaining in the bid order after the trade may be slightly less than the bid order quantity before the trade minus the traded quantity. This happens whenever the bid order's remaining balance reservation in the counter asset is not sufficient to purchase the remaining quantity of the base asset. In this case, a small amount of the counter asset may be returned from the balance reservation into the buyer's available balance.

Maintaining a Local View of Your Balances

Implementers may wish to maintain a local view of their account balances at all times. Because BalanceChanged notices may be delivered asynchronously at any time, an implementation may be challenged to correlate incoming BalanceChanged notices with other events in the system. The following rules may be helpful:

The above rules imply the following general truths about the delivery order of notices:

An additional truth that is not implied by the above rules, but is nonetheless true, is that an OrderOpened notice always follows the BalanceChanged notice that resulted from taking out the reservation that was required to open the order.

Request Limits

CoinFLEX's application programming interface (API) allows our clients to access and control their accounts or view our market data using custom-written software. To protect the performance of the system, we impose certain limits:

Metric Limit
Open orders 1,000 per user
Authentication attempts 1,000 per hour per user
Order placements* 200 per second per user
Information requests† 10 per 10 seconds per session
Records requests‡ 30 per 1 minute per user
Conversion requests 1 per 5 seconds per user

* "Order placements" also include order cancellations and market order estimates. This is for websockets. Via REST, the limit is 300 per 10 second window.

† "Information requests" include balance inquiries, open order listings, and trade volume inquiries.

‡ "Records requests" pertain to requests for historical records, such as past trades.

REST API

DEMO/STAGE site

https://stgwebapi.coinflex.com/

LIVE site

https://webapi.coinflex.com/

For clients who do not wish to take advantage of CoinFLEX's native WebSocket API, CoinFLEX offers a RESTful API that implements much of the same functionality.

Authentication

Authenticated requests to the REST API use HTTP Basic Authentication, wherein the user-id is the concatenation of user's numeric ID, a slash, and the user's Base64-encoded API key, and the password is the user's password or the Base64 encoding of the user's 28-byte private key that is derived from the user's ID and password.

The public market data methods do not require authentication.

Common Record Types

<balance>

{
    "id": <integer>,
    "available": <integer>,
    "reserved": <integer>
}

<order>

{
    "id": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "time": <integer>
}

<ticker>

{
    "base": <integer>,
    "counter": <integer>,
    "name": <string>,
    "spot_name": <string>
    "last": <integer>|null,
    "bid": <integer>|null,
    "ask": <integer>|null,
    "low": <integer>|null,
    "high": <integer>|null,
    "volume": <integer>,
    "time": <integer>
}

<trade>

{
    "time": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "total": <integer>,
    "base_fee": <integer>,
    "counter_fee": <integer>,
    "order_id": <integer>|null
}

GET /account_value/

Request

GET '/account_value/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[{
    "asset": <integer>,
    "spot_value": <integer>,
    "change_in_spot_value": <integer>,
    "futures_value": <integer>,
    "change_in_futures_value": <integer>,
    "total_value": <integer>,
    "change_in_total_value": <integer>
}, ]
  • asset: (integer) The numeric asset code of an asset in which the user's account value is reported.
  • spot_value: (integer) The total scaled amount held by the user in this spot asset.
  • change_in_spot_value: (integer) The scaled amount of the diff between the current spot_value and the snapshot spot_value.
  • futures_value: (integer) The total scaled amount held by the user in this futures asset.
  • change_in_futures_value: (integer) The scaled amount of the diff between the current futures_value and the snapshot futures_value.
  • total_value: (integer) The total scaled amount of the sum of spot and futures.
  • change_in_total_value: (integer) The scaled amount of the diff between the total_value and the snapshot total_value.

Authentication required.

Returns the user's account value broken down by spot, futures and their value changes since the daily snapshot at 00:00UTC.

GET /assets/

Request

GET '/assets/[?activeOnly=<boolean>]' HTTP/1.1
  • activeOnly: (boolean, optional) If true or omitted this will only return the list of active assets. If false, this will return the entire list of exchange assets, both expired and active assets.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
{
    "id": <integer>,
    "spot_id": <integer>,
    "spot_name": <string>,
    "name": <string>,
    "scale": <integer>
}
  • id: (integer) The numeric identifier of the asset.
  • name: (string) The string name of the asset.
  • spot_id: (integer) The numeric identifier of the underlying spot asset for a futures asset. Only applicable for futures assets.
  • spot_name: (string) The string name of the the underlying spot asset for a futures asset. Only applicable for futures assets.
  • scale: (integer) The scale factor for the asset, applicable to all asset quantities and totals transmitted via the CoinFLEX API.

Authentication not required.

Returns a complete list of CoinFLEX assets.

GET /markets/

Request

GET '/markets/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
{
    "base": <integer>,
    "counter": <integer>,
    "name": <string>,
    "spot_name": <string>,
    "start": <integer>,
    "expires": <integer>,
    "tenor": <string>,
    "tick": <integer>
}
  • base: (integer) The numeric identifier attributed to the base asset of the market.
  • counter: (integer) The numeric identifier attributed to the counter asset of the market.
  • name: (string) The string name of the market consisting of the base asset name and counter asset name.
  • spot_name: (string) The string name of the underlying spot market for a futures market.
  • start: (integer) The UNIX epoch millisecond timestamp of the first trade date of the market. Only applicable for futures markets.
  • expires: (integer) The UNIX epoch millisecond timestamp of the expiry date of the market. Only applicable for futures markets.
  • tenor: (string) The tenor code of the market using industry standard codes.
  • tick: (integer) The scaled tick size of the market.

Authentication not required.

Returns a complete list of CoinFLEX SPOT and Futures markets.

GET /positions/

Request

GET '/positions/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[{
    "asset": <integer>,
    "position": <integer>,
    "through": <integer>
}, ]
  • asset: (integer) The numeric asset code of an asset in which the user's traded net position is reported.
  • position: (integer) The scaled amount of the traded net position in the asset.
  • through: (integer) The micro-timestamp of the last net position change for the identified asset.

Authentication required.

Returns the user's traded net position in all assets.

GET /tickers/

Request

GET '/tickers/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<ticker>, ]

Authentication not required.

Returns the tickers of all available markets.

GET /tickers/<base>:<counter>

Request

GET '/tickers/<base>:<counter>' HTTP/1.1
  • base: (integer) The numeric identifier of the base asset of the market whose ticker is to be returned.
  • counter: (integer) The numeric identifier of the counter asset of the market whose ticker is to be returned.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<ticker>

Errors

If the specified market was not found, then this method returns:

HTTP/1.1 404 Not Found

Authentication not required.

Returns the ticker of the specified market.

GET /depth/<base>:<counter>

Request

GET '/depth/<base>:<counter>'
  • base: (integer) The numeric identifier of the base asset of the market whose depth information is to be returned.
  • counter: (integer) The numeric identifier of the counter asset of the market whose depth information is to be returned.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
{
    "bids": [[<price>, <quantity>], ],
    "asks": [[<price>, <quantity>], ]
}
  • price: (integer) The scaled price level at which market depth is reported.
  • quantity: (integer) The scaled amount of the base asset representing the total open interest at the specified price level.

Errors

If the specified market was not found, then this method returns:

HTTP/1.1 404 Not Found

Authentication not required.

Returns the amount of open interest at each of the top 20 price levels on each side of the specified order book.

A facility to retrieve full order book listings is intentionally omitted from this API, as such facilities have a tendency to be abused through rapid polling. If you require order book listings, please use the WebSocket API, which delivers snapshots followed by incremental updates.

GET /balances/

Request

GET '/balances/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<balance>, ]

Authentication required.

Returns the user's available and reserved balances in all assets.

GET /balances/<id>

Request

GET '/balances/<id>' HTTP/1.1
  • id: (integer) The numeric asset code of the asset in which to report the user's balances.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<balance>

Errors

If the specified asset was not found, then this method returns:

HTTP/1.1 404 Not Found
Content-Length: 0

Authentication required.

Returns the user's available and reserved balances in the specified asset.

GET /orders/

Request

GET '/orders/' HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<order>, ]

Authentication required.

Returns the user's open limit orders.

GET /orders/<id>

Request

GET /orders/<id> HTTP/1.1

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<order>

Errors

If the specified order was not found, then this method returns:

HTTP/1.1 404 Not Found
Content-Length: 0

Authentication required.

Returns the specified limit order of the user.

POST /orders/

Request

POST '/orders/' HTTP/1.1
Content-Type: application/x-www-form-urlencoded
base=<integer>&counter=<integer>[&price=<integer>][&quantity=<integer>|&total=<integer>]
  • base: (integer) The numeric identifier of the base asset of the order.
  • counter: (integer) The numeric identifier of the counter asset of the order.
  • price: (integer, optional) The scaled price at which to offer to trade. If omitted, the submitted order will be executed immediately as a market order.
  • quantity: (integer, conditional) The scaled amount of the base asset to be traded. Negative for a sell order or positive for a buy order. Required if price is supplied or total is omitted.
  • total: (integer, conditional) The scaled amount of the counter asset to be traded. Negative for a sell order or positive for a buy order. Required if quantity is omitted; forbidden if quantity is supplied.

Response

The response for a limit order (price supplied) is:

HTTP/1.1 201 Created
Location: <id>
Content-Location: <id>
Content-Type: application/json; charset=US-ASCII
  • id: (integer) The numeric identifier of the newly placed limit order.
<order>

The response for a market order (price omitted) is:

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
{"remaining":<integer>}
  • remaining: (integer) The scaled amount of the base asset (if quantity was supplied in the request), or the scaled amount of the counter asset (if total was supplied in the request), that could not be traded, either because insufficient liquidity existed on the order book or because the user's balance was exhausted.

Authentication required.

Places a limit order or executes a market order.

quantity price total
supplied supplied omitted
supplied omitted omitted
omitted omitted supplied

DELETE /orders/

Request

DELETE '/orders/' HTTP/1.1

Response

The response contains a snapshot of all of the orders that were canceled.

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<order>, ]

Authentication required.

Cancels all of the user's open limit orders.

DELETE /orders/<id>

Request

DELETE '/orders/<id>' HTTP/1.1
  • id: (integer) The numeric identifier of the order to be canceled.

Response

The response contains a snapshot of the order that was canceled.

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
<order>

Errors

If the specified order was not found, then this method returns:

HTTP/1.1 404 Not Found
Content-Length: 0

Authentication required.

Cancels the specified limit order of the user.

GET /trades/

Request

GET '/trades/[?since=<integer>][&until=<integer>][&sort=asc|desc][&limit=<integer>]' HTTP/1.1
  • since: (integer, optional) A micro-timestamp by which to constrain the set of returned trade records. If supplied, only records of trades that occurred strictly after this time will be returned.
  • until: (integer, optional) A micro-timestamp by which to constrain the set of returned trade records. If supplied, only records of trades that occurred strictly before this time will be returned.
  • sort: (string, optional) The order in which to sort records, either asc for ascending order or desc for descending order. In addition to causing the returned records to be sorted as specified, this also affects which records are selected if not all records in the specified time range are returned. If omitted, the default sort order is ascending if since is supplied, or else descending.
  • limit: (integer, optional) The maximum number of trade records to return. Note, however, that the number of records returned may be less than this limit even if more records exist in the specified time range, but at least one record is guaranteed to be returned if any records exist in the specified time range. If omitted, there is no particular limit imposed by the request.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII
[<trade>, ]

Authentication required.

Returns historical records of the user's past trades.

GET /trades/<time>

Request

GET '/trades/<time>' HTTP/1.1
  • time: (integer) The micro-timestamp of the trade to return.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=US-ASCII

<trade>

Errors

If the specified trade was not found, then this method returns:

HTTP/1.1 404 Not Found
Content-Length: 0

Authentication required.

Returns the historical record of a particular past trade of the user.

Scaling

Amounts

Asset quantities and totals transmitted via the CoinFLEX API are encoded as integers with an implicit scale factor that depends on the particular asset type. All assets have now been set with a scaling factor of 10000 (i.e. 4 decimal places).

Asset Type ID (Hex) ID (Dec) Scale Factor Atomic Unit
XBT 0xF800 63488 10000 Ƀ 0.0001
BCH 0xF808 63496 10000 ɃC 0.0001
ETH 0xF820 63520 10000 Ξ 0.0001
USDC 0xFF02 65282 10000 $C 0.0001
USDT 0xFF03 65283 10000 $T 0.0001
FLEX 0xFF05 65285 10000 FL 0.0001
DOTF 0xFF07 65287 10000 DTF 0.0001
USDTDOT 0xFF08 65288 10000 $TDT 0.0001
DFNF 0xFF0A 65290 10000 DFF 0.0001
USDTDFN 0xFF0B 65291 10000 $TDF 0.0001
LIBF 0xFF0F 65295 10000 LBF 0.0001
USDTLIB 0xFF10 65296 10000 $TLB 0.0001
XBTJAN 0xC800 51200 10000 JanɃ 0.0001
BCHJAN 0xC814 51220 10000 JanɃC 0.0001
ETHJAN 0xC828 51240 10000 JanΞ 0.0001
USDTJAN 0xCAA8 51880 10000 Jan$T 0.0001
USDCJAN 0xCA94 51860 10000 Jan$C 0.0001
XBTFEB 0xC801 51201 10000 FebɃ 0.0001
BCHFEB 0xC815 51221 10000 FebɃC 0.0001
ETHFEB 0xC829 51241 10000 FebΞ 0.0001
USDTFEB 0xCAA9 51881 10000 Feb$T 0.0001
USDCFEB 0xCA95 51861 10000 Feb$C 0.0001
XBTMAR 0xC802 51202 10000 MarɃ 0.0001
BCHMAR 0xC816 51222 10000 MarɃC 0.0001
ETHMAR 0xC82A 51242 10000 MarΞ 0.0001
USDTMAR 0xCAAA 51882 10000 Mar$T 0.0001
USDCMAR 0xCA96 51862 10000 Mar$C 0.0001
XBTAPR 0xC803 51203 10000 AprɃ 0.0001
BCHAPR 0xC817 51223 10000 AprɃC 0.0001
ETHAPR 0xC82B 51243 10000 AprΞ 0.0001
USDTAPR 0xCAAB 51883 10000 Apr$T 0.0001
USDCAPR 0xCA97 51863 10000 Apr$C 0.0001
XBTMAY 0xC804 51204 10000 MayɃ 0.0001
BCHMAY 0xC818 51224 10000 MayɃC 0.0001
ETHMAY 0xC82C 51244 10000 MayΞ 0.0001
USDTMAY 0xCAAC 51884 10000 May$T 0.0001
USDCMAY 0xCA98 51864 10000 May$C 0.0001
XBTJUN 0xC805 51205 10000 JunɃ 0.0001
BCHJUN 0xC819 51225 10000 JunɃC 0.0001
ETHJUN 0xC82D 51245 10000 JunΞ 0.0001
USDTJUN 0xCAAD 51885 10000 Jun$T 0.0001
USDCJUN 0xCA99 51865 10000 Jun$C 0.0001
XBTJUL 0xC806 51206 10000 JulɃ 0.0001
BCHJUL 0xC81A 51226 10000 JulɃC 0.0001
ETHJUL 0xC82E 51246 10000 JulΞ 0.0001
USDTJUL 0xCAAE 51886 10000 Jul$T 0.0001
USDCJUL 0xCA9A 51866 10000 Jul$C 0.0001
XBTAUG 0xC807 51207 10000 AugɃ 0.0001
BCHAUG 0xC81B 51227 10000 AugɃC 0.0001
ETHAUG 0xC82F 51247 10000 AugΞ 0.0001
USDTAUG 0xCAAF 51887 10000 Aug$T 0.0001
USDCAUG 0xCA9B 51867 10000 Aug$C 0.0001
XBTSEP 0xC808 51208 10000 SepɃ 0.0001
BCHSEP 0xC81C 51228 10000 SepɃC 0.0001
ETHSEP 0xC830 51248 10000 SepΞ 0.0001
USDTSEP 0xCAB0 51888 10000 Sep$T 0.0001
USDCSEP 0xCA9C 51868 10000 Sep$C 0.0001
XBTOCT 0xC809 51209 10000 OctɃ 0.0001
BCHOCT 0xC81D 51229 10000 OctɃC 0.0001
ETHOCT 0xC831 51249 10000 OctΞ 0.0001
USDTOCT 0xCAB1 51889 10000 Oct$T 0.0001
USDCOCT 0xCA9D 51869 10000 Oct$C 0.0001
XBTNOV 0xC80A 51210 10000 NovɃ 0.0001
BCHNOV 0xC81E 51230 10000 NovɃC 0.0001
ETHNOV 0xC832 51250 10000 NovΞ 0.0001
USDTNOV 0xCAB2 51890 10000 Nov$T 0.0001
USDCNOV 0xCA9E 51870 10000 Nov$C 0.0001
XBTDEC 0xC80B 51211 10000 DecɃ 0.0001
BCHDEC 0xC81F 51231 10000 DecɃC 0.0001
ETHDEC 0xC833 51251 10000 DecΞ 0.0001
USDTDEC 0xCAB3 51891 10000 Dec$T 0.0001
USDCDEC 0xCA9F 51871 10000 Dec$C 0.0001
XBTJUN20 0x2715 10005 10000 JunɃ20 0.0001
BCHJUN20 0x2721 10017 10000 JunɃC20 0.0001
ETHJUN20 0x272D 10029 10000 JunΞ20 0.0001
USDTJUN20 0x2745 10053 10000 Jun$T20 0.0001
USDCJUN20 0x2739 10041 10000 Jun$C20 0.0001

Examples

Logical Amount Integer Encoding
Ƀ12.3456 123456
$T1.654 16540
Ƀ1.5 15000
$C20 200000

Prices

Prices transmitted via the CoinFLEX API are encoded as integers with an implicit scale factor that depends on the particular asset pair.

Asset Pair Scale Factor
XBT:USDT 10000
BCH:USDT 10000
ETH:USDT 10000
USDC:USDT 10000
FLEX:USDT 10000
DOTF:USDTDOT 10000
DFNF:USDTDFN 10000
LIBF:USDTLIB 10000
XBTJAN:USDTJAN 10000
BCHJAN:USDTJAN 10000
ETHJAN:USDTJAN 10000
USDCJAN:USDTJAN 10000
XBTFEB:USDTFEB 10000
BCHFEB:USDTFEB 10000
ETHFEB:USDTFEB 10000
USDCFEB:USDTFEB 10000
XBTMAR:USDTMAR 10000
BCHMAR:USDTMAR 10000
ETHMAR:USDTMAR 10000
USDCMAR:USDTMAR 10000
XBTAPR:USDTAPR 10000
BCHAPR:USDTAPR 10000
ETHAPR:USDTAPR 10000
USDCAPR:USDTAPR 10000
XBTMAY:USDTMAY 10000
BCHMAY:USDTMAY 10000
ETHMAY:USDTMAY 10000
USDCMAY:USDTMAY 10000
XBTJUN:USDTJUN 10000
BCHJUN:USDTJUN 10000
ETHJUN:USDTJUN 10000
USDCJUN:USDTJUN 10000
XBTJUL:USDTJUL 10000
BCHJUL:USDTJUL 10000
ETHJUL:USDTJUL 10000
USDCJUL:USDTJUL 10000
XBTAUG:USDTAUG 10000
BCHAUG:USDTAUG 10000
ETHAUG:USDTAUG 10000
USDCAUG:USDTAUG 10000
XBTSEP:USDTSEP 10000
BCHSEP:USDTSEP 10000
ETHSEP:USDTSEP 10000
USDCSEP:USDTSEP 10000
XBTOCT:USDTOCT 10000
BCHOCT:USDTOCT 10000
ETHOCT:USDTOCT 10000
USDCOCT:USDTOCT 10000
XBTNOV:USDTNOV 10000
BCHNOV:USDTNOV 10000
ETHNOV:USDTNOV 10000
USDCNOV:USDTNOV 10000
XBTDEC:USDTDEC 10000
BCHDEC:USDTDEC 10000
ETHDEC:USDTDEC 10000
USDCDEC:USDTDEC 10000
XBTJUN20:USDTJUN20 10000
BCHJUN20:USDTJUN20 10000
ETHJUN20:USDTJUN20 10000
USDCJUN20:USDTJUN20 10000

Examples

Logical Price Integer Encoding
$T4443/XBT 44430000
$T1.011/USDC 10110

Tick Size

The Tick Size applied per asset pair as follows.

Note that bid prices are always rounded down and ask prices are always rounded up so as to ensure that a user never receives a less favourable price on their order than they requested.

Asset Pair Tick Size
XBT:USDT 1
BCH:USDT 0.25
ETH:USDT 0.1
USDC:USDT 0.001
FLEX:USDT 0.005
DOTF:USDTDOT 2
DFNF:USDTDFN 0.05
LIBF:USDTLIB 0.01
XBTJAN:USDTJAN 0.5
BCHJAN:USDTJAN 0.25
ETHJAN:USDTJAN 0.1
USDCJAN:USDTJAN 0.001
XBTFEB:USDTFEB 0.5
BCHFEB:USDTFEB 0.25
ETHFEB:USDTFEB 0.1
USDCFEB:USDTFEB 0.001
XBTMAR:USDTMAR 0.5
BCHMAR:USDTMAR 0.25
ETHMAR:USDTMAR 0.1
USDCMAR:USDTMAR 0.001
XBTAPR:USDTAPR 0.5
BCHAPR:USDTAPR 0.25
ETHAPR:USDTAPR 0.1
USDCAPR:USDTAPR 0.001
XBTMAY:USDTMAY 0.5
BCHMAY:USDTMAY 0.25
ETHMAY:USDTMAY 0.1
USDCMAY:USDTMAY 0.001
XBTJUN:USDTJUN 0.5
BCHJUN:USDTJUN 0.25
ETHJUN:USDTJUN 0.1
USDCJUN:USDTJUN 0.001
XBTJUL:USDTJUL 0.5
BCHJUL:USDTJUL 0.25
ETHJUL:USDTJUL 0.1
USDCJUL:USDTJUL 0.001
XBTAUG:USDTAUG 0.5
BCHAUG:USDTAUG 0.25
ETHAUG:USDTAUG 0.1
USDCAUG:USDTAUG 0.001
XBTSEP:USDTSEP 0.5
BCHSEP:USDTSEP 0.25
ETHSEP:USDTSEP 0.1
USDCSEP:USDTSEP 0.001
XBTOCT:USDTOCT 0.5
BCHOCT:USDTOCT 0.25
ETHOCT:USDTOCT 0.1
USDCOCT:USDTOCT 0.001
XBTNOV:USDTNOV 0.5
BCHNOV:USDTNOV 0.25
ETHNOV:USDTNOV 0.1
USDCNOV:USDTNOV 0.001
XBTDEC:USDTDEC 0.5
BCHDEC:USDTDEC 0.25
ETHDEC:USDTDEC 0.1
USDCDEC:USDTDEC 0.001
XBTJUN20:USDTJUN20 0.5
BCHJUN20:USDTJUN20 0.25
ETHJUN20:USDTJUN20 0.1
USDCJUN20:USDTJUN20 0.0001

Examples

Order Placed Order Opened
Sell 0.0001 XBT @ 4000.0001 USDT Sell 0.0001 XBT @ 4001 USDT
Qty:-1, Price:40000001 Qty:-1, Price:40010000
Buy 0.001 ETH @ 160.19 USDT Buy 0.001 ETH @ 160.1 USDT
Qty:10, Price:1601900 Qty:10, Price:1601000
Buy 1.5 FLEX @ 10.206 USDT Buy 1.5 FLEX @ 10.205 USDT
Qty:15000, Price:102060 Qty:15000, Price:102050
Buy 3.2 DOTF @ 1003.3 USDTDOT Buy 3.2 DOTF @ 1002 USDTDOT
Qty:32000, Price:10033000 Qty:32000, Price:10020000
Sell 1.0001 BCH @ 268.76 USDT Sell 1.0001 BCH @ 269.00 USDT
Qty:10001, Price: 2687600 Qty:10001, Price:2690000
Buy 1.1234 XBT @ 3999.9999 USDT Buy 1.1234 XBT @ 3999 USDT
Qty:11234, Price:39999999 Qty:11234, Price:39990000
Sell 1.0001 USDC @ 1.0001 USDT Sell 1.0001 USDC @ 1.001 USDT
Qty:-10001, Price:10001 Qty:-10001, Price:10010
Buy 1.0019 USDC @ 1.1299 USDT Buy 1.0019 USDC @ 1.129 USDT
Qty:10019, Price:11299 Qty:10019, Price:11290

WebSocket API Specification

DEMO/STAGE site

wss://stgapi.coinflex.com/v1

LIVE site

wss://api.coinflex.com/v1

CoinFLEX's application programming interface (API) provides our clients programmatic access to control aspects of their accounts and to place orders on the CoinFLEX trading platform. The API is accessible via WebSocket connection to the URIs listed above. Commands, replies, and notifications traverse the WebSocket in text frames with JSON-formatted payloads.

WebSocket connections to the API will time out after 60 seconds if no traffic passes in either direction. To prevent timeouts, send a Ping frame approximately every 45 seconds while the connection is otherwise idle. You do not need to send Ping frames if you are otherwise sending or receiving data frames on the socket.

To protect the performance of the system, CoinFLEX imposes certain limits on the rates at which you may issue commands to the API. Please see Request Limits.

All quantities and prices are transmitted and received as integers with implicit scale factors. For scale information, please see Scaling.

CoinFLEX has published client libraries for several popular languages to aid you in implementing your client application.

Wikipedia of "if and only if"

Message Flow

The WebSocket connection can be seen as logically carrying two independent communications channels: a control channel and an asynchronous notifications channel. Messages within each channel are ordered, but the two channels are not strictly synchronized with respect to each other. The distinction between the channels is implicit in the fields contained in the messages they carry; there are no explicit channel markers.

The control channel carries a series of command/reply pairs, where each command specifies a method and each reply specifies an error_code. Commands always flow from client to server, and replies always flow from server to client. A client may pipeline commands - that is, the client need not wait to receive the reply for one command before transmitting another command. However, because the server may reorder replies to the client with respect to the order in which the client submitted the commands that elicited those replies, a pipelining client should specify a unique tag in each command, to which it should correlate the matching tag in the corresponding reply. The server executes all commands that alter the state of the system in the order in which it receives them, but it may reply to information requests ahead of commands that alter state. For example, pipelining an EstimateMarketOrder command after a PlaceOrder command may mean that the returned estimate does not reflect any order book changes that result from the placed order.

The asynchronous notifications channel carries a series of notices, where each notice specifies a notice field. These notices may be delivered to the client at any time, and the timing of their delivery may not tightly correlate with command/reply messages in the control channel. For example, the OrderOpened notice that results from a PlaceOrder command may be delivered either before or after the command reply. However, notices are guaranteed to be delivered to the client in the same order as their respective events occurred in the trade engine. For example, an OrdersMatched notice that references a particular order will never be delivered after an OrderClosed notice that references the same order.

Contents

Currently, the WebSocket API supports the following:

Authenticate

Request

{
    "tag": <integer>,
    "method": "Authenticate",
    "user_id": <integer>,
    "cookie": <string>,
    "nonce": <string>,
    "signature": [
        <string>,
        <string>
    ]
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • user_id is the numeric identifier of the user who is attempting to authenticate.
  • cookie is the base64-encoded login cookie which is unique to the specified user.
  • nonce is a base64-encoded string of 16 bytes that have been randomly selected by the client.
  • signature is an array containing two base64-encoded strings, which encode the r and s components of the signature. Please see CoinFLEX Authentication Process for details of the authentication scheme.

Success Reply

{
    "tag": <integer>,
    "error_code": 0
}
  • tag is present iff tag was given and non-zero in the request.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Authenticates as a user by signing a challenge.

Authorization: None required.

error_code error_msg
1 "There is no such user."
6 "You are making authentication attempts too rapidly."
7 "You sent an incorrect login cookie."
7 "You sent an incorrect signature. This probably means you used a wrong passphrase."
8 (varies)

GetBalances

Request

{
    "tag": <integer>,
    "method": "GetBalances"
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "balances": [
        {
            "asset": <integer>,
            "balance": <integer>,
            "reserved_balance": <integer>,
            "total_balance": <integer>
        },
        
    ]
}
  • tag is present iff tag was given and non-zero in the request.
  • asset is an asset code for which a balance is given.
  • balance is the user's scaled available balance in the specified asset.
  • reserved_balance is the user's scaled reserved balance in the specified asset.
  • total_balance is the user's scaled total balance in the specified asset.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Retrieves the available balances of the authenticated user.

Authorization: Any authenticated user may invoke this command.

error_code error_msg
6 "You are making information requests too rapidly."
7 "You are not authenticated."
8 (varies)

GetOrders

Request

{
    "tag": <integer>,
    "method": "GetOrders"
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "orders": [
        {
            "id": <integer>,
            "tonce": <integer>,
            "base": <integer>,
            "counter": <integer>,
            "quantity": <integer>,
            "price": <integer>,
            "time": <integer>
        },
        
    ]
}
  • tag is present iff tag was given and non-zero in the request.
  • id is the numeric identifier of an order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce.
  • base and counter are the asset codes of the base and counter assets of the order.
  • quantity is the scaled amount of the base asset that is to be traded. It is negative for a sell order and positive for a buy order.
  • price is the scaled price at which the order offers to trade.
  • time is the micro-timestamp at which the order was opened.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Retrieves the open orders of the authenticated user.

Authorization: Any authenticated user may invoke this command.

error_code error_msg
6 "You are making information requests too rapidly."
7 "You are not authenticated."
8 (varies)

EstimateMarketOrder

Request

{
    "tag": <integer>,
    "method": "EstimateMarketOrder",
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "total": <integer>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • base and counter are the asset codes of the base and counter assets of the order.
  • quantity is the scaled amount of base asset that is to be traded. It is negative for a sell order and positive for a buy order. This field must be omitted if total is supplied.
  • total is the scaled amount of the counter asset that is to be traded. It is negative for a sell order and positive for a buy order. This field must be supplied if quantity is omitted.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "quantity": <integer>,
    "total": <integer>
}
  • tag is present iff tag was given and non-zero in the request.
  • quantity is the scaled amount of the base asset that would have been traded if the market order really had been executed. It is always positive.
  • total is the scaled amount of the counter asset that would have been traded if the market order really had been executed. It is always positive.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Simulates the execution of a market order and returns the quantity and total that would have been traded. This estimation does not take into account trading fees.

Authorization: None required.

error_code error_msg
1 "You specified an invalid asset pair."
6 "You are sending orders too rapidly."
8 "Quantity must not be zero."
8 "Total must not be zero."
8 "You must specify either quantity or total for a market order."
8 (varies)

PlaceOrder

Request

{
    "tag": <integer>,
    "method": "PlaceOrder",
    "tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "total": <integer>,
    "persist": <boolean>|"fill_or_kill",
    "post_only": <boolean>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • tonce is optional. If given, it must be non-zero and unique to any tonce currently active with any live open orders. The purpose of the tonce is to allow the user to resubmit a PlaceOrder command (e.g., after a connection failure) without risk of creating a duplicate order or to request cancellation of a just-placed order without needing to wait for the PlaceOrder reply containing the server-assigned order identifier.
  • base and counter are the asset codes of the base and counter assets of the order.
  • quantity is the scaled amount of base asset that is to be traded. It is negative for a sell order and positive for a buy order. This field must be supplied if price is supplied and must be omitted if total is supplied.
  • price is the scaled price at which the order offers to trade. It is optional; if omitted, the order will be executed as a market order.
  • total is the scaled amount of the counter asset that is to be traded. It is negative for a sell order and positive for a buy order. This field must be omitted if price is supplied and must be supplied if quantity is omitted.
  • persist is optional. If true or omitted, the order will remain on the order book until canceled or fulfilled. If false, the order will be canceled automatically when the client disconnects. If "fill_or_kill", the order will be canceled automatically after any immediate matches. This flag has no effect on market orders.
  • post_only is optional. If true the limit order will never take liquidity from the order book and can only become a non-aggressing maker order. If the limit price would result in an immediate match then the order will not be opened and hence rejected.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "id": <integer>,
    "time": <integer>,
    "remaining": <integer>
}
  • tag is present iff tag was given and non-zero in the request.
  • id is the numeric identifier assigned to the opened order. It is present only if price was supplied in the request.
  • time is the micro-timestamp at which the order was opened. It is present only if price was supplied in the request.
  • remaining is the scaled amount of the base asset (if quantity was supplied in the request), or the scaled amount of the counter asset (if total was supplied in the request), that could not be traded, either because insufficient liquidity existed on the order book or because the user's balance was exhausted. It is present only if price was omitted from the request.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}

tag is present iff tag was given and non-zero in the request.

Places an order to execute a specified trade. This command is used to place both limit orders and market orders.

Authorization: Any authenticated user may invoke this command.

quantity price total
supplied supplied omitted
supplied omitted omitted
omitted omitted supplied
error_code error_msg
1 "You specified an invalid asset pair."
3 "Tonce is out of sequence."
4 "You have insufficient funds."
5 "You have too many outstanding orders."
6 "You are sending orders too rapidly."
7 "You are not authenticated."
8 "Tonce must not be zero."
8 "Price must not be zero."
8 "Quantity must not be zero."
8 "Order total would overflow."
8 "You must specify either quantity or total for a market order."
8 (varies)
9 "Post-only order with these parameters would result in an immediate match."

ModifyOrder

Request

{
    "tag": <integer>,
    "method": "ModifyOrder",
    "id": <integer>,
    "tonce": <integer>,
    "quantity_delta": <integer>,
    "price": <integer>,
    "post_only": <boolean>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • id is the numeric identifier of the order to be modified. This field must be omitted if tonce is supplied.
  • tonce is the tonce given in the PlaceOrder command that opened the order to be modified. This field must be supplied if id is omitted.
  • quantity_delta is the scaled amount by which to adjust the quantity of the open order. It is negative to increase the quantity of a sell order or to decrease the quantity of a buy order. It is positive to increase the quantity of a buy order or to decrease the quantity of a sell order. It is optional; if omitted, the order's quantity will not be adjusted. If the requested adjustment would cause the order's quantity to reach or cross zero, then this command has the effect of canceling the order. If the order quantity is enlarged, then the order is moved to the end of the queue at its price level in the order book; otherwise, the order remains at its present position in the queue.
  • price is the new scaled price at which the order offers to trade. It is optional; if omitted, the order's price will not be modified.
  • post_only is optional. If true the modified limit order will never take liquidity from the order book and can only become a non-aggressing maker order. If the limit price would result in an immediate match then the order will not be modified and the order remains unchanged.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "id": <integer>,
    "tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "time": <integer>
}
  • tag is present iff tag was given and non-zero in the request.
  • id is the numeric identifier of the modified order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce.
  • base and counter are the asset codes of the base and counter assets of the modified order.
  • quantity is the new scaled amount of the base asset that remains to be traded in the order after the modification. It is negative for a sell order and positive for a buy order.
  • price is the new scaled price at which the modified order offers to trade.
  • time is the micro-timestamp at which the order was modified.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Modifies an open limit order. Only the quantity and price may be modified.

Authorization: Any authenticated user may invoke this command.

error_code error_msg
1 "The specified order was not found."
4 "You have insufficient funds."
6 "You are sending orders too rapidly."
7 "You are not authenticated."
8 "You must specify either order ID or tonce."
8 "Tonce must not be zero."
8 "You must specify quantity delta and/or price."
8 "Quantity delta must not be zero."
8 "Price must not be zero."
8 (varies)
9 "Post-only order with these parameters would result in an immediate match."

CancelOrder

Request

{
    "tag": <integer>,
    "method": "CancelOrder",
    "id": <integer>,
    "tonce": <integer>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • id is the numeric identifier of the order to be canceled. This field must be omitted if tonce is supplied.
  • tonce is the tonce given in the PlaceOrder command that opened the order to be canceled. This field must be supplied if id is omitted.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "id": <integer>,
    "tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "time": <integer>
}
  • tag is present iff tag was given and non-zero in the request.
  • id is the numeric identifier of the canceled order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce.
  • base and counter are the asset codes of the base and counter assets of the canceled order.
  • quantity is the scaled amount of the base asset that was remaining to be traded when the order was canceled. It is negative for a sell order and positive for a buy order.
  • price is the scaled price at which the canceled order had offered to trade.
  • time is the micro-timestamp at which the order was opened.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Cancels an open order belonging to the authenticated user.

Authorization: Any authenticated user may invoke this command.

error_code error_msg
1 "The specified order was not found."
6 "You are sending orders too rapidly."
7 "You are not authenticated."
8 "You must specify either order ID or tonce."
8 (varies)

CancelAllOrders

Request

{
    "tag": <integer>,
    "method": "CancelAllOrders"
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "orders": [
        {
            "id": <integer>,
            "tonce": <integer>,
            "base": <integer>,
            "counter": <integer>,
            "quantity": <integer>,
            "price": <integer>,
            "time": <integer>
        },
        ...
    ]
}
  • tag is present iff tag was given and non-zero in the request.
  • id is the numeric identifier of a canceled order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce.
  • base and counter are the asset codes of the base and counter assets of the canceled order.
  • quantity is the scaled amount of the base asset that was remaining to be traded when the order was canceled. It is negative for a sell order and positive for a buy order.
  • price is the scaled price at which the canceled order had offered to trade.
  • time is the micro-timestamp at which the order was opened.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Cancels all open orders belonging to the authenticated user. Also resets the user's tonce counter to zero.

Authorization: Any authenticated user may invoke this command.

error_code error_msg
6 "You are sending orders too rapidly."
7 "You are not authenticated."
8 (varies)

GetTradeVolume

Request

{
    "tag": <integer>,
    "method": "GetTradeVolume",
    "asset": <integer>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • asset is the asset code of the asset whose trade volume is to be retrieved.

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "volume": <integer>
}
  • tag is present iff tag was given and non-zero in the request.
  • volume is the user's 30-day trailing scaled trade volume in the specified asset.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Retrieves the 30-day trailing trade volume for the authenticated user.

Authorization: Any authenticated user may invoke this command.

error_code error_msg
6 "You are making information requests too rapidly."
7 "You are not authenticated."
8 (varies)

WatchOrders

Request

{
    "tag": <integer>,
    "method": "WatchOrders",
    "base": <integer>,
    "counter": <integer>,
    "watch": <boolean>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • base and counter are the asset codes of the base and counter assets of the order book whose orders feed the client is to be subscribed to or unsubscribed from.
  • watch is a flag indicating whether to subscribe (true) or unsubscribe (false).

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "orders": [
        {
            "id": <integer>,
            "quantity": <integer>,
            "price": <integer>,
            "time": <integer>
        },
        ...
    ]
}
  • tag is present iff tag was given and non-zero in the request.
  • orders is present iff watch was true in the request.
  • id is the numeric identifier of an order.
  • quantity is the scaled amount of the base asset that is to be traded. It is negative for a sell order and positive for a buy order.
  • price is the scaled price at which the order offers to trade.
  • time is the micro-timestamp at which the order was opened.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Subscribes/unsubscribes the requesting client to/from the orders feed of a specified order book. When subscribing, up to 1000 bids and 1000 asks from the top of the book are returned in the response.

Authorization: None required.

error_code error_msg
1 "You specified an invalid asset pair."
1 "You are not watching the order book for the specified asset pair."
2 "You are already watching the order book for the specified asset pair."
8 (varies)

WatchTicker

Request

{
    "tag": <integer>,
    "method": "WatchTicker",
    "base": <integer>,
    "counter": <integer>,
    "watch": <boolean>
}
  • tag is optional. Iff given and non-zero, it will be echoed in the reply.
  • base and counter are the asset codes of the base and counter assets of the order book whose ticker feed the client is to be subscribed to or unsubscribed from.
  • watch is a flag indicating whether to subscribe (true) or unsubscribe (false).

Success Reply

{
    "tag": <integer>,
    "error_code": 0,
    "last": <integer>,
    "bid": <integer>,
    "ask": <integer>,
    "low": <integer>,
    "high": <integer>,
    "volume": <integer>
}
  • tag is present iff tag was given and non-zero in the request.
  • last, bid, ask, low, high, and volume are present iff watch was true in the request.
  • last is the scaled price at which the last trade in the specified order book executed, or null if no such trade has yet executed.
  • bid and ask are the highest scaled bid price and lowest scaled ask price in the specified order book, respectively, or null if there is no such order.
  • low and high are the lowest and highest scaled prices at which any trade executed in the specified order book in the trailing 24-hour period, or null if no such trade executed in that period.
  • volume is the scaled quantity of the base asset that has been traded in the specified order book in the trailing 24-hour period.

Error Reply

{
    "tag": <integer>,
    "error_code": <integer>,
    "error_msg": <string>
}
  • tag is present iff tag was given and non-zero in the request.

Subscribes/unsubscribes the requesting client to/from the ticker feed of a specified order book. When subscribing, the current ticker values of the book are returned in the response.

Authorization: None required.

error_code error_msg
1 "You specified an invalid asset pair."
1 "You are not watching the ticker for the specified asset pair."
2 "You are already watching the ticker for the specified asset pair."
8 (varies)

BalanceChanged

Notification

{
    "notice": "BalanceChanged",
    "asset": <integer>,
    "balance": <integer>
}
  • asset is the asset code of the balance that changed.
  • balance is the user's new scaled available balance in the specified asset.

One of the authenticated user's balances has changed.

Recipients: Authenticated users receive notice of changes to their own balances.

OrderOpened

Notification

{
    "notice": "OrderOpened",
    "id": <integer>,
    "tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "time": <integer>
}
  • id is the numeric identifier of the order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce. It is present only if the recipient of the notification is the owner of the order.
  • base and counter are the asset codes of the base and counter assets of the order.
  • quantity is the scaled amount of the base asset that is to be traded. It is negative for a sell order and positive for a buy order.
  • price is the scaled price at which the order offers to trade.
  • time is the micro-timestamp at which the order was opened.

A new order has been opened.

Recipients: Authenticated users receive notice of their own orders. Users that have subscribed to the orders feed of an order book receive notice of all orders in that book.

OrderModified

Notification

{
    "notice": "OrderModified",
    "id": <integer>,
    "tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "time": <integer>
}
  • id is the numeric identifier of the order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce. It is present only if the recipient of the notification is the owner of the order.
  • base and counter are the asset codes of the base and counter assets of the order.
  • quantity is the new scaled amount of the base asset that is to be traded. It is negative for a sell order and positive for a buy order.
  • price is the new scaled price at which the order offers to trade.
  • time is the micro-timestamp at which the order was modified.

An order has been modified.

Recipients: Authenticated users receive notice of their own orders. Users that have subscribed to the orders feed of an order book receive notice of all orders in that book.

OrdersMatched

Notification

{
    "notice": "OrdersMatched",
    "bid": <integer>,
    "bid_tonce": <integer>,
    "ask": <integer>,
    "ask_tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "taker_side": <string>,
    "taker": <boolean>,
    "price": <integer>,
    "total": <integer>,
    "bid_rem": <integer>,
    "ask_rem": <integer>,
    "time": <integer>,
    "bid_base_fee": <integer>,
    "bid_counter_fee": <integer>,
    "ask_base_fee": <integer>,
    "ask_counter_fee": <integer>
}
  • bid and ask are the numeric identifiers of the bid and ask orders, respectively, that matched. Either (but not both) may be omitted if the corresponding side of the trade was a market order.
  • bid_tonce and ask_tonce are the tonces given in the PlaceOrder commands that opened the bid and ask orders, respectively, or null if the respective command did not specify a tonce. These fields are present only if the recipient of the notification is the buyer or seller, respectively.
  • base and counter are the asset codes of the base and counter assets of the orders.
  • quantity is the scaled amount of the base asset that was traded. It is always positive.
  • taker_side is the string identifier showing bid or ask to indentify which side of the matched trade was the taker/aggressor.
  • taker is the boolean identifier showing True for a taker trade or False for maker trade. This field is currently only visibile for the private authenticated OrdersMatched message.
  • price is the scaled price at which the trade executed.
  • total is the scaled amount of the counter asset that was traded. It is always positive.
  • bid_rem and ask_rem are the scaled quantities remaining in the bid and ask orders, respectively, after the trade. Either (but not both) may be omitted if the corresponding side of the trade was a market order.
  • time is the micro-timestamp at which the trade executed.
  • bid_base_fee, bid_counter_fee, ask_base_fee, and ask_counter_fee are the scaled fees levied on the buyer and seller, respectively, in the base and counter assets, respectively. These fields are present only if the recipient of the notification is the buyer or seller, respectively.

Two orders matched, resulting in a trade.

Recipients: Authenticated users receive notice of their own orders. Users that have subscribed to the orders feed of an order book receive notice of all orders in that book.

OrderClosed

Notification

{
    "notice": "OrderClosed",
    "id": <integer>,
    "tonce": <integer>,
    "base": <integer>,
    "counter": <integer>,
    "quantity": <integer>,
    "price": <integer>,
    "time_closed": <integer>
}
  • id is the numeric identifier of the order.
  • tonce is the tonce given in the PlaceOrder command that opened the order, or null if that command did not specify a tonce. It is present only if the recipient of the notification is the owner of the order.
  • base and counter are the asset codes of the base and counter assets of the order.
  • quantity is the scaled amount of the base asset that was remaining to be traded when the order was closed. It is negative for a sell order and positive for a buy order. It is zero if the order was completely fulfilled.
  • price is the scaled price at which the order had offered to trade.
  • time_closed is the microsecond timestamp of when the order was closed.

An order was removed from the order book.

Recipients: Authenticated users receive notice of their own orders. Users that have subscribed to the orders feed of an order book receive notice of all orders in that book.

TickerChanged

Notification

{
    "notice": "TickerChanged",
    "base": <integer>,
    "counter": <integer>,
    "last": <integer>,
    "bid": <integer>,
    "ask": <integer>,
    "low": <integer>,
    "high": <integer>,
    "volume": <integer>
}
  • base and counter are the asset codes of the base and counter assets of the order book whose ticker changed.
  • last is the scaled price at which the last trade in the specified order book executed, or null if no such trade has yet executed. It is present only if it has changed since the previous notice in which it was present.
  • bid and ask are the highest scaled bid price and lowest scaled ask price in the specified order book, respectively, or null if there is no such order. Each is present only if it has changed since the previous notice in which it was present.
  • low and high are the lowest and highest scaled prices at which any trade executed in the specified order book in the trailing 24-hour period, or null if no such trade executed in that period. Each is present only if it has changed since the previous notice in which it was present.
  • volume is the scaled quantity of the base asset that has been traded in the specified order book in the trailing 24-hour period. It is present only if it has changed since the previous notice in which it was present.

The ticker for an order book changed.

Recipients: Users that have subscribed to the ticker feed of an order book receive notice of all ticker changes in that book.

TradeVolumeChanged

Notification

{
    "notice": "TradeVolumeChanged",
    "asset": <integer>,
    "volume": <integer>
}
  • asset is the asset code of the asset whose 30-day trailing trade volume changed.
  • volume is the user's updated 30-day trailing trade volume in the specified asset.

A 30-day trailing trade volume for the authenticated user changed.

Recipients: Authenticated users receive notice of changes to their own trade volumes.