Richamster websocket API

Websockets API allows you to receive updates in real time. If you’re looking for the REST API check this URL
To receive data you have to connect websockets endpoint. For example in javascript:

and after that send JSON with corresponding data

 "channel": "trading", "pair": "KRB/UAH"}))  

That’s all. Now you’re subscribed to receive all updates over trading channel for currency pair KRB/UAH

Responses

After each subscription message you send you will receive JSON message with error or success data.

Examples:

{  
  "type": "success",  
  "message": "You are connected to channel \"trading\" and currency pair \"KRB/UAH\""  
}  
{  
  "type": "error",  
  "message": "Subscription channel is invalid."  
}  

Channels

Available channels are:

  1. ticker
  2. order_book
  3. trading
  4. user_orders

ticker

Over this channel you’ll receive currency tickers with data actual for the last 24 hours starting from now.

Example of message to subscribe:

{  
  "channel": "trading",  
  "pair": "KRB/UAH"  
}  

Receiving messages:

{  
  "pair":  "KRB/UAH",  
  "last": 1.234,  
  "first": 0.234,  
  "high": 1.78,  
  "low": 0.5,  
  "volume": 10.234236  
}  
  

JSON schema

{  
  "$schema": "http://json-schema.org/draft-04/schema#",  
  
  "type": "object",  
  "properties": {  
  "pair": {  
  "type": "string",  
  "description": "currency pair",  
  "examples": [  
 "KRB/UAH" ] },  "last": {  
  "type": "number",  
  "description": "unit price for the last closed ask in 24 hours",  
  "examples": [  
 1.234 ] },  "high": {  
  "type": "number",  
  "description": "the highest closed order price for the last 24 hours",  
  "examples": [  
 1.78 ] },  "low": {  
  "type": "number",  
  "description": "the lowest closed order price for the last 24 hours",  
  "examples": [  
 0.5 ] },  "volume": {  
  "type": "number",  
  "description": "total volume of closed orders for the 24 hours",  
  "examples": [  
 10.234236 ] } }}  

order_book

Over this channel you’ll receive updates in currency order book.

Example of message to subscribe:

{  
  "channel": "order_book",  
  "pair": "KRB/UAH"  
}  

Receiving messages:

{  
  "pair":  "KRB/UAH",  
  "unit_price": 1.234,  
  "sum": 1.78,  
  "side": "selling",  
  "volume": 10.234236  
}  
  

JSON Schema

{  
 "$schema": "http://json-schema.org/draft-04/schema#",  
 "type": "object", "properties": { "pair": { "type": "string", "description": "currency pair", "examples": [ "KRB/UAH" ] }, "unit_price": { "type": "number", "description": "order book item unit price", "examples": [ 1.234 ] }, "sum": { "type": "number", "description": "sum of orders with the same unit price", "examples": [ 1.78 ] }, "side": { "type": "number", "description": "order book side", "examples": [ "selling", "buying" ] }, "volume": { "type": "number", "description": "total volume of orders with same unit price", "examples": [ 10.234236 ] } }}  

trading

Over this channel you’ll receive messages about closed orders.

Example of message to subscribe:

{  
  "channel": "trading",  
  "pair": "KRB/UAH"  
}  

Receiving messages:

{  
  "created_at":  "1532694617",  
  "closed_at": "1532696617",  
  "side": "selling",  
  "volume": 2.23236,  
  "unit_price": 1.00,  
  "sum": 2.23236,  
  "pair": "KRB/UAH"  
}  

JSON schema

  
{  
  "$schema": "http://json-schema.org/draft-04/schema#",  
 {  "type": "object",  
  "properties": {  
  "pair": {  
  "type": "string",  
  "description": "currency pair",  
  "examples": [  
 "KRB/UAH" ] },  "unit_price": {  
  "type": "number",  
  "description": "order book item unit price",  
  "examples": [  
 1.234 ] },  "sum": {  
  "type": "number",  
  "description": "sum of orders with the same unit price",  
  "examples": [  
 1.78 ] },  "side": {  
  "type": "number",  
  "description": "order book side",  
  "examples": [  
 "selling", "buying" ] },  "volume": {  
  "type": "number",  
  "description": "total volume of orders with same unit price",  
  "examples": [  
 10.234236 ] },  "created_at": {  
  "type": "string",  
  "description": "Order creation time as UNIX timestamp",  
  "examples": [  
 "1532694617" ] },  "closed_at": {  
  "type": "string",  
  "description": "Order closing time as UNIX timestamp",  
  "examples": [  
 "1532696617" ] } } }```  
  
### user_orders  
  
Over this channel you'll receive updates on user orders.  
It's a private channel, so in order to receive messages you have to provide authorization token received after authentication.  
  
Example of message to subscribe:  
  
```json  
{  
  "channel": "trading",  
  "pair": "KRB/UAH",  
  "token": "124dfg7er894672isdg"  
}  

Receiving messages:

{  
  "created_at":  "1532694617",  
  "closed_at": "1532696617",  
  "side": "selling",  
  "volume": 2.23236,  
  "unit_price": 1.00,  
  "sum": 2.23236,  
  "pair": "KRB/UAH",  
  "pk": 1  
}  

JSON schema

  
{  
  "$schema": "http://json-schema.org/draft-04/schema#",  
 {  "type": "object",  
  "properties": {  
  "pair": {  
  "type": "string",  
  "description": "currency pair",  
  "examples": [  
 "KRB/UAH" ] },  "unit_price": {  
  "type": "number",  
  "description": "order book item unit price",  
  "examples": [  
 1.234 ] },  "sum": {  
  "type": "number",  
  "description": "sum of orders with the same unit price",  
  "examples": [  
 1.78 ] },  "side": {  
  "type": "number",  
  "description": "order book side",  
  "examples": [  
 "selling", "buying" ] },  "volume": {  
  "type": "number",  
  "description": "total volume of orders with same unit price",  
  "examples": [  
 10.234236 ] },  "created_at": {  
  "type": "string",  
  "description": "Order creation time as UNIX timestamp",  
  "examples": [  
 "1532694617" ] },  "closed_at": {  
  "type": "string",  
  "description": "Order closing time as UNIX timestamp",  
  "examples": [  
 "1532696617" ] },  "pk": {  
  "type": "number",  
  "description": "Order primary key",  
  "examples": [  
 1 ] } } }```