NAV Navbar
shell java python php node.js javascript

Introduction

Coinscious Data Service - Market Data API: Our comprehensive raw market data API services include crypto exchange trade history data, order book data and millisecond level live stream data. Feel free to download our Market data API specification.

Version: 1.0.0

Requests

Exchange

Please refer to the value of name field in the response returned by Exchange List Exchange List API.

Fiat Currency

We support AUD, CAD, CNY, EUR, GBP, JPY, KRW, RUB and USD. USD is used as the default for any pricing.

Token Pair

Please refer to the response returned by Exchange Token Pair List API.

Token

Please refer to the response returned by Token List API. Only lower case is accepted.

Interval, Limit and Date Range

We support the following intervals: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d. The default interval is 30m if it is not specified.

"Limit" is the number of data returned in JSON response.
* Limit is set to the default value of 500 if it is not specified.
* We only accept limits less than and equal to 2000. Multiple calls are required with different time ranges to pull more data.

You can also specify your query date range by defining the start and end in query parameters.
* "End" is set to the current timestamp by default.
* "Start" is calculated based on end, limit, and interval.

Response

Coinscious uses standard HTTP response codes to indicate the success or failure of an API request. For example,
* Code 200 indicates success.
* Code 400 indicates an error that resulted from the provided information (e.g., a required parameter was missing).

JSON structure of an unexpected error response is the following:

{
  "code": "1001",
  "message": "Exchange not specified."
}

We support the following list of standard HTTP response codes:

Status Code Description
200 It's All Good.
400 Unexpected Error
Refer to the list of Error Codes we provide.
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed
429 Too Many Requests
500 Internal Server Error

Dump (.csv) downloads

Trade History Download

Download a .csv dump file that contains the trade history of a specific token pair found on a supported exchange.

HTTP Request

GET /download/trade-history/{exchange}/{pair}

Parameters

Name Required Type Description
exchange Yes string Exchanges supported
pair Yes string Token Pair supported
start No timestamp
end No timestamp
limit No integer Interval and limit

Responses

Code Description
200 Successful response

Examples

/download/trade-history/poloniex/eth_btc?start=1532554784000&end=1532562073000&limit=500

Order Book Download

Download a .csv dump file that contains a 10% order book. This consists of orders placed at 10% lower or higher than the mid-price, for a specific token pair found on a supported exchange.

HTTP Request

GET /download/orderbook/{exchange}/{pair}

Parameters

Name Required Type Description
exchange Yes string Exchanges supported
pair Yes string Token Pair supported
start No timestamp
end No timestamp
limit No integer Interval and limit

Responses

Code Description
200 Successful response

Examples

/download/orderbook/bittres/eth_btc?start=1532554784000&end=1532555700000&limit=200

Exchange API

Exchange List

Obtain a list of supported exchanges, including their fee structures.

HTTP Request

GET /exchanges

curl -X GET "https://api.coinscious.org/exchanges" -H "accept: application/json" -H "Authorization: Bearer <token>"
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class Example {

    public static void main(String[] args) throws IOException {

        Request request = new Request.Builder()
                .get()
                .url("https://api.coinscious.org/exchanges")
                .addHeader("Authorization", "bearer " + token)
                .build();

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient client = new OkHttpClient.Builder()
                .dispatcher(dispatcher)
                .build();

        Response response = client.newCall(request).execute();
        String body = response.body().string();
    }

}
import requests
url = 'https://api.coinscious.org/exchanges'
headers = {'Authorization' : 'bearer token'}
response = requests.get(url, headers=headers)
<?php
$request = new HttpRequest();
$request->setUrl('https://api.coinscious.org/exchanges');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
  'Authorization' => 'bearer token'
));

