Yahoo switched to the Reactjs interface, which means that if you parse the request headers from the client to the backend, you can get the actual JSON that they use to fill the client-side storage.
These calls seem to be load balancing between:
query1.finance.yahoo.com and query2.finance.yahoo.com
Using the following path, using one of the host names listed above, you can request financial reports, insider activity, SEC applications, analyst evaluations .. (module names are pretty clear, and I have listed them below)
Main data path: (replace ticker symbol with AAPL)
/v10/finance/quoteSummary/AAPL?modules=
Parameters for the request ?modules= :
modules = [ 'assetProfile', 'incomeStatementHistory', 'incomeStatementHistoryQuarterly', 'balanceSheetHistory', 'balanceSheetHistoryQuarterly', 'cashFlowStatementHistory', 'cashFlowStatementHistoryQuarterly', 'defaultKeyStatistics', 'financialData', 'calendarEvents', 'secFilings', 'recommendationTrend', 'upgradeDowngradeHistory', 'institutionOwnership', 'fundOwnership', 'majorDirectHolders', 'majorHoldersBreakdown', 'insiderTransactions', 'insiderHolders', 'netSharePurchaseActivity', 'earnings', 'earningsHistory', 'earningsTrend', 'industryTrend', 'indexTrend', 'sectorTrend' ]
A full URL request for the AAPL ticker and assetProfile, defaultKeyStatistics and earnings modules History will look like this:
https://query1.yahoo.com/v10/finance/quoteSummary/AAPL?modules=assetProfile%2CdefaultKeyStatistics%2CearningsHistory
%2C is only a hexadecimal representation of a , and must be inserted between each requested module. If you want to know more about encoding detailing, check out https://stackoverflow.com/a/16621/
You can request any combination of the modules I have listed. But don't be d *! ^. The request for all fields is slightly less than 300 KB, so if you download all the NYSE and NASDAQ, it will be about 2 GB, which, of course, is large enough for Yahoo to notice. This is a really handy api, and I would not want them to close it. Please take the time to find out what data you really need, and only request for this data set. ~~ take what you need and leave the rest .. ~~ (The Band)
Contract path option:
/v7/finance/options/AAPL
This call will give you JSON for the current expiration month. To receive future exits, you need to add a request for a date:
?date= The date value will be an integer that represents the expiration date of the contract as a UNIX timestamp (which the stackoverflow post explains methods for converting unix timestamps to readable dates in Python).
Price request:
/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=3mo
This path will provide you with all the available price data for the AAPL ticker, grouped at 3-month intervals.
You can get interval=1m about 4-5 days. You can get interval=5m in the last 80 (ish) days. I assume that their circumcision is internally based on trading days, so my naive approach to creating past values for period1 little blurred, because I did not take into account the holidays and such (but this may be a more simplified assumption. You can go at different intervals, a little confusing and inconsistent). If you created a query that is valid but interval not supported, yahoo will return interval=3mo . Therefore, simply move the value of period1 forward in time until you get the supported interval.
Add prices before and after the market
&includePrePost=true
Add dividends and splits
&events=div%2Csplit
Example request for all price data for AAPL with a ticker during a 1-day interval, including before and after the market, as well as dividends and splits:
https://query1.finance.yahoo.com/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=1d&includePrePost=true&events=div%2Csplit
The value 9999999999 for period2= matters only in the sense that it is greater than or equal to the current unix timestamp.
Be respectful and perhaps roll YAHOO dice by clicking on some add-ons from time to time. Let them know that you value the service. They could easily collect all this information, so it would be almost impossible to detect, but they did not do this, and not by chance.
I wrote a personal library that uses random rotation of the user agent and forwards requests by rotating anonymous proxies to keep the original IP address of the requests private in order to avoid the blacklist. It also submits reasonable bid requests so as not to be unfair to yahoo servers. , github ( , , EC2 amazon , , ).