12

Until yesterday a query such as this http://autoc.finance.yahoo.com/autoc?query=a&callback=YAHOO.Finance.SymbolSuggest.ssCallback yielded a long list of fuzzy/broadmatch results for both ticker and company name.

Since today you are a.) required to specific region and language and b.) it is only yielding exact match results only for the ticker and not for the company name. Thus usually you get only one results back.

Thus for http://autoc.finance.yahoo.com/autoc?query=y&region=US&lang=en&callback=YAHOO.Finance.SymbolSuggest.ssCallback there's now only one result: YAHOO.Finance.SymbolSuggest.ssCallback({"ResultSet":{"Query":"a","Result":[{"symbol":"A","name":"Agilent Technologies Inc.","exch":"NYQ","type":"S","exchDisp":"NYSE","typeDisp":"EQUITY"}]}});

Any idea how to a.) broaden the match type and b.) include the company name as the searched field?

jco40
  • 297
  • 3
  • 9

4 Answers4

21

The URL has now changed to this: http://d.yimg.com/aq/autoc?query=y&region=US&lang=en-US&callback=YAHOO.util.ScriptNodeDataSource.callbacks

rassom
  • 2,896
  • 5
  • 34
  • 45
  • 2
    Hi, I'm just curious, how were you aware of this change? I rely on this API and this post saved me some serious trouble/headache. – Christopher Reid Oct 09 '15 at 00:10
  • @AllTheTime Glad it helped you and good question :) "Unfortunately" I saw that it didn't work by coincidence and googled to find a mention of the new URL. If you find a method to monitor it in a good way, please let me know :) – rassom Oct 09 '15 at 07:06
  • @rassom I just started by catching 400 errors and sending an email to myself from the server when they happen so I can find out about them faster – Christopher Reid Oct 09 '15 at 08:57
  • @AllTheTime Good idea :-) – rassom Oct 09 '15 at 12:30
  • That just saved my life. Thank you so much! How did you find the corrected URL by the way? – Jonathan Chen Oct 10 '15 at 22:19
  • Man, you just saved my life (and my app)! Thank you so much ! – Frederic Adda Nov 11 '15 at 20:12
  • 10
    You can skip the callback parameter, i.e. http://d.yimg.com/aq/autoc?query=y&region=US&lang=en-US and this will return you only the JSON. – Peter Dotchev Dec 10 '15 at 20:39
  • 1
    does anyone know how to add parameters to this call? For instance, I only want results from the exchanges: NAS and NYQ. I can't find any documentation – Roka Apr 19 '19 at 21:09
  • Why is this not working anymore? Until recently it did. As of today I get a "Will be right back ... ". Will it really be? – ChrisDelClea Sep 26 '21 at 14:27
6

The following works (the returned data stream has lots of escape characters):

http://autoc.finance.yahoo.com/autoc?query=alphabet&region=EU&lang=en-GB

Or expanded in the YQL Console:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D'http%3A%2F%2Fautoc.finance.yahoo.com%2Fautoc%3Fquery%3Dalphabet%26region%3DEU%26lang%3Den-GB'&format=json&callback=
jotik
  • 17,044
  • 13
  • 58
  • 123
Des
  • 61
  • 1
  • 1
  • the region choice doesn't seem to have any effect. – Lcukerd Jun 03 '17 at 06:37
  • Does anyone know how to add parameters to this call? For instance, I only want results from the exchanges: NAS and NYQ. I can't find any documentation – Roka Apr 19 '19 at 21:09
0

Shameless Plug

When I was building an app that required stock symbol/company lookup, I tried a few options, and none were very good. I took what I built, and made it public: https://www.stocksearchapi.com

UPDATE I took this offline due to lack of interest

cph2117
  • 2,651
  • 1
  • 28
  • 41
  • @JunchaoGu Took offline due to lack of interest – cph2117 Nov 02 '17 at 16:18
  • I think markit took down their api as well. recently I am trying to work a nice solution for this though. Other than yahoo finance, I did not find any other good candidate. maybe i will try google search company name as well – Junchao Gu Nov 03 '17 at 07:05
0

I found some of the above URL inactive. You can check

https://query2.finance.yahoo.com/v1/finance/search

Pythonic way to extract ticker lookup is


def getTicker(company_name):
    yfinance = "https://query2.finance.yahoo.com/v1/finance/search"
    user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
    params = {"q": company_name, "quotes_count": 1, "country": "United States"}

    res = requests.get(url=yfinance, params=params, headers={'User-Agent': user_agent})
    data = res.json()

    company_code = data['quotes'][0]['symbol']
    return company_code

Credit to https://gist.github.com/bruhbruhroblox/dd9d981c8c37983f61e423a45085e063

Pranjal Doshi
  • 862
  • 11
  • 29