• Stars
    star
    327
  • Rank 124,602 (Top 3 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unofficial API for Yahoo Finance

node-yahoo-finance2

Community API for Yahoo-Finance.

Copyright (c) 2021 by Gadi Cohen and Pilwon Huh. MIT licensed.

npm CircleCI coverage semantic-release TypeScript MIT License

Supports Node 12.0.0 and up (tests are run against 12.0.0).

Stable release - supersedes the ubiquitous node-yahoo-finance v1. NB: The API has changed, see UPGRADING for more information.

Live Demo on CodeSandbox

Unofficial API

This project is neither created nor endorsed by Yahoo Inc. Yahoo does not provide any official API to developers, nor makes any guarantees regarding service availability or API consistency. In practice however, the open source community has kept this project (and it's predecessor) working well since 2013.

Nevertheless, we make no guarantees and you use this package at your own risk. The developers (and obviously Yahoo) cannot be held responsible for any losses you may incur as a result of using this service. Use of this package is considered acknowledgement and acceptance of these terms and of it's license.

Quickstart

CLI (Command line interface)

$ npx yahoo-finance2 search AAPL

# or install it
$ npm install -g yahoo-finance2
$ yahoo-finance search AAPL '{ "someOption": true }'

Importing

// import syntax (recommended)
import yahooFinance from 'yahoo-finance2';

// require syntax (if your code base does not support imports)
const yahooFinance = require('yahoo-finance2').default; // NOTE the .default

const results = await yahooFinance.search('AAPL');
const results = await yahooFinance.search('AAPL', { someOption: true, etc });

Available modules: autoc, chart, historical, quote, quoteSummary (submodules: assetProfile, balanceSheetHistory, balanceSheetHistoryQuarterly, calendarEvents, cashflowStatementHistory, cashflowStatementHistoryQuarterly, defaultKeyStatistics, earnings, earningsHistory, earningsTrend, financialData, fundOwnership, fundPerformance, fundProfile, incomeStatementHistory, incomeStatementHistoryQuarterly, indexTrend, industryTrend, insiderHolders insiderTransactions, institutionOwnership, majorDirectHolders, majorHoldersBreakdown, netSharePurchaseActivity, price, quoteType, recommendationTrend, secFilings, sectorTrend, summaryDetail, summaryProfile, symbol, topHoldings, upgradeDowngradeHistory), search, recommendationsBySymbol, trendingSymbols, options, insights, with more coming soon.

Extras: quoteCombine. Utils: setGlobalConfig.

See the Full Documentation.

Particularly, make sure to read the notes there on ERROR HANDLING. Be aware that if a stock gets delisted, Yahoo removes all related data, including historical (and chart) data from periods before the delisting occurred (i.e. queries that worked before will start failing, and there is no way to retrieve this data again).

Even Quicker Start - Stock Price

const quote = await yahooFinance.quote('AAPL');
const { regularMarketPrice as price, currency } = quote;

NB: CommonJS / ES modules

This package is shipped as both an ES Module and a CommonJS module. Node will automatically load the ES module if:

  • Your package.json contains a { type: module } entry
  • You're running at least Node 12 (maybe with --experimental-module flag).
  • You import the module (require function does not exist in ES modules)

otherwise the traditional CommonJS module will be loaded. No flags are necessary for Node 12.7.0+ and Node 13.2.0+, but for older versions, you need to add the --experimental-module flag).

ES Modules are "relatively" new. They got a big boost in April 2021 when Node 10, which did not support them, reached end-of-life. However, support varies by build tool and configuration, and there are some edge cases which can be tricky. Please open an issue if you run into any trouble.

require (CommonJS)

If you use load the library with require, make sure to add .default:

const yahooFinance = require('yahoo-finance2').default; // NOTE the .default

(Optional) TypeScript Love

Working with yahoo-finance2 is a joy if you're using TypeScript (but you don't have to), with type checking and auto completion:

Types Animation

Try it yourself on our Live CodeSandbox.

Using in the Browser (TL;DR; possible but unsupported)

This project is primarily developed to be used server-side in node. Nevertheless, due to the large number on requests on this issue, we have taken care to ensure the package can be imported in the browser too.

HOWEVER: you'll run into other challenges there that we can't help you with, particularly CORS issues when trying to query Yahoo's servers in the browser from non-Yahoo origins. Since Yahoo is specifically blocking such requests, we will not help you bypass them. (One way around this is to run your own server to proxy your requests, but we won't help you with this).

Contributing

Pull Requests welcome! Read CONTRIBUTING.md and join our list of heroes:

contributor-faces

Special mention goes out to pudgereyem and PythonCreator27 who made significant contributions in the very early days of this project.

Credits

  • Massive thanks to @pilwon for the original node-yahoo-finance and for all our prior collaborations on this and other projects 🙏

More Repositories

1

meteor-famous-views

Famous, the Meteor Way (with Reactive Blaze Templates/Views)
JavaScript
335
star
2

meteor-hmr

Hot Module Replacement for Meteor; in your app, with react, with build plugins
JavaScript
143
star
3

meteor-sitemaps

Quickly create dynamic ("real-time") sitemaps using your own functions.
JavaScript
87
star
4

