Documentation
Log In
Documentation

🚧

ConnectionClosed

We are using external proxy service called CloudFlare. To deliver best and reliable services our provider is changing routing policy few times per day. This might cause instantaneous lost of connection on WebSocket channel. We recommend to consider and solve such situations at the beginning of developing own application.

📘

Secured Websocket URI:

wss://api.zondacrypto.exchange/websocket/

To perform a public subscription, you need to send: action subscribe-public, module and path to endpoint. Required format is JSON. This type of connection do not require any additional parameters.
To cancell subscription - just send action unsubscribe with previous module and path. This will close all active channels.

{
 "action": "subscribe-public",
 "module": "trading",
 "path": "ticker"
}
{
 "action": "unsubscribe",
 "module": "trading",
 "path": "ticker"
}

Response details

The first response will always return confirmation of subscription for specific channel. Each subsequent one is called push which contains target data.

{
  "action": "push",
  "topic": "trading/orderbook/btc-pln",
  "message": {
    "changes": [
      {
        "marketCode": "BTC-PLN",
        "entryType": "Buy",
        "rate": "27601.35",
        "action": "update",
        "state": {
          "ra": "27601.35",
          "ca": "0.46205049",
          "sa": "0.46205049",
          "pa": "0.46205049",
          "co": 4
        }
      }
    ],
    "timestamp": "1576847016253"
  },
  "timestamp": "1576847016253",
  "seqNo": 40018807
}
{
  "action": "subscribe-public-confirm",
  "module": "trading",
  "path": "orderbook/btc-pln"
}

Parameters action, topic, message, timestamp and seqNo are returned for each channel.

📘

Implementation example of the seqNo

To keep the order of receiving pushes and data consistency should be implemented the following mechanism:

  • Connect to the channel and save every push on temporary list.
  • Get the current snapshot of previous connected channel and save whole response to the target structure.
  • Update structure with temporary list, starting with 1 value greater of seqNo than downloaded snapshot.
  • For each update - check if seqNo is 1 more greater than previous message and clear temporary list after each successful update on structure.
  • If temporary list will not be clearing it will be the fault of lost push and need to repeat the whole process from the beginning.

Values of the seqNo are individual for each limits: 10 / 50 / 100 and are consistent for snapshot and websocket channel.

KeyTypeDescription
actionStringType of action: push / subscribe-public-error / subscribe-private-error / subscribe-private-confirm / subscribe-public-confirm / proxy-response / pong / json-error.
topicStringFull path of current channel.
messageObjectPush message with changes.
Different for each of channel.
timestampUnix TimestampTime of update on server side.
seqNointegerSequence number. Helps keep the order.

Snapshot

All of the presented public endpoints allows to catch a snapshot.
It is performed by action proxy to REST API endpoint. All of the REST API endpoints of type GET could be snapshotted. In this type of request you need to sent additional parameter: requestID, which is disposable UUID of the request.

{
	"requestId": "78539fe0-e9b0-4e4e-8c86-70b36aa93d4f",
	"action": "proxy",
	"module": "trading",
	"path": "ticker/eth-pln"
}
{
  "action": "proxy-response",
  "requestId": "78539fe0-e9b0-4e4e-8c86-70b36aa93d4f",
  "statusCode": 200,
  "body": {
    "status": "Ok",
    "ticker": {
      "market": {
        "code": "ETH-PLN",
        "first": {
          "currency": "ETH",
          "minOffer": "0.00045",
          "scale": 8
        },
        "second": {
          "currency": "PLN",
          "minOffer": "5",
          "scale": 2
        }
      },
      "time": "1576846031093",
      "highestBid": "491.44",
      "lowestAsk": "495",
      "rate": "495",
      "previousRate": "499.42"
    }
  }
}