npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@smurftheweb/tradier-client

v1.0.4

Published

Node API wrapper for the Tradier API

Downloads

4

Readme

tradier-client

npm

tradier-client is a promise-based Node.js wrapper for the Tradier API. It currently works with the Market Data and Fundamentals API.

API Keys

You will receive your Tradier API Access Token after: creating an account

Installation

$ npm i -S tradier-client

Example Usage

Require or import the package.

const Tradier = require('tradier-client');

// ES2015 
import Tradier from 'tradier-client';

When creating a new Tradier instance, you must specify if you are in a sandbox account. See below for a description.

// If you are not in a sandbox account, you only need to pass in your access token and it takes care of the rest:
const tradier = new Tradier('TRADIER_ACCESS_TOKEN');

// If you are in a sandbox account, you must pass in 'sandbox' as a second argument in the new instance: 
const tradier = new Tradier('TRADIER_ACCESS_TOKEN', 'sandbox');

// Get current stock quotes
tradier
  .quote('AAPL')  // For multiple quotes, separate tickers with a comma: .quote('AAPL,KO,S')
  .then(quote => {
    console.log(`
      Symbol: ${quote.symbol}     
      Volume: ${quote.volume} 
      Open: ${quote.open} 
      High: ${quote.high}
      Low: ${quote.low} 
      Close: ${quote.close}
      Previous: ${quote.prevclose}  
    `);
  })
  .catch(error => {
    console.log(error);
  })

Documentation

Methods

Quote

tradier
  .quote('AAPL')  // For multiple quotes: .quote('AAPL,KO,S')
  .then(quote => {
    console.log(quote)
  })
  .catch(error => {
    console.log(error);
  })

Time and Sales

tradier
  .timesales('AAPL')
  .then(ts => {
    console.log(ts)
  })
  .catch(error => {
    console.log(error);
  })

Option Chains

tradier
  .optionchain('AAPL')
  .then(oc => {
    console.log(oc)
  })
  .catch(error => {
    console.log(error);
  })

Option Strikes

tradier
  .optionstrikes('AAPL')
  .then(os => {
    console.log(os)
  })
  .catch(error => {
    console.log(error);
  })

Option Expirations

tradier
  .optionexpirations('AAPL')
  .then(oe => {
    console.log(oe)
  })
  .catch(error => {
    console.log(error);
  })

Historical Pricing

tradier
  .historical('AAPL')
  .then(history => {
    console.log(history)
  })
  .catch(error => {
    console.log(error);
  })
});

/* returns an array of objects

{ day: 
  [ { date: '2017-01-03',
       open: 115.8,
       high: 116.33,
       low: 114.76,
       close: 116.15,
       volume: 28781865 }... 
  ]

*/

Intraday Status

tradier
  .intradaystatus()
  .then(intraday => {
    console.log(intraday)
  })
  .catch(error => {
    console.log(error);
  })

Market Calendar

tradier
  .marketcalendar()
  .then(mc => {
    console.log(mc)
  })
  .catch(error => {
    console.log(error);
  })

Company Search

tradier
  .companysearch('AAPL')
  .then(cs => {
    console.log(cs)
  })
  .catch(error => {
    console.log(error);
  })

Company Information

tradier
  .getCompanyInfo('AAPL')
  .then(ci => {
    console.log(ci)
  })
  .catch(error => {
    console.log(error);
  })

Corporate Calendar

tradier
  .getCorporateCalendar('AAPL')
  .then(cc => {
    console.log(cc)
  })
  .catch(error => {
    console.log(error);
  })

Dividend Information

tradier
  .getDividendInfo('AAPL')
  .then(di => {
    console.log(di)
  })
  .catch(error => {
    console.log(error);
  })

Corporate Actions

tradier
  .getCorporateActions('AAPL')
  .then(ca => {
    console.log(ca)
  })
  .catch(error => {
    console.log(error);
  })

Ratios

tradier
  .getRatios('AAPL')
  .then(ratios => {
    console.log(ratios)
  })
  .catch(error => {
    console.log(error);
  })

Corporate Financials

tradier
  .getCorporateFinancials('AAPL')
  .then(cf => {
    console.log(cf)
  })
  .catch(error => {
    console.log(error);
  })

Price Statistics

tradier
  .getPriceStats('AAPL')
  .then(ps => {
    console.log(ps)
  })
  .catch(error => {
    console.log(error);
  })

Lookup a symbol

Note: At least one of the following parameters is required: q, exchanges, types


const params = {
  q: 'goo', 
  exchanges: ['Q', 'N'],
  types: ['stock', 'etf'],
};

tradier
  .lookup(params)
  .then(symbols => {
    console.log(symbols)
  })
  .catch(error => {
    console.log(error);
  })

Endpoints

API Endpoints used include:

Sandbox: https://sandbox.tradier.com/v1/ API: https://api.tradier.com/v1/ Beta: https://api.tradier.com/beta/

Contribute

Feel free to suggest new features, open an issue or submit a pull request.