try {
  $response = $request->send();
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
?>
const https = require('https');

var options = {
  "method": "GET",
  "hostname": "api.coinscious.org",
  "path": "/exchanges",
  "headers": {'Authorization': 'bearer token'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();
var req =  new XMLHttpRequest();
req.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(JSON.parse(this.responseText));
    }
};
req.open("GET", "https://api.coinscious.org/exchanges", true);
req.setRequestHeader("Authorization", "bearer token");
req.send();

The request returns JSON structured like the following:

[  
  {
    "name": "binance",
    "fee": {
        "orderExecutionFees": [
          {
            "tokenOrPair": "all",
            "isFutureTrading": false,
            "makerFee": "0.100%",
            "takerFee": "0.200%",
            "settlementFee": "",
            "leverage": "",
            "condition": "$0.00 or more traded"
          },
          {
            "tokenOrPair": "all",
            "isFutureTrading": false,
            "makerFee": "0.080%",
            "takerFee": "0.200%",
            "settlementFee": "",
            "leverage": "",
            "condition": "$500,000.00 or more traded"
          }
        ],
        "withdrawFees": [
          {
            "token": "btc",
            "feeRange": 
              {
                "all" : "0.0004 BTC"
              },
            "minumum": "0.002",
            "maximum": "",
            "limits": 
              {
                "Withdraw Daily Limit" : "100000"
              }
          }
        ],
        "depositFees": [
          {
            "token": "btc",
            "feeRange": 
              {
                ">=1000USD": "FREE",
                "<1000USD": "0.0004 BTC"
              },
            "minumum": "",
            "maximum": "",
            "limits": {}
          }
        ],
        "contracts": [
          {
            "contractType": "Perpetual Contracts",
            "tokenOrPair": "xbt",
            "makerFee": "-0.0250%",
            "takerFee": "0.0750%",
            "settlementFee": "",
            "leverage": "100x",
            "longFunding": "0.0100%",
            "shortfunding": "-0.0100%",
            "fundingInterval": "every 8 hours"
          }, 
          {
            "contractType": "Traditional Futures",
            "tokenOrPair": "xbt",
            "makerFee": "-0.0250%",
            "takerFee": "0.0750%",
            "settlementFee": "0.0500%",
            "leverage": "100x",
            "longFunding": "",
            "shortfunding": "",
            "fundingInterval": ""
          },
        ],
        "marginFunding": [
          {
            "Charge on fees collected by Margin Funding Providers":"15.0% (of the fees generated by active margin funding contracts)",
            "Charge on fees collected by Margin Funding Providers, when opened by a hidden offer": "18.0% (of the fees generated by active margin funding contracts)",
            "Charge on funding that is borrowed and subsequently returned without being used in a margin position":"Up to one full day’s interest"
          }
        ]
      }
  },
  {
    "name": "polonix",
    "fee": {
      "orderExecutionFees": [
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.10%",
          "takerFee": "0.20%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) < 500K USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.08%",
          "takerFee": "0.20%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 500K USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.06%",
          "takerFee": "0.20%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 1M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.04%",
          "takerFee": "0.20%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 2.5M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.02%",
          "takerFee": "0.20%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 5M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.00%",
          "takerFee": "0.20%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 7.5M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.00%",
          "takerFee": "0.18%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 10M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.00%",
          "takerFee": "0.16%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 15M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.00%",
          "takerFee": "0.14%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 20M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.00%",
          "takerFee": "0.12%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 25M USD",
          "futureTrading": false
        },
        {
          "tokenOrPair": "all",
          "isFutureTrading": false,
          "makerFee": "0.00%",
          "takerFee": "0.10%",
          "settlementFee": null,
          "leverage": null,
          "condition": "Trade Volume (trailing 30 day avg) ≥ 30M USD",
          "futureTrading": false
        }
      ],
      "withdrawalFees": [
        {
          "token": "all",
          "feeRange": {
            "all": "0"
          },
          "minimum": null,
          "maximum": null,
          "limits": null
        }
      ],
      "depositFees": [
        {
          "token": "all",
          "feeRange": {
            "all": "0"
          },
          "minimum": null,
          "maximum": null,
          "limits": null
        }
      ],
      "contracts": null,
      "marginFunding": null
    }
  }
]

Responses

Code Description
200 Successful response

Exchange Token Pair List

