104

Is there any sort of API that just offers a simple symbol lookup service? i.e., input a company name and it will tell you the ticker symbol? I've tried just screen-scraping Google Finance, but after a little while it rate limits you and you have to enter a CAPTCHA. I'm trying to batch-lookup about 2000 ticker symbols. Any ideas?

dancavallaro
  • 13,109
  • 8
  • 37
  • 33
  • No better luck with Yahoo Finance? – Noldorin May 19 '09 at 23:13
  • You need to add a delay between lookups. Say 5 seconds. – siamii May 10 '13 at 16:14
  • This script might be useful: https://github.com/kevin91nl/scrape-ticker-symbols – www.data-blogger.com Jun 16 '17 at 22:00
  • I did a recent evaluation of available trading APIs. http://www.strategic-options.com/insight/the-best-and-worst-stock-and-option-trading-apis/ – Chad Jul 23 '18 at 19:39
  • This one does exactly what you want and it is updated daily https://rapidapi.com/logicione/api/stock-ticker-security-and-company-search-database?endpoint=apiendpoint_c9c32d57-dede-4507-b180-9ea4a61ebb02 – Watt May 04 '20 at 09:35
  • I use https://github.com/portfolioplus/pytickersymbols the package offers an offline collection of many stock symbols. – SlashGordon Jul 31 '20 at 09:48

11 Answers11

106

You can use yahoo's symbol lookup like so:

http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=yahoo&callback=YAHOO.Finance.SymbolSuggest.ssCallback

Where query is the company name.

You'll get something like this in return:

YAHOO.Finance.SymbolSuggest.ssCallback(
{
    "ResultSet": {
        "Query": "ya",
        "Result": [
            {
                "symbol": "YHOO",
                "name": "Yahoo! Inc.",
                "exch": "NMS",
                "type": "S",
                "exchDisp": "NASDAQ"
            },
            {
                "symbol": "AUY",
                "name": "Yamana Gold, Inc.",
                "exch": "NYQ",
                "type": "S",
                "exchDisp": "NYSE"
            },
            {
                "symbol": "YZC",
                "name": "Yanzhou Coal Mining Co. Ltd.",
                "exch": "NYQ",
                "type": "S",
                "exchDisp": "NYSE"
            },
            {
                "symbol": "YRI.TO",
                "name": "YAMANA GOLD INC COM NPV",
                "exch": "TOR",
                "type": "S",
                "exchDisp": "Toronto"
            },
            {
                "symbol": "8046.TW",
                "name": "NAN YA PRINTED CIR TWD10",
                "exch": "TAI",
                "type": "S",
                "exchDisp": "Taiwan"
            },
            {
                "symbol": "600319.SS",
                "name": "WEIFANG YAXING CHE 'A'CNY1",
                "exch": "SHH",
                "type": "S",
                "exchDisp": "Shanghai"
            },
            {
                "symbol": "1991.HK",
                "name": "TA YANG GROUP",
                "exch": "HKG",
                "type": "S",
                "exchDisp": "Hong Kong"
            },
            {
                "symbol": "1303.TW",
                "name": "NAN YA PLASTIC TWD10",
                "exch": "TAI",
                "type": "S",
                "exchDisp": "Taiwan"
            },
            {
                "symbol": "0294.HK",
                "name": "YANGTZEKIANG",
                "exch": "HKG",
                "type": "S",
                "exchDisp": "Hong Kong"
            },
            {
                "symbol": "YAVY",
                "name": "Yadkin Valley Financial Corp.",
                "exch": "NMS",
                "type": "S",
                "exchDisp": "NASDAQ"
            }
        ]
    }
}
)

Which is JSON and very easy to work with.

Hush... don't tell anybody.

DLeh
  • 23,806
  • 16
  • 84
  • 128
