Skip to main content

JSON RPC

Market Data - JSON RPC

Introduction

Our market data API provides versatile access through JSON-RPC, and our REST endpoints are fully compatible with it, offering flexibility for developers.

  • By specifying resource paths (such as /v1/exchanges or /v1/exchangerates/BTC) in the method property of the JSON-RPC, you can access all of our market data resources.

  • Additionally, the params property allows for the inclusion of query parameters.

JSON-RPC

JSON-RPC is a lightweight remote procedure call protocol encoded in JSON. It allows for efficient and straightforward communication between a client and a server over various transport protocols.

JSON-RPC is widely used in web services and APIs due to its simplicity and ease of use.

JSON-RPC 2.0 Standard

Before diving into the details of using JSON-RPC with the Market Data API, it's important to understand the JSON-RPC standard. You can find detailed information about the JSON-RPC specification on the official JSON-RPC website.

Endpoint

To access market data using JSON-RPC, you need to use following URL:

EnviromentEncryptionValue
ProductionYeshttps://rest.coinapi.io/jsonrpc

Authentication

If you want to learn how to authenticate to this API, you can find detailed instructions and guidance in authentication section of this documentation.

Examples

Here are a few examples demonstrating how the Market Data API is accessed through JSON-RPC, along with their corresponding responses.

Get exchanges

Request

https://rest.coinapi.io/jsonrpc?apikey=YOUR-API-KEY

{
"jsonrpc": "2.0",
"method": "v1/exchanges",
"params": [],
"id": "my-tracking-id-001"
}

Response

{
"jsonrpc": "2.0",
"result": [
{
"exchange_id": "BINANCE",
"website": "https://www.binance.com/",
"name": "Binance",
"data_quote_start": "2017-12-18T00:00:00.0000000Z",
"data_quote_end": "2023-10-29T00:00:00.0000000Z",
"data_orderbook_start": "2017-12-18T21:50:58.3910192Z",
"data_orderbook_end": "2023-07-07T00:00:00.0000000Z",
"data_trade_start": "2017-07-14T00:00:00.0000000Z",
"data_trade_end": "2023-10-30T00:00:00.0000000Z",
"data_symbols_count": 2349,
"volume_1hrs_usd": 484530018.57,
"volume_1day_usd": 7696242910.91,
"volume_1mth_usd": 227749609430.91
},
//other result entries
],
"id": "my-tracking-id-001"
}

Get BTC exchange rates

Request

https://rest.coinapi.io/jsonrpc/apikey-YOUR-API-KEY

{
"jsonrpc": "2.0",
"method": "v1/exchangerate/BTC",
"params": [],
"id": "my-tracking-id-001"
}

Response

{
"jsonrpc": "2.0",
"result": {
"asset_id_base": "BTC",
"rates": [
{
"time": "2023-10-31T09:19:36.0000000Z",
"asset_id_quote": "USDC",
"rate": 34393.502957271553532525456547
},
//other result entries
]
},
"id": "my-tracking-id-001"
}

Get symbols (filtered)

Request

https://rest.coinapi.io/jsonrpc/apikey-YOUR-API-KEY

{
"jsonrpc": "2.0",
"method": "v1/symbols",
"params": [{"exchange_id" : "BITSTAMP" }, {"filter_symbol_id" : "BITSTAMP_"}, {"filter_asset_id" : "XRP"}],
"id": "my-tracking-id-001"
}

Response

{
"jsonrpc": "2.0",
"result": [
{
"symbol_id": "BITSTAMP_SPOT_XRP_EUR",
"exchange_id": "BITSTAMP",
"symbol_type": "SPOT",
"asset_id_base": "XRP",
"asset_id_quote": "EUR",
"data_start": "2017-01-25",
"data_end": "2023-10-30",
"data_quote_start": "2017-01-26T00:00:00.0000000Z",
"data_quote_end": "2023-10-29T00:00:00.0000000Z",
"data_orderbook_start": "2017-01-25T19:41:55.0000000Z",
"data_orderbook_end": "2023-07-06T00:00:00.0000000Z",
"data_trade_start": "2017-01-25T00:00:00.0000000Z",
"data_trade_end": "2023-10-30T00:00:00.0000000Z",
"volume_1hrs": 8781306.97576001,
"volume_1hrs_usd": 5031705.13,
"volume_1day": 35365544.1431782,
"volume_1day_usd": 20264522.16,
"volume_1mth": 929524888.659593,
"volume_1mth_usd": 532619479.27,
"price": 0.538365,
"symbol_id_exchange": "XRPEUR",
"asset_id_base_exchange": "XRP",
"asset_id_quote_exchange": "EUR",
"price_precision": 0.000010000,
"size_precision": 0.000000010
},
//other result entries
],
"id": "my-tracking-id-001"
}

Error Responses

  • An incorrectly defined request may result in the following error response:

    {
    "jsonrpc": "2.0",
    "id": "my-tracking-id-001"
    "error": {
    "code": 400,
    "message": "Bad request (failed to parse json rpc)"
    }
    }
  • If a resource is not found, you can expect the following error response:

    {
    "jsonrpc": "2.0",
    "id": "my-tracking-id-001"
    "error": {
    "code": 404,
    "message": "Resource not found"
    }
    }