Obtain a list of all the token pairs available on a supported exchange.

HTTP Request

GET /exchanges/{exchange}/pairs

Parameters

Name Required Type Description
exchange Yes string Exchanges supported
curl -X GET "https://api.coinscious.org/exchanges/poloniex/pairs" -H "accept: application/json" -H "Authorization: Bearer <token>"
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class Example {

    public static void main(String[] args) throws IOException {

        Request request = new Request.Builder()
                .get()
                .url("https://api.coinscious.org/exchanges/poloniex/pairs")
                .addHeader("Authorization", "bearer " + token)
                .build();

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient client = new OkHttpClient.Builder()
                .dispatcher(dispatcher)
                .build();

        Response response = client.newCall(request).execute();
        String body = response.body().string();
    }

}
import requests
url = 'https://api.coinscious.org/exchanges/poloniex/pairs'
headers = {'Authorization' : 'bearer token'}
response = requests.get(url, headers=headers)
<?php
$request = new HttpRequest();
$request->setUrl('https://api.coinscious.org/exchanges/poloniex/pairs');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
  'Authorization' => 'bearer token'
));

try {
  $response = $request->send();
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
?>
const https = require('https');

var options = {
  "method": "GET",
  "hostname": "api.coinscious.org",
  "path": "/exchanges/poloniex/pairs",
  "headers": {'Authorization': 'bearer token'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();
var req =  new XMLHttpRequest();
req.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(JSON.parse(this.responseText));
    }
};
req.open("GET", "https://api.coinscious.org/exchanges/poloniex/pairs", true);
req.setRequestHeader("Authorization", "bearer token");
req.send();

The request returns JSON structured like the following:

{
  "current": [
    "adah19",
    "bchh19",
    "eosh19",
    "ethh19",
    "ethusd",
    "ltch19",
    "trxh19",
    "xbt7d_d95",
    "xbt7d_u105",
    "xbth19",
    "xbtm19",
    "xbtusd",
    "xrph19"
  ],
  "expired": [
    "adaz18",
    "bchz18",
    "eosz18",
    "ethz18",
    "ltcz18",
    "trxz18",
    "xbtz18",
    "xrpz18"
  ]
}

Responses

Code Description
200 Successful response

Token List

Obtain a list of general information on all the available tokens.

HTTP Request

GET /tokens

curl -X GET "https://api.coinscious.org/tokens" -H "accept: application/json" -H "Authorization: Bearer <token>"
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class Example {

    public static void main(String[] args) throws IOException {

        Request request = new Request.Builder()
                .get()
                .url("https://api.coinscious.org/tokens")
                .addHeader("Authorization", "bearer " + token)
                .build();

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient client = new OkHttpClient.Builder()
                .dispatcher(dispatcher)
                .build();

        Response response = client.newCall(request).execute();
        String body = response.body().string();
    }

}
import requests
url = 'https://api.coinscious.org/tokens'
headers = {'Authorization' : 'bearer token'}
response = requests.get(url, headers=headers)
<?php
$request = new HttpRequest();
$request->setUrl('https://api.coinscious.org/tokens');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
  'Authorization' => 'bearer token'
));

