bilalq / iex-api

Unofficial SDK for using the IEX API
MIT License
42 stars 13 forks source link

iex-api

Currently still a work-in-progress, but it should already be quite usable.

An unofficial SDK for using the free IEX API. You can use this to get stock market information. This module is usable in Web Browsers, React Native, and NodeJS (though a polyfill/ponyfill for the fetch API is needed in NodeJS).

Features

Installation

npm install --save iex-api

Usage

In Web Browsers and React Native

import { IEXClient } from 'iex-api'

const iex = new IEXClient(fetch)
iex.stockCompany('AAPL')
  .then(company => console.log(company))

  // {
  //   symbol: "AAPL",
  //   companyName: "Apple Inc.",
  //   exchange: "Nasdaq Global Select",
  //   industry: "Computer Hardware",
  //   website: "http://www.apple.com",
  //   description: "Apple Inc is designs, manufactures and markets mobile communication and media devices and personal computers, and sells a variety of related software, services, accessories, networking solutions and third-party digital content and applications.",
  //   CEO: "Timothy D. Cook",
  //   issueType: "cs",
  //   sector: "Technology"
  // }

In NodeJS

To use this in NodeJS and any other JS runtime that doesn't provide the fetch API, you will have to provide it through a polyfill or ponyfill. I recommend using fetch-ponyfill for this purpose, since it doesn't mess with the global context. You may find isomorphic-fetch easier to use, however.

npm install --save isomorphic-fetch
npm install --save-dev @types/isomorphic-fetch # If using TypeScript
import { IEXClient } from 'iex-api'
import * as _fetch from 'isomorphic-fetch'

const iex = new IEXClient(_fetch)
iex.stockCompany('AAPL')
  .then(company => console.log(company))

  // {
  //   symbol: "AAPL",
  //   companyName: "Apple Inc.",
  //   exchange: "Nasdaq Global Select",
  //   industry: "Computer Hardware",
  //   website: "http://www.apple.com",
  //   description: "Apple Inc is designs, manufactures and markets mobile communication and media devices and personal computers, and sells a variety of related software, services, accessories, networking solutions and third-party digital content and applications.",
  //   CEO: "Timothy D. Cook",
  //   issueType: "cs",
  //   sector: "Technology"
  // }

To Do: