Giter Club home page Giter Club logo

iexjs's Introduction

🚨 This library is no longer actively maintained 🚨

JavaScript interface to IEX Cloud

Build Status License npm

Install

Install from npm

npm install --save iexjs

iexjs can run in the browser via native fetch and eventsource, or from node via cross-fetch and eventsource.

Overview

iexjs supports the IEX Cloud api through 2 interfaces. The first is a simple function call, passing in the api version and token as arguments

const {chart} = require("iexjs");
chart({symbol: "AAPL", range: "1m"}, {token, version}).then((res) => {
    console.log(res);
});

Since the token rarely changes, we have a Client object for convenience:

const {Client} = require("iexjs");
const client = new Client({api_token: "YOUR_TOKEN_HERE", version: "v1"});
client.chart({symbol: "AAPL", range: "1m"}).then((res) => {
    console.log(res);
});

The client will automatically pick up the API key from the environment variable IEX_TOKEN, or it can be passed as an argument. To use the IEX Cloud test environment, simple set version: 'sandbox'.

Full API

iexjs provides wrappers around both static and SSE streaming data. Implemented methods are provided in CATALOG.md.

License

This software is licensed under the Apache 2.0 license. See the LICENSE and AUTHORS files for details.

iexjs's People

Contributors

aelliott1485 avatar dependabot[bot] avatar timkpaine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

iexjs's Issues

ERROR Error: API Token missing or not in environment (IEX_TOKEN)

Hi,

Thanks for the library, using it in our React Native app,

we have an issue when using the library this way:

    const client = new Client({
      token: 'sandbox publishable token here',
      version: 'sandbox',
    });

    client.cryptoQuotesSSE('BTCUSD', (e) => {
      console.log(e);
    });

The error is:

ERROR Error: API Token missing or not in environment (IEX_TOKEN)
But it works when using the example from the readme (with chart).

Any idea?

Thanks,

ThΓ©o

time-series should not use 'limit=1' when specifying a range

Hi,
If you specify the 'range' as an option in timeseries the limit is automatically set to 1. I don't think that this is the desired behavior. When specifying the range, I would assume that the full range will be downloaded.

For example:

client.timeSeries({
      id: 'BALANCE_SHEET',
      key: 'AAPL',
      range: '4y'
})

The code above will use the following url:
https://sandbox.iexapis.com/stable/time-series/BALANCE_SHEET/AAPL?range=4y&limit=1&token=...

client.keyStats - 404

Describe the bug
Maybe this isn't a bug and I'm consuming the library poorly. The keyStats method on Client is kicking back a 404.

To Reproduce
Steps to reproduce the behavior:
const client = new Client({ version: "sandbox", api_token: process.env.REACT_APP_API_KEY }); client.keyStats('APPL', 'companyName', 'symbol,week52high', 'json').then(console.log)

Expected behavior
There should be a json payload

Desktop (please complete the following information):

  • Big Sur
  • chrome
  • Version 90.0.4430.93

Additional context
Add any other context about the problem here.

Some fundamentals return empty arrays

Hi,
the function below always returns an empty array, because the left-hand side of OR is always undefined.

https://github.com/iexcloud/iexjs/blob/e491c644596b25e7a56740361dce62407f0a54a6/src/js/stocks/fundamentals.js#L43-L51

The problem could be a misplaced bracket. It should look like this:

(await _get({...})).balancesheet || []

Besides this problem the result of the different functions are inconsistent. Sometimes it returns a promise and sometimes not. In my opinion, it should always return a promise. So the user has to handle the raw result from iex and extract the property

Batch options should pass as an object

Client.prototype.batch = function (
  symbols,
  { fields, range, last } = {},
  { filter, format } = {},
) {
  return batch(symbols, fields, range, last, {
    token: this._token,
    version: this._version,
    filter,
    format,
  });
};

shuld be

Client.prototype.batch = function (
  symbols,
  { fields, range, last } = {},
  { filter, format } = {},
) {
  return batch(symbols, {fields, range, last}, {
    token: this._token,
    version: this._version,
    filter,
    format,
  });
};

for now is pass as arguments and the token is undefined

SyntaxError: Unexpected token export

Describe the bug
Getting the error from the title when I try the example from the readme.

To Reproduce

const { Client } = require('iexjs');

const client = new Client({ token: 'sandbox_client_key', version: 'sandbox' });

client.chart('AAPL', '1m').then((res) => {
	console.log(res);
});

Expected behavior
Expecting to get the AAPL chart data.

Screenshots
Screen Shot 2021-03-29 at 3 53 45 PM

Additional context
Node version: 12.9.0
"iexjs": "^0.2.4"

Implement or remove blank index.d.ts file for IDE autocomplete

Describe the bug
There is currently a blank index.d.ts file in this project. It should be implemented correctly as the blank declaration disrupts default IDE discovery of types via the code.

To Reproduce
Steps to reproduce the behavior:

  1. Import iexjs and notice no autocomplete of exported variables or functions available to initialized Client objects.
  2. Goto node_modules/iexjs and delete index.d.ts
  3. In VS Code, decent autocomplete is available again.

Expected behavior
The typings should be implemented or file removed for proper type discovery.

"list" argument must be an Array of Buffers

Describe the bug
I'm trying to connect to price streaming over SSE, but the process crashes with the error from the screenshot. I've noticed that if I pass 18 symbols, the app doesn't crash, but if I pass 19, it crashes. Don't know if it's connected to the number of symbols passing as an argument.

To Reproduce

const { Client } = require('iexjs');

const client = new Client({ api_token: '123', version: 'sandbox' });

client.topsSSE('apd,rrc,wec,nyt,rdc,ms,abt,nem,adm,irm,iff,v,ma,ldos,pnw,ma,v,msft,amzn', ([data]) => {
    console.log(data.symbol);
});

Expected behavior
Not expecting the error, but rather an influx of prices.

Screenshots
Screen Shot 2021-04-28 at 2 53 47 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.