yahoo-finance icon indicating copy to clipboard operation
yahoo-finance copied to clipboard

Yahoo API version 7

Open bcoles opened this issue 8 years ago • 15 comments

Yahoo API version 7 is superior to the current implementation.

The new API has more accurate data.

The data in the old API does not appear to updated any more for properties such as free float and shares outstanding. Basic properties such as change, volume, open, close are still accurate using the old API - for the time being.

Version 7 still supports multiple stocks in a single call:

  • https://query1.finance.yahoo.com/v7/finance/quote?symbols=TLS.AX,MUS.AX

Version 7 supports options, which the old API does not:

  • https://query1.finance.yahoo.com/v7/finance/options/MUSOA.AX

bcoles avatar Sep 18 '17 17:09 bcoles

Hey @bcoles ! Would you be interested on porting that? I'm slightly flooded at the moment and won't be able to take on this any time soon..

herval avatar Oct 04 '17 03:10 herval

Hey @herval

I'm in the same boat. I won't have time to port this either.

bcoles avatar Oct 05 '17 06:10 bcoles

@herval upon requesting yahoo_client.quote.. , it gives the following response: OpenURI::HTTPError: 999 Request denied. I think its the right time to update the end point to v7.

ahmadali1 avatar Nov 02 '17 08:11 ahmadali1

Anyone currently working on this? I have time to jump in and make the changes

brettallred avatar Nov 16 '17 04:11 brettallred

You’re more than welcome to start the work, Brett! 🙌