try {
  $response = $request->send();
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
?>
const https = require('https');

var options = {
  "method": "GET",
  "hostname": "api.coinscious.org",
  "path": "/tokens",
  "headers": {'Authorization': 'bearer token'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();
var req =  new XMLHttpRequest();
req.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(JSON.parse(this.responseText));
    }
};
req.open("GET", "https://api.coinscious.org/tokens", true);
req.setRequestHeader("Authorization", "bearer token");
req.send();

The request returns JSON structured like the following:

[
  {
    "symbol": "BTC",
    "fullName": "Bitcoin (BTC)",
    "chineseName": "比特币"
  }
]

Responses

Code Description
200 Successful response

OHLCV Data

Obtain open, high, low, close prices and volume indicators (OHLCV) data for a specific token pair found on a supported exchange.

HTTP Request

GET /ohlcv/{exchange}/{pair}

Parameters

Name Required Type Description
exchange Yes string Exchanges supported
pair Yes string Token Pair supported
interval No string Interval and limit
start No timestamp
end No timestamp
limit No integer Interval and limit
curl -X GET "https://api.coinscious.org/ohlcv/binance/eth_btc" -H "accept: application/json" -H "Authorization: Bearer <token>"
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class Example {

    public static void main(String[] args) throws IOException {

        Request request = new Request.Builder()
                .get()
                .url("https://api.coinscious.org/ohlcv/binance/eth_btc")
                .addHeader("Authorization", "bearer " + token)
                .build();

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient client = new OkHttpClient.Builder()
                .dispatcher(dispatcher)
                .build();

        Response response = client.newCall(request).execute();
        String body = response.body().string();
    }

}
import requests
url = 'https://api.coinscious.org/ohlcv/binance/eth_btc'
headers = {'Authorization' : 'bearer token'}
response = requests.get(url, headers=headers)
<?php
$request = new HttpRequest();
$request->setUrl('https://api.coinscious.org/ohlcv/binance/eth_btc');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
  'Authorization' => 'bearer token'
));

try {
  $response = $request->send();
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
?>
const https = require('https');

var options = {
  "method": "GET",
  "hostname": "api.coinscious.org",
  "path": "/ohlcv/binance/eth_btc",
  "headers": {'Authorization': 'bearer token'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();
var req =  new XMLHttpRequest();
req.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(JSON.parse(this.responseText));
    }
};
req.open("GET", "https://api.coinscious.org//ohlcv/binance/eth_btc", true);
req.setRequestHeader("Authorization", "bearer token");
req.send();

The request returns JSON structured like the following:

[
  {
    "timestamp": 1515100800000,
    "open": 0.06354946,
    "high": 0.06377,
    "low": 0.06320008,
    "close": 0.06320008,
    "volume": 31.97875423
  },
  {
    "timestamp": 1515101100000,
    "open": 0.06354947,
    "high": 0.06379,
    "low": 0.06320003,
    "close": 0.06320005,
    "volume": 45.39787
  }
]

Responses

Code Description
200 Successful response

VWAP Data

Obtain volume weighted average price (VWAP) data for a specific token found on a supported exchange.

HTTP Request

GET /vwap/{token}

Parameters

Name Required Type Description
token Yes string Token supported
fiat No string Fiat Currency supported
interval No string Interval and limit
start No timestamp
end No timestamp
limit No integer Interval and limit
curl -X GET "https://api.coinscious.org/vwap/btc" -H "accept: application/json" -H "Authorization: Bearer <token>"
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class Example {

    public static void main(String[] args) throws IOException {

        Request request = new Request.Builder()
                .get()
                .url("https://api.coinscious.org/vwap/btc")
                .addHeader("Authorization", "bearer " + token)
                .build();

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient client = new OkHttpClient.Builder()
                .dispatcher(dispatcher)
                .build();

        Response response = client.newCall(request).execute();
        String body = response.body().string();
    }

}
import requests
url = 'https://api.coinscious.org/vwap/btc'
headers = {'Authorization' : 'bearer token'}
response = requests.get(url, headers=headers)
<?php
$request = new HttpRequest();
$request->setUrl('https://api.coinscious.org/vwap/btc');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
  'Authorization' => 'bearer token'
));