Jalmarez
  • 1,223
  • 1
  • 10
  • 8
  • 1
    hey is it possible to use wild char in the query? tried % and * but no luck... – NightWolf Jun 20 '11 at 05:22
  • 2
    this returns a maximum of 10 results in JSON !!!! How can we bypass this limitation of ONLY 10 results ?? – Sandy505 Jan 14 '12 at 19:05
  • 1
    thank you so much! is there a way to return pure JSON from yahoo finance if the query is a stock symbol instead of a name? – bouncingHippo Nov 19 '12 at 16:26
  • Also looking for a solution to bypass the limit of 10 results. Any ideas? – Timo Ernst Sep 28 '15 at 00:46
  • 5
    As of a few days ago, this solution seems to be broken. Yahoo now requires a "region" parameter, and setting it to "US" doesn't make any difference. If anybody has a workaround, I would love to hear it! – wstr Oct 02 '15 at 17:39
  • 6
    seems like they added 2 additional param,"region" and "lang". try the following http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=yhoo&region=1&lang=en&callback=YAHOO.Finance.SymbolSuggest.ssCallback – lancegoh Oct 06 '15 at 03:51
  • 2
    And now it doesn't support fuzzy search anymore, it can only lookup "Exactly" symbol. :( Anyone has the workaround or any hidden parameter to turn on the fuzzy search feature? – Jonathan Chen Oct 10 '15 at 21:59
  • This answer shows how to get the same functionality as before: http://stackoverflow.com/a/32943831/1571826 – Def_Os Oct 27 '15 at 01:45
  • For anyone else looking for this...Nothing I found was that good and Yahoo's docs suck so I created one: http://chstocksearch.herokuapp.com/welcome – cph2117 Nov 06 '15 at 22:32
  • This URL has been changed to: http://d.yimg.com/aq/autoc?query=yahoo&region=IN&lang=en-UK&callback=YAHOO.Finance.SymbolSuggest.ssCallback – N3R4ZZuRR0 Dec 22 '16 at 04:30
  • @VermaJr. where can I find the documentation for this API, in case the URL should change again? How did you know the new URL? – robertspierre Jul 24 '17 at 11:03
  • You could do fuzzy search using this https://rapidapi.com/logicione/api/stock-ticker-security-and-company-search-database?endpoint=apiendpoint_c9c32d57-dede-4507-b180-9ea4a61ebb02 – Watt May 04 '20 at 09:35
33

Google Finance does let you retrieve up to 100 stock quotes at once using the following URL:

www.google.com/finance/info?infotype=infoquoteall&q=[ticker1],[ticker2],...,[tickern]

For example:

www.google.com/finance/info?infotype=infoquoteall&q=C,JPM,AIG

Someone has deciphered the available fields here:

http://qsb-mac.googlecode.com/svn/trunk/Vermilion/Modules/StockQuoter/StockQuoter.py

The current price ("l") is real-time and the delay is on par with Yahoo Finance. There are a few quirks you should be aware of. A handful of stocks require an exchange prefix. For example, if you query "BTIM", you'll get a "Bad Request" error but "AMEX:BTIM" works. A few stocks don't work even with the exchange prefix. For example, querying "FTWRD" and "NASDAQ:FTWRD" both generate "Bad Request" errors even though Google Finance does have information for this NASDAQ stock.

The "el" field, if present, tells you the current pre-market or after-hours price.

Aliphany
  • 347
  • 3
  • 3
  • 5
    Moved to http://qsb-mac-plugins.googlecode.com/svn-history/r4/trunk/stock-quoter/trunk/StockQuoter.py – JRG Jun 03 '11 at 14:43
  • 4
    Unfortunately it looks like the Google Finance API is deprecated and will be shutdown on 20 October 2012 https://developers.google.com/finance – vegemite4me Sep 05 '12 at 08:15
  • 2
    Yes having a look and google finance is now depricated and not open for business. Given googles track record closing apis I would be very hesitant to base a business or app on it unless you had a contract and sla with them – Shawn Vader Jan 07 '14 at 10:34
  • 1
    Any new docs? Service still works, Looking for a stock search too :) like yahoo one – João Nunes May 23 '16 at 17:52
