WebSocket Protocol API - coinsbit-india/api GitHub Wiki
The API is based on JSON RPC of Websocket protocol. Repeated subscription will be cancelled for the same data type.
System Methods
- PING-PONG Method - used to test the health of sockets
- System Time Method - used to synchronize with socket service times
- Web-Soket Authentication - used to subscribe on private methods
Public Methods
- KLine methods for Graph - used to get data on charts (the change comes after a trade and chart data change)
- Market Price Methods - used to get information about the market price for a specific pair (the change comes after a trade and a change in the market price)
- Market Price Methods - used to get information about market activity for a specific pair (the change comes after a trade and a change in market parameters)
- Deals Methods - used to get information about the last trade in the market (the change comes after the execution of a trade)
- Depth Methods - used to get information on order books and monitor their changes in the market (the change comes after placing, canceling, executing, changing an order)
Private Methods
- Trade Users Balances Methods - used to get the balances of the user from which the request is made (the change comes after updating the value of any balance)
- Active Orders and Orders History Methods - used to get active orders and their history for a specific user from which the request is made (the change comes after placing, canceling, executing, changing an order)
Private Methods:
This method provides information via POST
. The response will return all the information that was posted by the platform. To obtain private information, use the same methods via POST
as an authorized user using api keys.
- List of Public Pairs - returns the history of trades for all public pairs - used for tracking to compare prices in the market, control positions for many markets at once.
- Specific Public Ticker Data - returns the trading history for a specific selected pair - used to track a specific pair and track its key characteristics.
- List of Order Book - Returns all positions for a specific market for all orders of the order book in the selected direction with pagination - used for full monitoring of the order book status, its changes, evaluation of its placed orders and their priority.
- Market History Data - returns the history of trading on the market - used to track your own or someone else's executed orders, trading dynamics, control over buying / selling.
- Public Pair List - returns all public pairs - used to track new pairs, monitor pairs for MM.
- Depth List - returns data on the order book with pagination for a specific pair - used to track the depth of the order book, control placed orders, monitor the market in light mode.
- List of Graphic Data KLine - returns data on charts - is used to create personal charts, control market trends.
Request:
Method
server.auth
Request Parameters:
Name | Type | Description |
---|---|---|
Token | STRING | Personal user token ( check HTTP Authorization ) |
Source | STRING | Defoult: web; Max: 30 bytes; Custom configuration for understendong source of web-soket info |
Request
{
"method":"server.auth",
"params":
[
"$2y$10$J3gXRK...ZOH2yGXTlOcp9iBUq"
"web"
],
"id":0
}
Response Parameters:
Name | Type | Description |
---|---|---|
Status | STRING | Success - auth compleated |
Response:
{
id: 2,
params:
[
],
result:
{
status: "success"
},
error: null
}
Request
- Endpoint
wss://coinsbit.in/ws
Name | Type |
---|---|
method | STRING |
params | ARRAY |
id | INTEGER |
Response
Name | Type | Success | Error |
---|---|---|---|
result | JSON Object | Response | Failure |
Error | JSON Object | NULL | Failure |
id | Integer | Integer | Integer |
Notify
Name | Type |
---|---|
method | STRING |
params | ARRAY |
id | NULL |
General error code:
- invalid argument
- internal error
- service unavailable
- method not found
- service timeout
- require authentication
Method
server.ping
Request
{
"method":"server.ping",
"params":[],
"id":1000}
}
Response Parameters:
Name | Type |
---|---|
result | STRING |
ID | NUMERIC |
Error | NULL |
Response:
{
"error": null,
"result": "pong",
"id": 1000
}
Request:
Method
server.time
Request
{
"method":"server.time",
"params":[],
"id":0
}
Response Parameters:
Name | Type |
---|---|
result | TimeStamp, INTEGER |
ID | NUMERIC |
Error | NULL |
Response:
{
"error": null,
"result": 1493285895,
"id": 1000
}
Method
kline.query
Request Parameters:
Name | Type |
---|---|
market | STRING |
interval | NUMERIC |
Request:
{
"method":"kline.query",
"params":
[
"ETH_BTC",
3600
],
"id":1000
}
Response Parameters:
Name | Type |
---|---|
time | TimeStamp, INTEGER |
open | STRING |
close | STRING |
highest | STRING |
lowest | STRING |
volume | STRING |
amount | STRING |
market | STRING |
Response:
{
"method": "kline.query",
"params":
[
[
1568548260, //time
"0.018302", //open
"0.018302", //close
"0.018302", //highest
"0.018302", //lowest
"500", //volume
"15", //amount
"ETH_BTC" //market
]
],
"id": 1000
}
Method
kline.subscribe
Request Parameters:
Name | Type |
---|---|
market | STRING |
interval | NUMERIC |
Request:
{
"method":"kline.subscribe",
"params":
[
"ETH_BTC",
3600
],
"id":1000
}
Response Parameters:
kline.update
Name | Type |
---|---|
time | TimeStamp, INTEGER |
open | STRING |
close | STRING |
highest | STRING |
lowest | STRING |
volume | STRING |
amount | STRING |
market | STRING |
Response:
{
"method": "kline.update",
"params":
[
[
1568548260, //time
"0.018302", //open
"0.018302", //close
"0.018302", //highest
"0.018302", //lowest
"500", //volume
"15", //amount
"ETH_BTC" //market
]
],
"id": null
}
Method
kline.unsubscribe
Request
{
"method":"kline.unsubscribe",
"params":[],
"id":16
}
Method
price.query
Request Parameters:
Name | Type | Descriprion |
---|---|---|
market | STRING | Can be few markets per request |
Request:
{
"method":"price.query",
"params":
[
"ETH_BTC",
],
"id":111
}
Response Parameters:
Name | Type |
---|---|
market | STRING |
price | STRING |
Response:
{
"method":"price.query",
"params":
[
"ETH_BTC",
"0.01860351"
],
"id":111
}
Method
price.subscribe
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Can be few markets per request |
Request:
{
"method":"price.subscribe",
"params":
[
"ETH_BTC",
],
"id":111
}
Response Parameters:
price.update
Name | Type |
---|---|
market | STRING |
price | STRING |
Response:
{
"method":"price.update",
"params":
[
"ETH_BTC",
"0.01860351"
],
"id":null
}
Method
price.unsubscribe
Request
{
"method":"price.unsubscribe",
"params":[],
"id":16
}
Method
state.query
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Any exchange market |
period | NUMERIC | Default: 86400 |
Request:
{
"method":"state.query",
"params":
[
"ETH_BTC",
86400
],
"id":111
}
Response Parameters:
Name | Type |
---|---|
period | NUMERIC |
volume | STRING |
last | STRING |
open | STRING |
low | STRING |
close | STRING |
high | STRING |
deal | STRING |
Response:
{
"result":
{
"period": 86400,
"volume": "192238.62392908",
"last": "0.018295",
"open": "0.017526",
"low": "0.0174",
"close": "0.018295",
"high": "0.02",
"deal": "3479.25570915213257"
},
"error": null,
"id": 111
}
Method
state.subscribe
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Any exchange market |
period | NUMERIC | Default: 86400 |
Request:
{
"method":"state.subscribe",
"params":
[
"ETH_BTC",
86400
],
"id":111
}
Response Parameters:
state.update
Response Parameters:
Name | Type |
---|---|
period | NUMERIC |
volume | STRING |
last | STRING |
open | STRING |
low | STRING |
close | STRING |
high | STRING |
deal | STRING |
Response:
{
"result":
{
"period": 86400,
"volume": "192238.62392908",
"last": "0.018295",
"open": "0.017526",
"low": "0.0174",
"close": "0.018295",
"high": "0.02",
"deal": "3479.25570915213257"
},
"error": null,
"id": null
}
Method
state.unsubscribe
Request
{
"method":"state.unsubscribe",
"params":[],
"id":16
}
Method
deals.query
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Can be few markets per request |
Request:
{
"method":"deals.query",
"params":
[
"ETH_BTC",
"BTC_USD"
],
"id":111
}
Response Parameters:
Name | Type |
---|---|
type | NUMERIC |
time | STRING |
id | NUMERIC |
amount | STRING |
price | STRING |
Response:
{
"method": "deals.query",
"params":
[
"ETH_BTC",
[
{
"type": "sell",
"time": 1568556382.1329091,
"id": 5478754,
"amount": "4.9193309",
"price": "10365.40703518"
}
],
"BTC_USD",
[
{
...
}
],
],
"id": 111
}
Method
deals.subscribe
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Can be few markets per request |
Request:
{
"method":"deals.subscribe",
"params":
[
"ETH_BTC",
"BTC_USD"
],
"id":111
}
Response Parameters:
deals.update
Response Parameters:
Name | Type |
---|---|
type | NUMERIC |
time | STRING |
id | NUMERIC |
amount | STRING |
price | STRING |
Response:
{
"method": "deals.update",
"params":
[
"ETH_BTC",
[
{
"type": "sell",
"time": 1568556382.1329091,
"id": 5478754,
"amount": "4.9193309",
"price": "10365.40703518"
}
],
"BTC_USD",
[
{
...
}
],
],
"id": null
}
Method
deals.unsubscribe
Request
{
"method":"deals.unsubscribe",
"params":[],
"id":16
}
Method
depth.query
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Any market pair |
limit | NUMERIC | Limit of order quantity |
interval | STRING | Defoult: 1, No interval: 0, Step: 1 |
Request:
{
"method":"depth.query",
"params":
[
"ETH_BTC", //market
1, //limit
"0" //interval
],
"id":111
}
Response Parameters:
Name | Type |
---|---|
type | STRING |
id | NUMERIC |
amount | STRING |
price | STRING |
Response:
}
"method":"depth.query",
"result":
{
"asks":
[
[
"8000.00", //price
"9.6250" //amount
]
],
"bids":
[
[
"7000.00", //price
"0.1000" //amount
]
]
"id": 111,
}
Method
depth.subscribe
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Any market pair |
limit | NUMERIC | Limit of order quantity |
interval | STRING | Defoult: 1, No interval: 0, Step: 1 |
Request:
{
"method":"depth.subscribe",
"params":
[
"ETH_BTC", //market
1, //limit
"0" //interval
],
"id":111
}
Response Parameters:
depth.update
Response Parameters:
Name | Type | Description |
---|---|---|
clean | BOOLEAN | FALSE: returned latest result, TRUE - no updates |
limit | NUMERIC | Return update from last result with limit |
market | STRING | Subscribed market |
id | NUMERIC | Request ID |
Type | String | Order type |
Amount | String | order amount in 1st Ticker |
Price | String | order price in 1st Ticker |
Response:
{
"method": "depth.update",
"params":
[
true,
{
"asks":
[
[
"0.018519", //price
"120.6" //amount
]
],
"bids":
[
[
"0.01806", //price
"90.31637262" //amount
]
]
},
"ETH_BTC"
],
"id": null
}
Method
depth.unsubscribe
Request
{
"method":"depth.unsubscribe",
"params":[],
"id":16
}
Need to authorize first Web-Soket Authorization
Method
asset.query
Request Parameters:
Name | Type | Description |
---|---|---|
asset list | STRING | Null: for all; Asset List: for choosed |
Request:
{
"method":"asset.query",
"params":
[
"BTC"
],
"id":111
}
Response Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Asset name |
available | NUMERIC | Amount without active orders |
freeze | STRING | active orders amount |
Response:
{
"BTC":
{
"available": "1.10000000",
"freeze": "9.90000000"
}
}
Method
asset.subscribe
Request Parameters:
Name | Type | Description |
---|---|---|
asset list | STRING | Null: for all; Asset List: for choosed |
Request:
{
"method":"asset.subscribe",
"params":
[
"BTC",
"CNY"
],
"id":111
}
Response Parameters:
asset.update
Response Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Asset name |
available | NUMERIC | Amount without active orders |
freeze | STRING | active orders amount |
Response:
[
{
"BTC:
{
"available": "1.10000000",
"freeze": "9.90000000"
},
"CNY":
{
}
}
]
Method
asset.unsubscribe
Request
{
"method":"asset.unsubscribe",
"params":[],
"id":111
}
Need to authorize first Web-Soket Authorization
Method
order.query
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | For all pairs: ""; Special: Choosed Pair |
offset | INTEGER | NO |
limit | INTEGER | Defoult: 1, No interval: 0, Step: 1 |
Request:
{
"method":"order.query",
"params":
[
"", //market
1, //offset
30 //interval
],
"id":6
}
Response Parameters:
Name | Type | Description |
---|---|---|
algorithm | INTEGER | Spot: 0; Margin: 1 |
amount | NUMERIC | Order amount in first ticker of Pair (Asset) |
ctime | TIMESTAMP | Time of order placed |
deal_fee | STRING | user fee coefficient |
deal_money | STRING | Order amount in second ticker of Pair (Market) |
deal_stock | STRING | Order amount in first ticker of Pair (Asset) |
id | INTEGER | Order ID |
left | STRING | Order left (if not traded = amount = deal_stock; if 0 - order finished) |
maker_fee | STRING | Fee of order placer |
market | STRING | Order Pair |
mtime | INTEGER | Matching time ( time of finishing) |
platform | INTEGER | 0 - Limit / Market; 1 - Stop-limit; 2 - OCO |
price | STRING | Order Price |
side | INTEGER | 1 - Sell (Ask) 2- Buy (Bid) |
source | STRING | Custom Parametr |
taker_fee | STRING | Fee of order tacker |
type | INTEGER | 1 - Limit; 2 - Market |
user | INTEGER | - User ID |
Response:
{
id: 6,
params:
[
6,
"all",
0,
30
],
result:
{
limit: 30
market_name: "all"
offset: 0
records:
{
algorithm: 0
amount: "1"
ctime: 1620561060.783
deal_fee: "0"
deal_money: "0"
deal_stock: "0"
id: 224280948
left: "1"
maker_fee: "0.002"
market: "ETH_EUR"
mtime: 0
platform: 0
price: "5000"
side: 1
source: ""
taker_fee: "0.002"
type: 1
user: 6
}
total: 1,
}
}
Method
order.history
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | Any market pair |
start_time | INTEGER | Unlimited: 0; Timestamp: custom |
end_time | INTEGER | Unlimited: 0; Timestamp: custom |
offset | INTEGER | NO |
limit | NUMERIC | Limit of order quantity |
side | STRING | Unlimited: 0, Sell: 1, Buy: 2 |
Request:
{
method: "order.history",
params:
[
"",
0,
0,
0,
30
],
id: 10
}
Response Parameters:
Name | Type | Description |
---|---|---|
algorithm | INTEGER | Spot: 0; Margin: 1 |
amount | NUMERIC | Order amount in first ticker of Pair (Asset) |
ctime | TIMESTAMP | Time of order placed |
deal_fee | STRING | user fee coefficient |
deal_money | STRING | Order amount in second ticker of Pair (Market) |
deal_stock | STRING | Order amount in first ticker of Pair (Asset) |
id | INTEGER | Order ID |
left | STRING | Order left (if not traded = amount = deal_stock; if 0 - order finished) |
maker_fee | STRING | Fee of order placer |
market | STRING | Order Pair |
mtime | INTEGER | Matching time ( time of finishing) |
platform | INTEGER | 0 - Limit / Market; 1 - Stop-limit; 2 - OCO |
price | STRING | Order Price |
side | INTEGER | 1 - Sell (Ask) 2- Buy (Bid) |
source | STRING | Custom Parametr |
taker_fee | STRING | Fee of order tacker |
type | INTEGER | 1 - Limit; 2 - Market |
user | INTEGER | - User ID |
Response:
{
id: 6,
params:
[
"",
0,
0,
0,
30
],
result:
{
limit: 30
start_time: 0
end_time: 0
market_name: ""
side: 0
offset: 0
records:
{
algorithm: 0
amount: "1"
ctime: 1620561060.783
deal_fee: "0"
deal_money: "0"
deal_stock: "0"
id: 224280948
left: "1"
maker_fee: "0.002"
market: "ETH_EUR"
mtime: 0
platform: 0
price: "5000"
side: 1
source: ""
taker_fee: "0.002"
type: 1
user: 6
}
}
}
Method
order.subscribe
Request Parameters:
Name | Type | Description |
---|---|---|
market | STRING | For all pairs: ""; Special: Choosed Pair |
offset | INTEGER | NO |
limit | INTEGER | Defoult: 1, No interval: 0, Step: 1 |
Request:
{
"method":"order.subscribe",
"params":
[
"BTC_USDT", //market
],
"id":6
}
order.update
Response Parameters:
Name | Type | Description |
---|---|---|
algorithm | INTEGER | Spot: 0; Margin: 1 |
amount | NUMERIC | Order amount in first ticker of Pair (Asset) |
ctime | TIMESTAMP | Time of order placed |
deal_fee | STRING | user fee coefficient |
deal_money | STRING | Order amount in second ticker of Pair (Market) |
deal_stock | STRING | Order amount in first ticker of Pair (Asset) |
id | INTEGER | Order ID |
left | STRING | Order left (if not traded = amount = deal_stock; if 0 - order finished) |
maker_fee | STRING | Fee of order placer |
market | STRING | Order Pair |
mtime | INTEGER | Matching time ( time of finishing) |
platform | INTEGER | 0 - Limit / Market; 1 - Stop-limit; 2 - OCO |
price | STRING | Order Price |
side | INTEGER | 1 - Sell (Ask) 2- Buy (Bid) |
source | STRING | Custom Parametr |
taker_fee | STRING | Fee of order tacker |
type | INTEGER | 1 - Limit; 2 - Market |
user | INTEGER | - User ID |
Response:
result:
{
{
algorithm: 0
amount: "1"
ctime: 1620561060.783
deal_fee: "0"
deal_money: "0"
deal_stock: "0"
id: 224280948
left: "1"
maker_fee: "0.002"
market: "ETH_EUR"
mtime: 0
platform: 0
price: "5000"
side: 1
source: ""
taker_fee: "0.002"
type: 1
user: 6
}
}
Method
order.unsubscribe
Request
{
"method":"order.unsubscribe",
"params":[],
"id":16
}