JulesPatry / yahoo-stock-api

πŸ’° NPM package to get stock and historical price from finance.yahoo.com

Home Page:https://www.npmjs.com/package/yahoo-stock-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yahoo-stock-api

πŸ’° NPM package to get stock and historical price from finance.yahoo.com

GitHub top language GitHub package.json version GitHub last commit GitHub issues GitHub Travis (.org) Node.js CI Code quality David npm bundle size Snyk Vulnerabilities for npm package ![Visits Badge

Installaion

npm i yahoo-stock-api or yarn add yahoo-stock-api if you use yarn.

API

Everything in this API will return Promise so remember to use await

getHistoricalPrices: async function(startDate, endDate, symbol, frequency)

  • startDate: Object (datetime)
  • endDate: Object (datetime)
  • symbol: String (stock symbol)
  • frequency: String ('1d', '1wk' or '1mo' only)
    • 1d: 1day
    • 1wk: 1 week
    • 1mo: 1 month

Return promise, example:

const yahooStockAPI  = require('yahoo-stock-api');
async function main()  {
	const startDate = new Date('08/21/2020');
	const endDate = new Date('08/26/2020');
	console.log(await yahooStockAPI.getHistoricalPrices(startDate, endDate, 'AAPL', '1d'));
}
main();
{
  error: false,
  currency: 'USD',
  data: [
    {
      date: 1598448600,
      open: 504.7200012207031,
      high: 507.9700012207031,
      low: 500.3299865722656,
      close: 506.0899963378906,
      volume: 40617600,
      adjclose: 506.0899963378906
    },
    {
      date: 1598362200,
      open: 498.7900085449219,
      high: 500.7200012207031,
      low: 492.2099914550781,
      close: 499.29998779296875,
      volume: 52873900,
      adjclose: 499.29998779296875
    },
    {
      date: 1598275800,
      open: 514.7899780273438,
      high: 515.1400146484375,
      low: 495.75,
      close: 503.42999267578125,
      volume: 86484400,
      adjclose: 503.42999267578125
    },
    {
      date: 1598016600,
      open: 477.04998779296875,
      high: 499.4700012207031,
      low: 477,
      close: 497.4800109863281,
      volume: 84513700,
      adjclose: 497.4800109863281
    }
  ]
}

getSymbol(symbol)

  • symbol: String (stock symbol)

Return promise, example:

const yahooStockAPI  = require('yahoo-stock-api');
async function main()  {
	console.log(await  yahooStockAPI.getSymbol('AAPL'));
}
main();
{
  error: false,
  currency: 'USD',
  response: {
    updated: 1598573260808,
    previousClose: 506.09, 
    open: 508.57,
    bid: '500.53 x 900',
    ask: '500.90 x 800',
    dayRange: '495.33 - 509.94',
    fiftyTwoWeekRange: '204.22 - 515.14',
    volume: 38255269,
    avgVolume: 39094272,
    marketCap: 2138000000000,
    beta: 1.23,
    peRatio: 37.92,
    eps: 13.19,
    earningsDate: 'Oct 28, 2020 - Nov 02, 2020',
    forwardDividendYield: '3.28 (0.65%)',
    exDividendDate: 'Aug 07, 2020',
    oneYearTargetEst: 430.06
  }
}

Test

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Duy Pham Le

πŸ’»

Rajat

πŸ€”

Tommy Tang

πŸ’» πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!

License

FOSSA Status

About

πŸ’° NPM package to get stock and historical price from finance.yahoo.com

https://www.npmjs.com/package/yahoo-stock-api

License:MIT License


Languages

Language:JavaScript 100.0%