25

You can send an HTTP request to http://finance.yahoo.com requesting symbols, names, quotes, and all sorts of other data. Data is returned as a .CSV so you can request multiple symbols in one query.

So if you send:

http://finance.yahoo.com/d/quotes.csv?s=MSFT+F+ATT&f=sn

You'll get back something like:

"MSFT","Microsoft Corp"
"F","FORD MOTOR CO"
"ATT","AT&T"

Here is an article called Downloading Yahoo Data which includes the various tags used to request the data.

Farmer Joe
  • 6,020
  • 1
  • 30
  • 40
Robert Cartaino
  • 27,494
  • 6
  • 45
  • 67
  • 1
    Unfortunately, finding the company name from a symbol is easy. I'm looking for a way to automate a batch-lookup of ticker symbols from a list of company names. Google has by far the best search, I can find the symbol for almost any company in my list without having to manually search, but Google has rate-limiting and will give you a 503 error after about 1000 requests. – dancavallaro May 20 '09 at 21:35
  • not an answer, but useful for the domain – kenny Aug 02 '10 at 20:36
  • looks like that api usage has legal issues. When opening [Downloading Yahoo Data] one will see a note of Yahoo that using their service in those way is illegal – Bogdan Jun 11 '14 at 10:31
  • 1
    You can see the same interface documented at http://www.jarloo.com/yahoo_finance/. Or search for the original at http://archive.org. – George Apr 22 '15 at 02:37
23

The NASDAQ site hosts separate CSV lists for ticker symbols in each stock exchange (NYSE, AMEX and NASDAQ). You need to complete the captcha and get the CSV dump.

http://www.nasdaq.com/screening/company-list.aspx

Karthik
  • 231
  • 2
  • 3
9

If you didn't want to sign up for a service, I'd probably go back to the exchanges themselves; most of them aren't CAPTCHAed yet...

The symbol lookup page for:

etc...

Stobor
  • 44,246
  • 6
  • 66
  • 69
  • 2
    Better yet, skip symbol lookup at the exchange sites -- just screen-scrape their full listings into your own local table and do the lookup yourself. –  May 20 '09 at 01:50
  • @John Pirie: Yeah, that too... :-) – Stobor May 20 '09 at 02:32
7

Use YQL and you don't need to worry. It's a query language by Yahoo and you can get all the stock data including the name of the company for the ticker. It's a REST API and it returns the results via XML or JSON. I have a full tutorial and source code on my site take a look: http://www.jarloo.com/yahoo-stock-symbol-lookup/

Kelly
  • 6,992
  • 12
  • 59
  • 76
6

Currently, the NASDAQ web site publicly provides CSV files containing bulk listings -- it is broken up by first letter.

http://www.nasdaq.com/screening/companies-by-name.aspx?letter=A&render=download

Paul
  • 26,170
  • 12
  • 85
  • 119
2

Google Finance has an API - you probably have to apply for a developers key, but at least you'd save yourself the hassle of screen-scraping: http://code.google.com/apis/finance/reference.html

matt
  • 9,113
  • 3
  • 44
  • 46
1

Your best bets are probably going with one of the other lookup services (still screen-scraping), and checking whether they don't require CAPTCHAs.

The last appears the least likely to require a CAPTCHA at any point, but it's worth checking all three.

Noldorin
  • 144,213
  • 56
  • 264
  • 302
0

Use YQL: a sql-like language to retrieve stuff from public api's: YQL Console (external link)

It gives you a nice XML file to work with!

Fabdrol
  • 728
  • 1
  • 7
  • 20
0

You can use the "Company Search" operation in the Company Fundamentals API here: http://www.mergent.com/servius/

Eugene Osovetsky
  • 6,443
  • 2
  • 38
  • 59