node-iex-cloud
Version:
SDK for iex cloud
207 lines (161 loc) • 4.83 kB
Markdown
# node-iex-cloud
See IEX API [Documentation](https://iexcloud.io/docs/api) for more information.
## Installation and Usage
```bash
npm i node-iex-cloud
```
ES6+
```javascript
import { IEXCloudClient } from "node-iex-cloud";
// import promise base library
import fetch from "node-fetch";
```
common.js
```javascript
const { IEXCloudClient } = require("node-iex-cloud");
// import promise base library
const fetch = require("node-fetch");
```
## Configuration and Setup
IEX Cloud uses a message weighting system to measure usage in message counts, make sure sandbox is enabled to `true` in development to avoid reaching data limits or overages. (Note: when enabling sandbox to true, the publishable key token is automatically prefixed with the letter T and doesn't require changing the existing token to access Test Data ) MAKE SURE PUBLIC KEY & NOT PRIVATE KEY IS BEING USED as it is prefixed with: `"pk_"`
```javascript
const iex = new IEX(fetch, {
sandbox: true,
publishable: "pk_21b4ffeccc6e3cnc1df07467a47231c6",
version: "stable"
});
```
## Examples
The first method takes in a company symbol (an abbreviation used to uniquely identify publicly traded shares). The subequent method retreive the specfic IEX data type.
### Stocks
```javascript
iex
// stock/google/financials?period=annual
.symbol("googl")
.financials("quarterly")
.then(res => console.log(res));
```
```javascript
// stock/googl/ceo-compensation
iex
.symbol("googl")
.ceoCompensation()
.then(res => console.log(res));
```
```javascript
// Query Charts
iex
.symbol("googl")
.chart("dynamic", { chartCloseOnly: true })
.then(res => console.log(res));
iex
.symbol("aapl")
.chart("6m", { chartCloseOnly: true, chartSimplify: true, chartInterval: 2 })
.then(res => console.log(res));
```
### Available Methods
- [x] `balanceSheet(period?)`
- [x] `book`
- [x] `chart(range?: string, params?: object)`
- [x] `cashFlow(period?: string, last?: number)`
- [x] `ceoCompensation`
- [x] `company`
- [x] `delayedQuote`
- [x] `dividends(range?)`
- [x] `earnings(last, field)`
- [x] `estimates`
- [x] `financials(period?: string)`
- [x] `news(last?: number)`
- [x] `fundOwnership`
- [x] `income(period?: string, last?: number)`
- [x] `insiderRoster`
- [x] `insiderSummary`
- [x] `insiderTransactions`
- [x] `institutionalOwnership`
- [x] `intradayPrices(params?: object)`
- [x] `logo`
- [x] `largestTrades`
- [x] `options(expiration?: string, optionSide?: string)`
- [x] `peers`
- [x] `previous`
- [x] `price`
- [x] `priceTarget`
- [x] `ohlc`
- [x] `sentiment(type?: string, date?: string)`
- [x] `quote(field: string)`
- [x] `recommendationTrends`
- [x] `stats(stat?: string)`
- [x] `splits(range)`
- [x] `shortInterest(date?: string)`
- [x] `volumeByVenue`
### Market
```javascript
// stock/market/today-earnings
iex.market("today-earnings").then(res => console.log(res));
```
### Data Points
Data points are available per symbol and return individual plain text values.
```javascript
// data-points/aapl/quote-latestprice
iex
.symbol("aapl")
.dataPoints("quote-latestprice")
.then(res => console.log(res));
```
### Batch Symbols
Use method `symbols` instead of `"symbol"` to batch multiple stock symbols together, IEX allows only up to `10` symbols to be made per request.
```javascript
// batch?symbols=googl,amzn,fb&types=company
iex
.symbols("googl,amzn,fb")
.company()
.then(res => console.log(res));
```
```javascript
// batch?symbols=googl,amzn,fb&types=price
iex
.symbols("googl,amzn,fb,aapl")
.price()
.then(res => console.log(res));
```
### Batch Types
Use the method `batch` to batch Request of multiple data types, all IEX types are supported. IEX allows only up to `10` types to be made per request.
```javascript
iex
// stock/googl/batch?types=stock,company,balance-sheet,cash-flow,estimates
.symbol("googl")
.batch("company", "balance-sheet", "cash-flow", "estimates")
.then(res => console.log(res));
```
### Batch Symbols & Types
```javascript
//batch?symbols=googl,amzn,fb,aapl&types=company,balance-sheet,cash-flow,estimates
iex
.symbols("googl,amzn,fb,aapl")
.batch("company", "balance-sheet", "cash-flow", "estimates")
.then(res => console.log(res));
```
### IEX Last
Last provides trade data for executions on IEX.
```javascript
// tops/last?symbols=aapl,googl,amzn
iex.tops("aapl", "googl", "amzn").then(res => console.log(res));
```
### IEX Historical Stats
```javascript
// stats/intraday
iex.historicalStats("intraday").then(res => console.log(res));
```
### IEX Deep
DEEP is used to receive real-time depth of book quotations direct from IEX.
```javascript
// deep/trading-status?symbols=msft
iex
.symbol("msft")
.deep("trading-status")
.then(res => console.log(res));
```
### SSE Streaming
Not Yet Supported
### Web Sockets
Coming Soon