Querying Data with iex.js#
Use the iexjs library queryDataset
method to search any IEX Cloud dataset you have a token for.
Prerequisite
IEX Cloud account - Create one here.
Example: Searching a Dataset#
Once you’ve installed the iexjs package, instantiate a Client
(passing in your API token and API version in place of TOKEN
and VERSION
below) and call queryDataset
with the key
(primary index), workspace, and dataset of the equity you want data for.
For example, if you want Apple cash flow records, pass in the Apple symbol AAPL
for the key
, core
for the workspace, and CASH_FLOW
for the dataset.
const {Client} = require("@apperate/iexjs")
const client = new Client({api_token: "TOKEN", version: "VERSION"});
client.apperate.queryData({key: "AAPL", workspace: "core", id: "CASH_FLOW"}).then((res) => {
console.log(res);
});
Like all IEX Cloud Financial datasets, the CASH_FLOW
dataset is in the core
workspace. The CASH_FLOW
dataset’s key
property is symbol
.
A dataset’s API doc shows the key
, subkey
(if any), and date
properties. For example, the image below highlights the CASH_FLOW
dataset’s key
and date
indexes in the https://iexcloud.io/docs/core/CASH_FLOW page’s Response Attributes section.
Tip
An endpoint reference page’s Path Parameters section indicates the data’s key index and subkey index (if it has any).
You can fine-tune your search by specifying additional GET /data query parameters.
For example, you can limit results to a particular time range using the from
and to
query parameters.
client.apperate.queryData({
key: "AAPL", workspace: "core", id: "CASH_FLOW",
from: "2019-01-01", to: "2019-07-01"}).then((res) => {
console.log(res);
});
It’s that easy to query IEX Cloud Data from your JavaScript apps!
What’s Next#
Paginate with Chunks of Data using apperate.queryData()
in JavaScript or using the GET /data REST endpoint directly. Pagination and handling large amounts of data has never been easier.
iexjs library introduces the client library and methods it offers for querying data.