try {
  $response = $request->send();
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
?>
const https = require('https');

var options = {
  "method": "GET",
  "hostname": "api.coinscious.org",
  "path": "/vwap/btc",
  "headers": {'Authorization': 'bearer token'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();
var req =  new XMLHttpRequest();
req.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(JSON.parse(this.responseText));
    }
};
req.open("GET", "https://api.coinscious.org/vwap/btc", true);
req.setRequestHeader("Authorization", "bearer token");
req.send();

The request returns JSON structured like the following:

[
  {
    "timestamp": 1515100800000,
    "vwap": 10.32
  },
  {
    "timestamp": 1515101100000,
    "vwap": 9.98
  }
]

Responses

Code Description
200 Successful response

Exchange VWAP Data

Obtain volume weighted average price (VWAP) for a specific token pair found on a supported exchange.

HTTP Request

GET /exchange-vwap/{exchange}/{pair}

Parameters

Name Required Type Description
exchange Yes string Exchanges supported
pair Yes string Token Pair supported
interval No string Interval and limit
start No timestamp
end No timestamp
limit No integer Interval and limit
curl -X GET "https://api.coinscious.org/exchange-vwap/binance/eth_btc" -H "accept: application/json" -H "Authorization: Bearer <token>"
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class Example {

    public static void main(String[] args) throws IOException {

        Request request = new Request.Builder()
                .get()
                .url("https://api.coinscious.org/exchange-vwap/binance/eth_btc")
                .addHeader("Authorization", "bearer " + token)
                .build();

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient client = new OkHttpClient.Builder()
                .dispatcher(dispatcher)
                .build();

        Response response = client.newCall(request).execute();
        String body = response.body().string();
    }

}
import requests
url = 'https://api.coinscious.org/exchange-vwap/binance/eth_btc'
headers = {'Authorization' : 'bearer token'}
response = requests.get(url, headers=headers)
<?php
$request = new HttpRequest();
$request->setUrl('https://api.coinscious.org/exchange-vwap/binance/eth_btc');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
  'Authorization' => 'bearer token'
));

