NAV
json

Blocksize Connect API

Welcome to the documentation of Blocksize Connect's API! Here is the right place for you to find out how you get the high-fidelity crypto asset data from our API.

If you have any questions, feel free to reach out to the Blocksize Connect Support.

Introduction

This websocket API provides access to the data of the Blocksize Connect product via JSON-RPC over Websockets. The API provides real-time trading data of volume-weighted average prices (VWAP) for a growing number of cryptocurrency assets. The data streams are collected from more than 10 centralized and decentralized exchanges.

Endpoints

Production

Websockets: wss://data.blocksize.capital/marketdata/v1/ws

HTTP: https://data.blocksize.capital/marketdata/v1/api

JSON-RPC

JSON-RPC is a light-weight remote procedure call (RPC) protocol. This API implements the JSON-RPC specification over Websockets and HTTP. All messages that are exchanged between client and server are in JSON format.

Requests

Request

{
  "jsonrpc": "2.0",
  "id": 6712,
  "method": "servicename_methodname",
  "params": {
    "parameter_1": 42,
    "parameter_2": "string"
  }
}

Every JSON-RPC request must be a JSON object with the following fields:

Field Type Description
jsonrpc string Must be set to 2.0.
method string Must be a valid method name as highlighted by this documentation.
id string or int Can be any identifier set by the client to map requests->responses.
params object A structured value of arguments the method expects. Can be omitted if the method accepts no arguments.

Responses

Response (OK)

{
  "jsonrpc": "2.0",
  "id": 6712,
  "result": {
    "result_parameter": "string"
  }
}

Response (Error)

{
  "jsonrpc": "2.0",
  "id": 6712,
  "error": {
    "code": -32602,
    "message": "invalid params"
  }
}

Every JSON-RPC response must be a JSON object with the following fields:

Field Type Description
jsonrpc string Must be set to 2.0.
id string or int The identifier as set by the client. If no ID was specified or can otherwise not be parsed, id will be null
result object If the method call was successful, this field will contain a structured value as highlighted in this documentation.
error object If an error occurred during the method call, the error field will be present and will an object containing information on the error.
› code int Code indicated the type of the error that occurred. Only use this code when comparing errors, as codes are part of the API. See the Errors section for more details
› message string A short error message describing the error. Do not compare or parse the message, it is not part of the API.
› data string A longer description of the error wherever applicable. Can be omitted. Do not compare or parse data, it is not part of the API.

Notifications

Notification Message

{
  "jsonrpc": "2.0",
  "method": "servicename_subscription",
  "params": {
    "datapoint_1": 23.78,
    "datapoint_2": "data"
  }
}

A notification is a request message without an "id" field. Notifications will be sent by the server to the client after a successful confirmation. The client must not confirm the receipt of notifications.

Field Type Description
jsonrpc string Must be set to 2.0.
method string Must be a valid method name as highlighted by this documentation.
params object A structured value of method arguments as highlighted by this documentation.

JSON-RPC over HTTP

curl --request POST 'https://data.blocksize.capital/marketdata/v1/api' \
--header 'Content-Type: application/json' \
--header 'X-API-Key: Xavv9doDyT8NzX45XXclNqi26PRyaaVxWhbXciazVerZwy8Kz1uXGf54oC93h0UwcUzw458ebh4a4Iz2' \
--data-raw '{
  "jsonrpc": "2.0",
  "id": 6712,
  "method": "servicename_methodname",
  "params": {
    "parameter_1": 42,
    "parameter_2": "string"
  }
}'

The above command returns JSON structured like this:

{
  "jsonrpc": "2.0",
  "id": 6712,
  "result": {
    "result_parameter": "string"
  }
}

Some of the unary API methods are also available via JSON-RPC over HTTP. If a method supports this calling method its section will have a hint.

When using JSON-RPC over HTTP, the request and response structure will stay the same as documented.

This API only supports JSON-RPC over HTTP using POST requests. The Content-Type needs to be of type application/json.

If the method being called requires authentication, authentication headers need to be added:

The HTTP response code will always be 200, even if an error occurred.

Time

time_now

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "time_now"
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "timestamp": 1644195661
  }
}

This method can be used to get the current time of the server or to test if the connection is still alive.

Parameters

Field Required Type Description

Response

Field Type Description
timestamp int64 The server time in seconds (Unix).

Authentication

The Authentication service allows to authenticate a session.

authentication_logon

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "authentication_logon",
  "params": {
    "api_key": "",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "user_id": "OjSYjQdxBC"
  }
}

This method authenticates the current session.

This is a prerequisite for many of the other methods.

Parameters

Field Required Type Description
api_key false string Your generated API key
token false string An optional API Token

Response

Field Type Description
user_id string If authentication was successful, this will contain the user ID of the logged in user.

authentication_logoff

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "authentication_logoff"
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "user_id": ""
  }
}

This method logs the user out of the current session.

Logging off won't clear the current subscriptions, they will just be paused. Logging in again will resume all subscriptions.'.

Parameters

Field Required Type Description

Response

