Last active
April 19, 2025 07:58
-
-
Save leftmove/dd9d981c8c37983f61e423a45085e063 to your computer and use it in GitHub Desktop.
Company name to ticker using Yahoo Finance API endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_ticker(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 |
@bruhbruhroblox Thank you very much!
Thanks @leftmove
Working
As of 19.04.2025, it is still working. ๐
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bruhbruhroblox Good catch! It's really helpful for me as well. I also tried to get ticker symbol from company name using OpenFIGI, FinHub, IEXCloud etc, but couldn't get correct symbols what I wanted to. it returns perfect ones. ๐