JSON RPC
Stock Data - JSON RPC
Introduction
Our stock 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/stocks
or/v1/prices/AAPL
) in themethod
property of the JSON-RPC, you can access all of our stock 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 Stock 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 stock data using JSON-RPC, you need to use following URL:
Enviroment | Encryption | Value |
---|---|---|
Production | Yes | https://api-historical.stock.finfeedapi.com/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.
Request Format
All requests should follow this format:
{
"jsonrpc": "2.0",
"method": "v1/methodName",
"params": [...],
"id": null
}
Examples
Here are a few examples demonstrating how the Stock Data API is accessed through JSON-RPC, along with their corresponding responses.
Get stocks
Request
https://api-realtime.stock.finfeedapi.com/jsonrpc?apikey=YOUR-API-KEY
{
"jsonrpc": "2.0",
"method": "v1/getStocks",
"params": [],
"id": null
}
Response
{
"jsonrpc": "2.0",
"result": [
{
"stock_id": "AAPL",
"name": "Apple Inc.",
"type": "equity",
"price_usd": 186.42,
"id_icon": "4caf2b16-a017-4e26-a348-2cea69c34cba",
"exchange": "NASDAQ"
},
//other result entries
],
"id": "my-tracking-id-001"
}
Get AAPL historical prices
Request
https://api-historical.stock.finfeedapi.com/jsonrpc/apikey-YOUR-API-KEY
{
"jsonrpc": "2.0",
"method": "v1/getHistoricalPrices",
"params": [
{"stock_id": "AAPL"},
{"period_id": "1DAY"},
{"time_start": "2025-01-24T00:00:00"},
{"time_end": "2025-01-30T00:00:00"}
],
"id": null
}
Response
{
"jsonrpc": "2.0",
"result": [
{
"time_period_start": "2025-01-24T00:00:00.0000000Z",
"time_period_end": "2025-01-25T00:00:00.0000000Z",
"time_open": "2025-01-24T09:30:00.0000000Z",
"time_close": "2025-01-24T16:00:00.0000000Z",
"price_open": 185.42,
"price_high": 187.63,
"price_low": 184.21,
"price_close": 186.42,
"volume": 2456789
},
//other result entries
],
"id": "my-tracking-id-001"
}
Get Current Price
Request
https://api-realtime.stock.finfeedapi.com/jsonrpc/apikey-YOUR-API-KEY
{
"jsonrpc": "2.0",
"method": "v1/getCurrentPrice",
"params": [
{"stock_id": "AAPL"}
],
"id": null
}
Response
{
"jsonrpc": "2.0",
"result": {
"time": "2025-01-30T11:18:06.2000000Z",
"stock_id": "AAPL",
"price": 189.74,
"volume": 1234567
},
//other result entries
}
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"
}
}