🔗 JSON-RPC API
JSON-RPC proxy for Exchange Rates REST endpoints.
Exchange Rates - JSON RPC
Overview
Our JSON-RPC implementation is a thin proxy around the Exchange Rates REST API. It does not introduce a separate RPC-specific domain model or extra business logic.
methodis the REST path, for examplev1/assetsorv1/exchangerate/{asset_id_base}/{asset_id_quote}/historyparamsis converted into REST path parameters and query string parameters- Keys used in path placeholders are substituted into the path
- Remaining keys are forwarded as standard query string parameters
This means JSON-RPC is just another way to call the same read-only REST resources.
Endpoint
To access Exchange Rates through JSON-RPC, use:
| Environment | Encryption | Value |
|---|---|---|
| Production | Yes | https://api-realtime.exrates.coinapi.io/jsonrpc |
| Production | Yes | https://api-historical.exrates.coinapi.io/jsonrpc |
Authentication
Authentication is exactly the same as for the REST API. See the authentication section.
Request Format
Use a JSON-RPC 2.0 request where method contains the REST path and params is an object:
{
"jsonrpc": "2.0",
"method": "v1/exchangerate/{asset_id_base}/{asset_id_quote}/history",
"params": {
"asset_id_base": "BTC",
"asset_id_quote": "USD",
"period_id": "1HRS",
"time_start": "2025-01-24T00:00:00Z",
"time_end": "2025-01-24T01:00:00Z"
},
"id": "my-tracking-id-001"
}The request above is proxied to:
GET /v1/exchangerate/BTC/USD/history?period_id=1HRS&time_start=2025-01-24T00:00:00Z&time_end=2025-01-24T01:00:00ZAPI Design Mapping
- Metadata endpoints such as
v1/assetsandv1/assets/{asset_id} - Realtime rate endpoints such as
v1/exchangerate/{asset_id_base}andv1/exchangerate/{asset_id_base}/{asset_id_quote} - Historical timeseries endpoints such as
v1/exchangerate/{asset_id_base}/{asset_id_quote}/history - Supporting endpoints such as
v1/exchangerate/history/periods
Examples
List all assets
Request
https://api-realtime.exrates.coinapi.io/jsonrpc?apikey=YOUR-API-KEY
{
"jsonrpc": "2.0",
"method": "v1/assets",
"params": {},
"id": "my-tracking-id-001"
}Proxied REST request:
GET /v1/assetsGet the current BTC/USD rate
Request
https://api-realtime.exrates.coinapi.io/jsonrpc?apikey=YOUR-API-KEY
{
"jsonrpc": "2.0",
"method": "v1/exchangerate/{asset_id_base}/{asset_id_quote}",
"params": {
"asset_id_base": "BTC",
"asset_id_quote": "USD"
},
"id": "my-tracking-id-001"
}Proxied REST request:
GET /v1/exchangerate/BTC/USDGet historical BTC/USD timeseries
Request
https://api-historical.exrates.coinapi.io/jsonrpc?apikey=YOUR-API-KEY
{
"jsonrpc": "2.0",
"method": "v1/exchangerate/{asset_id_base}/{asset_id_quote}/history",
"params": {
"asset_id_base": "BTC",
"asset_id_quote": "USD",
"period_id": "1HRS",
"time_start": "2025-01-24T00:00:00Z",
"time_end": "2025-01-24T01:00:00Z"
},
"id": "my-tracking-id-001"
}Proxied REST request:
GET /v1/exchangerate/BTC/USD/history?period_id=1HRS&time_start=2025-01-24T00:00:00Z&time_end=2025-01-24T01:00:00ZResponses and Errors
Successful JSON-RPC responses return the underlying REST payload in the result field.
If the proxied REST request fails, the error is returned as a JSON-RPC error object.
{
"jsonrpc": "2.0",
"result": {},
"id": "my-tracking-id-001"
}