Field Type Description
user_id string If the logout was successful this field will be empty.

Vwap

vwap_subscribe

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "vwap_subscribe",
  "params": {
    "tickers": [
      "BTCEUR",
      "ETHEUR"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "snapshot": [
      {
        "ticker": "ETHEUR",
        "price": 2398.6491068570076,
        "size": 1238.9841055992033,
        "volume": 32265.21,
        "ts": 1662492937000
      },
      {
        "ticker": "BTCEUR",
        "price": 34745.13362675458,
        "size": 0.13582984000000048,
        "volume": 4719.42594130071,
        "ts": 1662492937000
      }
    ]
  }
}

Notifications

{
  "jsonrpc": "2.0",
  "method": "vwap",
  "params": {
    "updates": [
      {
        "ticker": "BTCEUR",
        "price": 34748.12924828815,
        "size": 0.006374660000000493,
        "volume": 221.50750959390967,
        "ts": 1662492940000
      }
    ]
  }
}
{
  "jsonrpc": "2.0",
  "method": "vwap",
  "params": {
    "updates": [
      {
        "ticker": "ETHEUR",
        "price": 2400.209999999564,
        "size": 0.06804130000001375,
        "volume": 163.31340867300332,
        "ts": 1662492940000
      }
    ]
  }
}

This method subscribes to one or multiple instruments.

The server will respond to a subscription with a response containing the latest known prices for all successful pairs.

After a successful subscription, notification messages will be sent by the server to the client with the method vwap

Updates will be sent in 250 millisecond batches. Updates will only be sent when the price of an asset has changed.

Parameters

Field Required Type Description
tickers false []string A list of tickers

Response

Field Type Description
snapshot []object This will contain a list of the latest prices for all the requested tickers
› ticker string The ticker of instrument
› price float64 The VWAP of instrument
› size float64 Total size
› volume float64 Total volume
› ts int64 Timestamp of VWAP in milliseconds. Indicates last timestamp (exchange provided) of the last trade used for calculation

Notifications

Field Required Type Description
updates false []object This will contain price updates for one or multiple pairs the session is subscribed to
› ticker false string The ticker of instrument
› price false float64 The VWAP of instrument
› size false float64 Total size
› volume false float64 Total volume
› ts false int64 Timestamp of VWAP in milliseconds. Indicates last timestamp (exchange provided) of the last trade used for calculation

