Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yahoo-stock-api

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yahoo-stock-api

Simple API to get stock price from finance.yahoo.com

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

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

Installaion

Not yet ;)

Test

  • Clone this Repo (git clone https://github.com/phamleduy04/yahoo-stock-api)
  • Open Terminal (Command Line) in the folder.
  • npm test

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
  }
}

Contributors ✨

Thanks goes to these wonderful people (emoji key):

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

Keywords

FAQs

Package last updated on 28 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc