CryptoSouk Public API

Request structure

Requests are intiated using POST method. Data is transmitted to the server using UTF-8 charset.

POST data is expected to be sent as a JSON string.

JSON.stringify({key:'value'})

Response structure

Responses will contain either the key "isAccepted": true, or "isAccepted": false,.

Typically there will be another key "rejectReason" with a textual explanation of the error as shown below.

{"isAccepted": false, "rejectReason": "Incorrect usage",}

Request limits

More than 500 request per 10 minutes will result in IP ban.

For real-time data please refer to the CryptoSouk WebSocket API.

WebSocket API

Our WebSocket API provides real-time order book, trade data, and much more.

Public HTTP API 

Ticker 

Parameters

productPair - trade pair (ex: “BTCNZD”)

Gets the current ticker data for a given currency pair
/ajax/v1/GetTicker
  • Request
  • Headers
    Content-Type: application/json
    Body
    {"productPair": "BTCNZD"}
                                            
  • Response  200
  • Headers
    Content-Type: application/json
    Body
                                                {"high":253.101,"last":249.76,"bid":248.8901,"volume":5.813354,"low":231.21,"ask":248.9012,"Total24HrQtyTraded":52.654968,"Total24HrProduct2Traded":569.05762,"Total24HrNumTrades":4,"sellOrderCount":7,"buyOrderCount":11,"numOfCreateOrders":0,"isAccepted":true}
                                            

Trades 

Parameters

ins - instrument code (ex: “BTCNZD”)

startIndex - specifies the index to begin from, -1 being the first trade on CryptoSouk. To begin from the most recent trade, set startIndex to 0 (default: 0)

Count - specifies the number of trades to return (default: 10)

Fetches past trades for the given currency pair
/ajax/v1/GetTrades
  • Request
  • Headers
    Content-Type: application/json
    Body
                                                {"ins": "BTCNZD", "startIndex": -1, "count": 20}
                                                
                                            
  • Response  200
  • Headers
                                                Content-Type: application/json
    Body
                                                {"isAccepted":true,"dateTimeUtc":635507981548085938,"ins":"BTCNZD","startIndex":0,"count":10,"trades":[{"tid":0,"px":231.8379,"qty":4.913,"unixtime":1399951989,"utcticks":635355487898355234,"incomingOrderSide":0,"incomingServerOrderId":2598,"bookServerOrderId":2588},{"tid":1,"px":7895.1487,"qty":0.25,"unixtime":1403143708,"utcticks":635387405087297421,"incomingOrderSide":0,"incomingServerOrderId":284241,"bookServerOrderId":284235},{"tid":2,"px":7935.058,"qty":0.25,"unixtime":1403195348,"utcticks":635387921488684140,"incomingOrderSide":0,"incomingServerOrderId":575845,"bookServerOrderId":574078},{"tid":3,"px":7935.0448,"qty":0.25,"unixtime":1403195378,"utcticks":635387921780090390,"incomingOrderSide":0,"incomingServerOrderId":576028,"bookServerOrderId":575946},{"tid":4,"px":7933.9566,"qty":0.1168,"unixtime":1403195510,"utcticks":635387923108371640,"incomingOrderSide":0,"incomingServerOrderId":576974,"bookServerOrderId":576947},{"tid":5,"px":7961.0856,"qty":0.25,"unixtime":1403202307,"utcticks":635387991073850156,"incomingOrderSide":0,"incomingServerOrderId":600547,"bookServerOrderId":600338},{"tid":6,"px":7961.1388,"qty":0.011,"unixtime":1403202307,"utcticks":635387991073850156,"incomingOrderSide":0,"incomingServerOrderId":600547,"bookServerOrderId":600418},{"tid":7,"px":7961.2451,"qty":0.02,"unixtime":1403202307,"utcticks":635387991073850156,"incomingOrderSide":0,"incomingServerOrderId":600547,"bookServerOrderId":600428},{"tid":8,"px":7947.1437,"qty":0.09,"unixtime":1403202749,"utcticks":635387995498225156,"incomingOrderSide":0,"incomingServerOrderId":602183,"bookServerOrderId":601745},{"tid":9,"px":7818.5073,"qty":0.25,"unixtime":1403219720,"utcticks":635388165206506406,"incomingOrderSide":0,"incomingServerOrderId":661909,"bookServerOrderId":661620}]}    
                                                
                                            

Trades by date 

Parameters

ins - instrument code (ex: “BTCNZD”)

startDate - specifies the starting time in epoch time, type is long

endDate - specifies the end time in epoch time, type is long

Get trades by date
/ajax/v1/GetTradesByDate
  • Request
  • Headers
    Content-Type: application/json
    Body
    {"ins":"BTCNZD","startDate":1414799400,"endDate":1414800000}
                                                
                                            
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {"isAccepted":true,"dateTimeUtc":635504540880633671,"ins":"BTCNZD","startDate":1414799400,"endDate":1414800000,"trades":[
    {"tid":11505,"px":334.669,"qty":0.1211,"unixtime":1414799403,"utcticks":635503962032459843,"incomingOrderSide":1,"incomingServerOrderId":5185651,"bookServerOrderId":5162440},
    {"tid":11506,"px":334.669,"qty":0.1211,"unixtime":1414799405,"utcticks":635503962058446171,"incomingOrderSide":1,"incomingServerOrderId":5186245,"bookServerOrderId":5162440},
    {"tid":11507,"px":336.498,"qty":0.011,"unixtime":1414799407,"utcticks":635503962072967656,"incomingOrderSide":0,"incomingServerOrderId":5186530,"bookServerOrderId":5178944},
    {"tid":11508,"px":335.948,"qty":0.011,"unixtime":1414799410,"utcticks":635503962108055546,"incomingOrderSide":0,"incomingServerOrderId":5187260,"bookServerOrderId":5186531}]}
    