From: Brett Allred [email protected] Sent: Wednesday, November 15, 2017 8:48:40 PM To: herval/yahoo-finance Cc: Herval Freire; Mention Subject: Re: [herval/yahoo-finance] Yahoo API version 7 (#51)

Anyone currently working on this? I have time to jump in and make the changes

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/herval/yahoo-finance/issues/51#issuecomment-344814926, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAAV6vEClTK_Yit3VakSjzxH0XsEES_zks5s276ogaJpZM4PbPGl.

herval avatar Nov 16 '17 05:11 herval

Probably best to stick with version 7 rather than 8 for now.

Version 8 API endpoint returns no data for quotes; or maybe the endpoint has changed.

bcoles avatar Nov 18 '17 04:11 bcoles

Note that many of the properties originally available in version 7, in particular the fundamentals such as EBITDA, are no longer available.

Here's an example response for the quote endpoint, using a stock ticker and an option ticker as an example. Should be pretty easy to convert to a hash.

  • hxxps://query1.finance.yahoo.com/v7/finance/quote?symbols=TLS.AX,LPIO.AX
{
	"quoteResponse": {
		"result": [
			{
				"language": "en-US",
				"quoteType": "EQUITY",
				"currency": "AUD",
				"exchange": "ASX",
				"financialCurrency": "AUD",
				"averageDailyVolume3Month": 28446096,
				"averageDailyVolume10Day": 27888822,
				"fiftyTwoWeekLowChange": 0.09500003,
				"fiftyTwoWeekLowChangePercent": 0.02818992,
				"fiftyTwoWeekHighChange": -1.825,
				"fiftyTwoWeekHighChangePercent": -0.34499055,
				"fiftyTwoWeekLow": 3.37,
				"fiftyTwoWeekHigh": 5.29,
				"earningsTimestamp": 1502910900,
				"earningsTimestampStart": 1518605940,
				"earningsTimestampEnd": 1519041600,
				"trailingAnnualDividendRate": 0.31,
				"trailingPE": 10.661538,
				"trailingAnnualDividendYield": 0.09037901,
				"market": "au_market",
				"regularMarketPrice": 3.465,
				"regularMarketTime": 1510894799,
				"regularMarketChange": 0.0349998,
				"regularMarketOpen": 3.45,
				"regularMarketDayHigh": 3.475,
				"regularMarketDayLow": 3.43,
				"regularMarketVolume": 15289576,
				"priceHint": 3,
				"epsTrailingTwelveMonths": 0.325,
				"epsForward": 0.34,
				"sharesOutstanding": 11878899712,
				"bookValue": 1.224,
				"fiftyDayAverage": 3.4888237,
				"fiftyDayAverageChange": -0.023823738,
				"fiftyDayAverageChangePercent": -0.0068285875,
				"twoHundredDayAverage": 3.9805634,
				"priceToBook": 2.8308823,
				"sourceInterval": 20,
				"exchangeTimezoneName": "Australia/Sydney",
				"exchangeTimezoneShortName": "AEDT",
				"gmtOffSetMilliseconds": 39600000,
				"tradeable": false,
				"regularMarketChangePercent": 1.0204,
				"regularMarketPreviousClose": 3.43,
				"bid": 3.65,
				"ask": 3.2,
				"bidSize": 1165,
				"askSize": 289,
				"messageBoardId": "finmb_91774",
				"fullExchangeName": "ASX",
				"longName": "Telstra Corporation Limited",
				"shortName": "Telstra Corp Ltd",
				"twoHundredDayAverageChange": -0.5155635,
				"twoHundredDayAverageChangePercent": -0.12952024,
				"marketCap": 41160384512,
				"forwardPE": 10.191176,
				"exchangeDataDelayedBy": 0,
				"marketState": "CLOSED",
				"symbol": "TLS.AX"
			},
			{
				"language": "en-US",
				"quoteType": "EQUITY",
				"currency": "AUD",
				"exchange": "ASX",
				"fiftyTwoWeekLowChange": 0.030000001,
				"fiftyTwoWeekLowChangePercent": 1.5000001,
				"fiftyTwoWeekHighChange": -0.0069999993,
				"fiftyTwoWeekHighChangePercent": -0.122807,
				"fiftyTwoWeekLow": 0.02,
				"fiftyTwoWeekHigh": 0.057,
				"market": "au_market",
				"regularMarketPrice": 0.05,
				"regularMarketTime": 1510892471,
				"regularMarketChange": 0.038,
				"regularMarketOpen": 0.024,
				"regularMarketDayHigh": 0.057,
				"regularMarketDayLow": 0.02,
				"regularMarketVolume": 4386630,
				"priceHint": 2,
				"sourceInterval": 20,
				"exchangeTimezoneName": "Australia/Sydney",
				"exchangeTimezoneShortName": "AEDT",
				"gmtOffSetMilliseconds": 39600000,
				"tradeable": false,
				"regularMarketChangePercent": 316.667,
				"regularMarketPreviousClose": 0.012,
				"bid": 0.045,
				"ask": 0.05,
				"bidSize": 40000,
				"askSize": 218048,
				"fullExchangeName": "ASX",
				"exchangeDataDelayedBy": 0,
				"marketState": "CLOSED",
				"symbol": "LPIO.AX"
			}
		],
		"error": null
	}
}

A nice feature of version 7 is that it now supports data for options, which wasn't supported in the original API. There's an API endpoint for options, however I've found that the quote endpoint is just as good for option data. (Neither endpoint contains the option expiry date or exercise price).

For what it's worth, here's an example response from the options endpoint.

  • hxxps://query1.finance.yahoo.com/v7/finance/options/LPIO.AX
{
	"optionChain": {
		"result": [
			{
				"underlyingSymbol": "LPIO.AX",
				"expirationDates": [],
				"strikes": [],
				"hasMiniOptions": false,
				"quote": {
					"language": "en-US",
					"quoteType": "EQUITY",
					"currency": "AUD",
					"exchangeDataDelayedBy": 0,
					"fiftyTwoWeekHighChange": -0.0069999993,
					"fiftyTwoWeekHighChangePercent": -0.122807,
					"fiftyTwoWeekLow": 0.02,
					"fiftyTwoWeekHigh": 0.057,
					"priceHint": 2,
					"market": "au_market",
					"regularMarketPrice": 0.05,
					"regularMarketTime": 1510892471,
					"regularMarketChange": 0.038,
					"regularMarketOpen": 0.024,
					"regularMarketDayHigh": 0.057,
					"regularMarketDayLow": 0.02,
					"regularMarketVolume": 4386630,
					"sourceInterval": 20,
					"exchangeTimezoneName": "Australia/Sydney",
					"exchangeTimezoneShortName": "AEDT",
					"gmtOffSetMilliseconds": 39600000,
					"tradeable": false,
					"regularMarketChangePercent": 316.667,
					"regularMarketPreviousClose": 0.012,
					"bid": 0.045,
					"ask": 0.05,
					"bidSize": 40000,
					"askSize": 218048,
					"fullExchangeName": "ASX",
					"fiftyTwoWeekLowChange": 0.030000001,
					"fiftyTwoWeekLowChangePercent": 1.5000001,
					"marketState": "CLOSED",
					"exchange": "ASX",
					"symbol": "LPIO.AX"
				},
				"options": []
			}
		],
		"error": null
	}
}

bcoles avatar Nov 18 '17 04:11 bcoles

@bcoles - Thanks for the good info.

Do you have any idea on a new endpoint for the splits calculation

"https://ichart.finance.yahoo.com/x?#{params.map{|k, v| "#{k}=#{v}"}.join("&")}"

brettallred avatar Nov 19 '17 21:11 brettallred

@brettallred nope, sorry, never used that functionality.

bcoles avatar Dec 01 '17 06:12 bcoles

@bcoles,

The quote endpoint still contains EBITDA. The default endpoint, as listed in your earlier post, has a list of a few default outputs, but modification of the endpoint will return EBITDA (see the example below). I'm trying to hunt down all the available values for the [fields] parameter, so if you find some documentation for this then please pass it along.

https://query1.finance.yahoo.com/v7/finance/quote?symbols=UNP&fields=ebitda,shortRatio,priceToSales

matthewherbert avatar Jan 27 '18 19:01 matthewherbert

@bcoles, I noticed the v7 doesn't have certain fields too, like Forward Annual Dividend Yield that can be found in the web version.

@matthewherbert Thanks. That's useful to know. Any idea how to get other fields like forward dividend? I tried a few different parameters but couldn't get it.

NYcoder8 avatar Jun 15 '18 01:06 NYcoder8

Is there some kind of API rate limiting for Yahoo API v7? I would like to get some quotes every second using https://query1.finance.yahoo.com/v7/finance/quote?symbols=.

HLFH avatar Jun 15 '18 07:06 HLFH

try this way

https://query1.finance.yahoo.com/v7/finance/chart/RADICO.NS?&interval=1m

kongaraman avatar Aug 07 '18 10:08 kongaraman

@HLFH Did you find answer to your question?

pratikgaloria avatar Mar 22 '19 07:03 pratikgaloria