try {
  $response = $request->send();
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
?>
const https = require('https');

var options = {
  "method": "GET",
  "hostname": "api.coinscious.org",
  "path": "/exchange-vwap/binance/eth_btc",
  "headers": {'Authorization': 'bearer token'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();
var req =  new XMLHttpRequest();
req.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(JSON.parse(this.responseText));
    }
};
req.open("GET", "https://api.coinscious.org/exchange-vwap/binance/eth_btc", true);
req.setRequestHeader("Authorization", "bearer token");
req.send();

The request returns JSON structured like the following:

[
  {
    "timestamp": 1515100800000,
    "vwap": 10.32
  },
  {
    "timestamp": 1515101100000,
    "vwap": 9.98
  }
]

Responses

Code Description
200 Successful response

Live Stream

Get real-time, millisecond level, market data updates by connecting to our WebSocket.

WebSocket /live

Heartbeat Message

Client needs to implement ping/pong as RFC6455 defines.
Furthermore, in order to keep it alive, client needs to send ping to the server every minute.

Trade History

Subscribe & Unsubscribe Message

{ subscribe: "trade", msg: {exchange: <exchange>, pair: <pair>} }

{ unsubscribe: "trade", msg: {exchange: <exchange>, pair: <pair>} }

Parameters

Name Required Type Description
exchange Yes string Exchanges supported
pair Yes string Token Pair supported
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

import java.util.concurrent.TimeUnit;

public class Example {

    public static void main(String[] args) {

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient httpClient = new OkHttpClient.Builder()
                .pingInterval(60, TimeUnit.SECONDS)
                .dispatcher(dispatcher)
                .build();

        Request request = new Request.Builder()
                .url("wss://livestream.coinscious.org/live")
                .addHeader("Authorization", "bearer " + token)
                .build();

        WebSocket webSocket = httpClient.newWebSocket(request, new WebSocketListener() {
            @Override
            public void onMessage(WebSocket webSocket, String text) {
                // TODO your code here
            }

            @Override
            public void onFailure(WebSocket webSocket, Throwable t, Response response) {
                // TODO your code here
            }

            @Override
            public void onClosing(WebSocket webSocket, int code, String reason) {
                // TODO your code here
            }
        });

        webSocket.send("{\"subscribe\":\"trade\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
    }

}
import websocket
try:
    import thread
except ImportError:
    import _thread as thread
import time

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("closed")

def on_open(ws):
    print("onopen")
    def run(*args):
        ws.send("{\"subscribe\":\"trade\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}")
        while True:
            time.sleep(1)
        ws.close()
    thread.start_new_thread(run, ())


if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp("wss://livestream.coinscious.org/live",
                              header = {"Authorization:Bearer token"},
                              on_message = on_message,
                              on_error = on_error,
                              on_close = on_close)
    ws.on_open = on_open
    ws.run_forever(ping_interval=60)
//composer require ratchet/pawl
<?php

    require __DIR__ . '/vendor/autoload.php';

    $loop = \React\EventLoop\Factory::create();
    $reactConnector = new \React\Socket\Connector($loop);

    $connector = new \Ratchet\Client\Connector($loop, $reactConnector);

    $connector('wss://livestream.coinscious.org/live', [], ['Authorization' => 'Bearer token'])
    ->then(function(Ratchet\Client\WebSocket $conn) {
        $conn->on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
            echo "Received: {$msg}\n";
            //$conn->close();
        });

        $conn->on('close', function($code = null, $reason = null) {
            echo "Connection closed ({$code} - {$reason})\n";
        });

        $conn->send("{\"subscribe\":\"trade\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
    }, function(\Exception $e) use ($loop) {
        echo "Could not connect: {$e->getMessage()}\n";
        $loop->stop();
    });

    $loop->run();

?>
const WebSocket = require('ws');

const ws = new WebSocket("wss://livestream.coinscious.org/live", {
        headers : {
          Authorization: "Bearer token"
        }
      });

ws.onopen = () => {
  console.log('connected');
  ws.send("{\"subscribe\":\"trade\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
  setInterval(
    () => ws.send('ping'),
    60000
  )
}

ws.onmessage = e => {
  console.log(e.data)
}

ws.onerror = error => {
  console.log(`WebSocket error: ${error}`)
}

ws.onclose = () => {
  console.log('disconnected');
}
var ws = new WebSocket("wss://livestream.coinscious.org/live?token=token");

ws.onopen = function() {
  console.log('connected');
  ws.send("{\"subscribe\":\"trade\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
  setInterval(
    () => ws.send('ping'),
    60000
  );
};

ws.onmessage = function (e) {
  console.log(e.data)
}

ws.onerror = function(error) {
  console.log(`WebSocket error: ${error}`)
}

ws.onclose = function() {
  console.log('disconnected');
}

Response

The response will have the following format:

{ site: <exchange>, currencyPair: <pair>, tradeTime: <timestamp>, price: <price>, amount: <amount>, originalId: <originalId>, isBuyMaker: <isBuyMaker> }

{
  site: binance,
  currencyPair: eth_btc,
  tradeTime: 1515100800000, 
  price: 6345.4545, 
  amount: 0.056, 
  originalId: 1278007, 
  isBuyMaker: true
}

Order Book

We support four modes of order book, they are full mode, orderbook5 mode, orderbook10 mode, and orderbook20 mode.

Subscribe & Unsubscribe Message

{ subscribe: <subscribe>, msg: {exchange: <exchange>, pair: <pair>} }

{ unsubscribe: <unsubscribe>, msg: {exchange: <exchange>, pair: <pair>} }

Parameters

Name Required Type Description
subscribe Yes string orderbook mode, value supported: orderbook, orderbook5, orderbook10, orderbook20
unsubscribe Yes string orderbook mode, value supported: orderbook, orderbook5, orderbook10, orderbook20
exchange Yes string Exchanges supported
pair Yes string Token Pair supported
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

import java.util.concurrent.TimeUnit;

public class Example {

    public static void main(String[] args) {

        Dispatcher dispatcher = new Dispatcher();
        OkHttpClient httpClient = new OkHttpClient.Builder()
                .pingInterval(60, TimeUnit.SECONDS)
                .dispatcher(dispatcher)
                .build();

        Request request = new Request.Builder()
                .url("wss://livestream.coinscious.org/live")
                .addHeader("Authorization", "bearer " + token)
                .build();

        WebSocket webSocket = httpClient.newWebSocket(request, new WebSocketListener() {
            @Override
            public void onMessage(WebSocket webSocket, String text) {
                // TODO your code here
            }

            @Override
            public void onFailure(WebSocket webSocket, Throwable t, Response response) {
                // TODO your code here
            }

            @Override
            public void onClosing(WebSocket webSocket, int code, String reason) {
                // TODO your code here
            }
        });

        webSocket.send("{\"subscribe\":\"orderbook\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
    }

}
import websocket
try:
    import thread
except ImportError:
    import _thread as thread
import time

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("closed")

def on_open(ws):
    print("onopen")
    def run(*args):
        ws.send("{\"subscribe\":\"orderbook\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}")
        while True:
            time.sleep(1)
        ws.close()
    thread.start_new_thread(run, ())


if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp("wss://livestream.coinscious.org/live",
                              header = {"Authorization:Bearer token"},
                              on_message = on_message,
                              on_error = on_error,
                              on_close = on_close)
    ws.on_open = on_open
    ws.run_forever(ping_interval=60)
//composer require ratchet/pawl
<?php

    require __DIR__ . '/vendor/autoload.php';

    $loop = \React\EventLoop\Factory::create();
    $reactConnector = new \React\Socket\Connector($loop);

    $connector = new \Ratchet\Client\Connector($loop, $reactConnector);

    $connector('wss://livestream.coinscious.org/live', [], ['Authorization' => 'Bearer token'])
    ->then(function(Ratchet\Client\WebSocket $conn) {
        $conn->on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
            echo "Received: {$msg}\n";
            //$conn->close();
        });

        $conn->on('close', function($code = null, $reason = null) {
            echo "Connection closed ({$code} - {$reason})\n";
        });

        $conn->send("{\"subscribe\":\"orderbook\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
    }, function(\Exception $e) use ($loop) {
        echo "Could not connect: {$e->getMessage()}\n";
        $loop->stop();
    });

    $loop->run();

?>
const WebSocket = require('ws');

const ws = new WebSocket("wss://livestream.coinscious.org/live", {
        headers : {
          Authorization: "Bearer token"
        }
      });

ws.onopen = () => {
  console.log('connected');
  ws.send("{\"subscribe\":\"orderbook\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
  setInterval(
    () => ws.send('ping'),
    60000
  )
}

ws.onmessage = e => {
  console.log(e.data)
}

ws.onerror = error => {
  console.log(`WebSocket error: ${error}`)
}

ws.onclose = () => {
  console.log('disconnected');
}
var ws = new WebSocket("wss://livestream.coinscious.org/live?token=token");

ws.onopen = function() {
  console.log('connected');
  ws.send("{\"subscribe\":\"orderbook\",\"msg\":{\"exchange\":\"binance\",\"pair\":\"btc_usdt\"}}");
  setInterval(
    () => ws.send('ping'),
    60000
  );
};

ws.onmessage = function (e) {
  console.log(e.data)
}

ws.onerror = function(error) {
  console.log(`WebSocket error: ${error}`)
}

ws.onclose = function() {
  console.log('disconnected');
}

Response

The response will have the following format:

{ site: <exchange>, currencyPair: <pair>, fetchTime: <timestamp>, asks:[ {price: <price>, amount: <amount>}, ... ], bids:[ {price: <price>, amount: <amount>}, ... ] }

{
  site: binance,
  currencyPair: eth_btc,
  fetchTime:1515100800000,
  asks:
    {price: 1.3456778, amount: 23.6},
    {price: 1.35, amount:20.67}
  ],
  bids:[
    {price: 1.345, amount: 23.6},
    {price: 1.35, amount:20.67}
  ]
}

Error Codes

Coinscious Data Services - Market Data API uses the following error codes:

Error Code Meaning
1001 Exchange not specified.
1002 Exchange not supported.
1003 Pair not specified.
1004 Pair not supported.
1005 Token not specified.
1006 Token not supported.
1007 Fiat currency not supported.
1008 Interval not supported.
1009 Limit exceeds max limit supported.
1010 Invalid data range.
1011 Date range less than interval.
4001 Invalid WebSocket command.