vwap_unsubscribe

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "vwap_unsubscribe",
  "params": {
    "tickers": [
      "BTCEUR"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {}
}

This method unsubscribes from one or multiple instruments.

After a successful unsubscription, no more notifications will be sent for the instruments.

Parameters

Field Required Type Description
tickers false []string A list of tickers

Response

Field Type Description

Fixed Vwap

fixedvwap_subscribe

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "fixedvwap_subscribe",
  "params": {
    "tickers": [
      "BTCEUR",
      "ETHEUR"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "snapshot": [
      {
        "ticker": "ETHEUR",
        "price": 2398.6491068570076,
        "size": 1238.9841055992033,
        "volume": 32265.21,
        "ts": 1662336000000
      },
      {
        "ticker": "BTCEUR",
        "price": 34745.13362675458,
        "size": 0.13582984000000048,
        "volume": 4719.42594130071,
        "ts": 1662336000000
      }
    ]
  }
}

Notifications

{
  "jsonrpc": "2.0",
  "method": "fixedvwap",
  "params": {
    "updates": [
      {
        "ticker": "BTCEUR",
        "price": 34748.12924828815,
        "size": 0.006374660000000493,
        "volume": 221.50750959390967,
        "ts": 1662422400000
      }
    ]
  }
}
{
  "jsonrpc": "2.0",
  "method": "fixedvwap",
  "params": {
    "updates": [
      {
        "ticker": "ETHEUR",
        "price": 2400.209999999564,
        "size": 0.06804130000001375,
        "volume": 163.31340867300332,
        "ts": 1662422400000
      }
    ]
  }
}

This method subscribes for fixed window VWAP (currently only 24h) to one or multiple instruments.

The server will respond to a subscription with a response containing the latest known prices for all successful pairs.

After a successful subscription, notification messages will be sent by the server to the client with the method fixedvwapUpdates will be sent every midnight UTC.

Parameters

Field Required Type Description
tickers false []string A list of tickers

Response

Field Type Description
snapshot []object This will contain a list of the latest prices for all the requested tickers
› ticker string The ticker of instrument
› price float64 The VWAP of instrument
› size float64 Total size
› volume float64 Total volume
› ts int64 Timestamp of VWAP in milliseconds. Indicates last timestamp (exchange provided) of the last trade used for calculation

Notifications

Field Required Type Description
updates false []object This will contain price updates for one or multiple pairs the session is subscribed to
› ticker false string The ticker of instrument
› price false float64 The VWAP of instrument
› size false float64 Total size
› volume false float64 Total volume
› ts false int64 Timestamp of VWAP in milliseconds. Indicates last timestamp (exchange provided) of the last trade used for calculation

fixedvwap_unsubscribe

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "fixedvwap_unsubscribe",
  "params": {
    "tickers": [
      "BTCEUR"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {}
}

This method unsubscribes from one or multiple instruments.

After a successful unsubscription, no more notifications will be sent for the instruments.

Parameters

Field Required Type Description
tickers false []string A list of tickers

Response

Field Type Description

Trades

trade_subscribe

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "trade_subscribe",
  "params": {
    "tickers": [
      "WETHUSDT",
      "WETHUSDC"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {}
}

Notifications

{
  "jsonrpc": "2.0",
  "method": "trade",
  "params": {
    "trades": [
      {
        "timestamp": 1653413274,
        "ticker": "WETHUSDC",
        "price": 1936.560945696583,
        "size": 34.84534949284921,
        "exchange": "UNISWAPV3_ETHEREUM",
        "base": "WETH",
        "quote": "USDC"
      },
      {
        "timestamp": 1653413274,
        "ticker": "WETHUSDC",
        "price": 1938.399952607055,
        "size": 13.92915344931057,
        "exchange": "UNISWAPV3_ETHEREUM",
        "base": "WETH",
        "quote": "USDC"
      }
    ]
  }
}
{
  "jsonrpc": "2.0",
  "method": "trade",
  "params": {
    "trades": [
      {
        "timestamp": 1653413275,
        "ticker": "WETHUSDC",
        "price": 1941.097139713692,
        "size": 1.593544492294829,
        "exchange": "UNISWAPV2_ETHEREUM",
        "base": "WETH",
        "quote": "USDC"
      },
      {
        "timestamp": 1653413275,
        "ticker": "WETHUSDC",
        "price": 1941.097139713692,
        "size": 1.593544492294829,
        "exchange": "UNISWAPV2_ETHEREUM",
        "base": "WETH",
        "quote": "USDC"
      },
      {
        "timestamp": 1653413275,
        "ticker": "WETHUSDT",
        "price": 1947.47485439373,
        "size": 0.08029212631280865,
        "exchange": "UNISWAPV2_ETHEREUM",
        "base": "WETH",
        "quote": "USDT"
      },
      {
        "timestamp": 1653413275,
        "ticker": "WETHUSDT",
        "price": 1947.47485439373,
        "size": 0.08029212631280865,
        "exchange": "UNISWAPV2_ETHEREUM",
        "base": "WETH",
        "quote": "USDT"
      }
    ]
  }
}

This method subscribes to the trades one or multiple instruments.

The server will respond always respond with an empty response.

After a successful subscription, notification messages will be sent by the server to the client with the method trade

Update notifications will be send in 250 millisecond batches. Updates will only be sent if a trade occurred.

To subscribe to all trades, use a special wildcard ticker *:

{ "jsonrpc": "2.0", "id": 0, "method": "trade_subscribe", "params": { "tickers": [ "*" ] } }

Parameters

Field Required Type Description
tickers false []string A list of tickers

Response

Field Type Description

Notifications

Field Required Type Description
trades false []object A batched list of trade events
› timestamp false int64 The Unix timestamp of the trade in milliseconds.
› ticker false string The ticker of the instrument that was traded.
› price false float64 The price the instrument was traded at, denoted in the Quote currency.
› size false float64 The size of the trade, denoted in the Base currency.
› exchange false string The name of the exchange the trade occurred at.
› base false string The ticker of the base currency.
› quote false string The ticker of the quote currency.

trade_unsubscribe

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "trade_unsubscribe",
  "params": {
    "tickers": [
      "BTCEUR"
    ]
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {}
}

This method unsubscribes from one or multiple instruments.

After a successful unsubscription, no more notifications will be sent for the instruments.

If subscribed using the wildcard character *, the unsubscription has to be done with the same.

Parameters

Field Required Type Description
tickers false []string A list of tickers

Response

Field Type Description

Instruments

The Instruments service allows to get/list all available instruments.

instruments_list

Request

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "instruments_list"
}

Response

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "instruments": [
      {
        "ticker": "BTCEUR",
        "base_currency": "BTC",
        "quote_currency": "EUR"
      },
      {
        "ticker": "ETHEUR",
        "base_currency": "ETH",
        "quote_currency": "EUR"
      }
    ]
  }
}

This method returns all available pairs.

Parameters

Field Required Type Description

Response

Field Type Description
instruments []object A list of all pairs that can be subscribed to
› ticker string The instrument's ticker
› base_currency string The instrument's base currency
› quote_currency string The instrument's quote currency

Errors

If a request is unsuccessful, a response containing an error object will be returned. See Responses for more details.

The following errors can be returned by this API:

Error Code Short Message Description
-32601 method not found The requested method or service could not be found
-32602 invalid params The requested method expects a different parameter format
-32603 internal error An unknown error occurred
-32700 parse error An invalid JSON message was received
4000 unauthenticated A method that required authentication was called from an unauthenticated session
4001 invalid API key The API key that was tried to authenticate with was invalid
4002 invalid API token The API token that was tried to authenticate with was invalid
4003 payment required An active subscription is required before using the API