meteor-headers

Access HTTP headers on both server and client. Client IP with proxy support.
JavaScript
61
star
5

meteor-blaze-react-component

<Blaze template="itemsList" items={items} />
JavaScript
60
star
6

meteor-messageformat

MessageFormat i18n support for Meteor, with reactive templates
JavaScript
56
star
7

meteor-reactive-window

Reactive functions for window properties; width, scroll, etc
JavaScript
29
star
8

meteor-phantomjs

Smart package to ensure PhantomJS is automatically installed
JavaScript
25
star
9

fview-flex

IjzerenHein's famous-flex for famous-views (Meteor)
JavaScript
24
star
10

meteor-blaze-virtual-dom

An experiment to use Blaze with a virtual dom
JavaScript
16
star
11

meteor-robots.txt

Serves a robot.txt which can be modified programatically
JavaScript
10
star
12

espruino-gc-meteor

JavaScript
10
star
13

fview-lab

Real-time playground for meteor famous-views
JavaScript
9
star
14

famin

JavaScript
9
star
15

mongodb-rest-relay

Relay mongodb queries over HTTP REST. Great for Edge.
TypeScript
9
star
16

meteor-usermap

A map of Meteor users
JavaScript
8
star
17

node-hosts-so-easy

Safe, parallel API for manipulating /etc/hosts.
JavaScript
8
star
18

redalert

Hackathon related stuff, mostly Tzeva Adom related
JavaScript
6
star
19

meteor-extensions

Add support for extensions (hooks, plugins) to your app
JavaScript
6
star
20

phantomjs-remote

Run phantomjs on a remote server (e.g. if no binary is available locally)
JavaScript
5
star
21

magickli

open source magick stuff....
TypeScript
5
star
22

wmd

JavaScript
5
star
23

meteor-doingthiswith

Anybody doing this [technology/framework/sitetype] with Meteor?
JavaScript
5
star
24

fview-quickstart

Fresh meteor project using quickstart instructions from famous-views
CSS
4
star
25

meteor-famous

Temporary package for Famo.us Mixed Mode v0.5.0
JavaScript
4
star
26

meteor-prism

Prism Syntax Highlighter, integrated with Meteor
JavaScript
4
star
27

fview-lagometer

IjzerenHein's lagometer packaged for famous-views
JavaScript
4
star
28

meteor-spiderable-remote

Like spiderable, but runs phantomjs via phantomjs_remote
JavaScript
4
star
29

fview-sizeconstraint

set renderable scale, padding, max-size, min-size and aspect-ratio
HTML
4
star
30

mink

Mink - Meteor integration for INK File Picker
JavaScript
3
star
31

fview-timbre

Famous Timbre demo using famous-views
JavaScript
3
star
32

fview-demo

Demo of simple app using famous-views
CoffeeScript
2
star
33

meetup-fview-london

Slides for Meteor London meetup 2015-06-25
HTML
2
star
34

meteor-rest-test

Quick and dirty code to make HTTP.call's of different types and check request/response
JavaScript
2
star
35

meteor-accounts-merge

Let user login to and add multiple services to one account
JavaScript
2
star
36

meteor-snippets

Code snippets with highlighting and lang conversion
JavaScript
2
star
37

async-composable-tasks

Composable async tasks designed for await/sync and arrow functions, with progress and parallelism.
JavaScript
2
star
38

meteor-cross-domain-login

User remains logged in on same site across multiple domains
JavaScript
2
star
39

meteor-jquery2

jQuery 2.x packaged for Meteor
JavaScript
1
star
40

meteor-react-container-efficiency

One autorun vs isolated autoruns in react
JavaScript
1
star
41

meteor-modules

Minimalist require support, with glslify hack.
JavaScript
1
star
42

meteor-modal-bs3ui

bootstrap 3 modals, the Meteor way (for Meteor UI)
JavaScript
1
star
43

rtr-utils

Helpful utilities for react-three-render
JavaScript
1
star
44

meetup-fview-tlv

Meteor TLV Meetup 2015-06-14
HTML
1
star
45

meteor-mongo-stream

Live streaming of (recorder) streams (stdout/stderr/anything) to the browser
JavaScript
1
star
46

repro-ranjeev

https://forums.meteor.com/t/how-to-make-blaze-templates-reactive/21027
JavaScript
1
star
47

contributors-svg

Code for Contributors SVG service
JavaScript
1
star
48

meteor-jade-client

Wrapper for mquandalle:jade to use client-side
JavaScript
1
star
49

meteor-json5

Meteor wrapper for json5 npm package
JavaScript
1
star
50

blaze-content

Minimal reproduction showing that content overrides .content in current context
JavaScript
1
star
51

redux-router-state

Store router state in Redux and route via redux
JavaScript
1
star
52

node-yahoo-finance

Yahoo Finance historical quotes and snapshot data downloader written in Node.js
JavaScript
1
star
53

squid-ssl-zero

Zero-config squid caching proxy with SSL intercept (sslbump)
Shell
1
star
54

shadowlang

TypeScript
1
star
55

meetup-fview-ottawa

HTML
1
star
56

jest-fetch-mock-cache

Caching mock implementation for jest-fetch-mock
TypeScript
1
star