Order book 

Displays the top 20 asks and bids. For Real-Time data please use the CryptoSouk WebSockets API.

Parameters

productPair - trade pair (ex: “BTCNZD”)

Fetches the current orderbook for a given currency pair
/ajax/v1/GetOrderBook
  • Request
  • Headers
    Content-Type: application/json
    Body
    {"productPair":"BTCNZD"}
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {"bids":[{"qty":725,"px":66},{"qty":1289,"px":65},{"qty":1266,"px":64}],"asks":[{"qty":1,"px":67},{"qty":1,"px":69},{"qty":2,"px":70},],"isAccepted":true}
    

Product pairs 

Gets the currency pairs currently traded on CryptoSouk
/ajax/v1/GetProductPairs
  • Request
  • Headers
    Content-Type: application/json
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {"productPairs":[{"name":"LTCUSD","productPairCode":100,"product1Label":"LTC","product1DecimalPlaces":8,"product2Label":"USD","product2DecimalPlaces":6}, {"name":"BTCNZD","productPairCode":99,"product1Label":"BTC","product1DecimalPlaces":8,"product2Label":"USD","product2DecimalPlaces":6}],"isAccepted":true}         
    

Products 

Gets the currency products currently supported on CryptoSouk
/ajax/v1/GetProducts
  • Request
  • Headers
    Content-Type: application/json
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {"products": [{"name": "USD","isDigital": false,"productCode": 0,"decimalPlaces": 4,"fullName": "US Dollar"},{"name": "BTC","isDigital": true,"productCode": 1,"decimalPlaces": 6,"fullName": "Bitcoin"}],"isAccepted": true}
    

WebSocket API 

The WebSocket protocol provides full-duplex communications channels over a single persistent TCP connection.

For real-time exchange data or high frequency activity we recommend using our WebSockets API.

WebSocket URI: wss://api.cryptosouk.exchange/WSGateway/

All WebSocket requests require the trailing “/” in the URI


Get Ticker

/v1/GetTicker/

Parameters

messageType - logon

Get Ticker

var ws = new WebSocket("wss://api.cryptosouk.exchange/WSGateway/v1/GetTicker/");
ws.onopen = function()
{
ws.send(JSON.stringify({messageType: 'logon'}));
};
ws.onmessage = function (evt)
{ 
console.log(evt.data);
}

Response

Example shows only a subset of the typical response.

{"messageType":"Ticker","prodPair":"BTCGBP","high":0,"low":0,"last":0,"volume":0,"Total24HrQtyTraded":0,"Total24HrProduct2Traded":0,"Total24HrNumTrades":0,"bid":0,"ask":9223372036.85478,"buyOrderCount":0,"sellOrderCount":0}

Get Trades and Orderbook

/v1/GetL2AndTrades/

Parameters:

ins - instrument code (ex: “BTCNZD”)

ModifyL2Order - 0 for orderbook, 1 for new trades (default: 0)

Get trades

var ws = new WebSocket("wss://api.cryptosouk.exchange/WSGateway/v1/GetL2AndTrades/");
ws.onopen = function()
{
ws.send(JSON.stringify({ins:'BTCNZD',ModifyL2Order:'0'}));
};
ws.onmessage = function (evt)
{ 
console.log(evt.data);
}

Response

Example shows only a subset of the typical response.

[[78433227,635586774471555007,225.58,0.7045,0,0],[78433226,635586774471555006,225.6,33,0,0],[78431613,635586774176867505,225.62,37.1979,0,0]]

Get Requests 

Product pairs 

Gets the currency pairs currently traded on CryptoSouk
/ajax/v1/GetProductPairs
  • Request
  • Headers
    Content-Type: application/json
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {"productPairs":[{"name":"LTCUSD","productPairCode":100,"product1Label":"LTC","product1DecimalPlaces":8,"product2Label":"USD","product2DecimalPlaces":6}, {"name":"BTCNZD","productPairCode":99,"product1Label":"BTC","product1DecimalPlaces":8,"product2Label":"USD","product2DecimalPlaces":6}],"isAccepted":true}         

Trades

Parameters

ins - instrument code (ex: “BTCNZD”)

Since - specifies the starting Trade ID (TID)

Get trades
/ajax/v1/Trades
  • Request
  • Headers
    Content-Type: application/json
    CryptoSouk AJAX REQUEST URL/Trades/BTCNZD/?Since=0
  • Response  200
  • Headers
    Content-Type: application/json
    "trades": [ {"tid":11505,"price":334.669,"amount":0.1211,"date":1414799403}, {" tid":11506,"price":334.669,"amount":0.1211,"date":1414799405}, {" tid":11507,"price":336.498,"amount":0.011,"date":1414799407}, {" tid":11508,"price":335.948,"amount":0.011,"date":1414799410}

GetOrderBook 

Parameters

ins - instrument code (ex: “BTCNZD”)

Get trades
/ajax/v1/GetOrderBook
  • Request
  • Headers
    Content-Type: application/json
    CryptoSouk AJAX REQUEST URL/GetOrderBook/BTCNZD/
  • Response  200
  • Headers
    Content-Type: application/json
    "bids": [[226.04,24.6696],[226.03,20]], "asks":[[226.85,1.406],[226.86,2.9806]],"isAccepted":true}