Search code examples
pythonyahoo-financeyfinance

Multiple Quotes from single API call yfinance Python


I want a quote for multiple stock symbols with one API call using Yahoo Finance.

import yfinance as yf

t = yf.Tickers('msft aapl goog')
print(t.info)

Solution

  • Yahoo Finance API is being discontinued.

    I would suggest using the Financial Modeling Prep API as an alternative.

    https://financialmodelingprep.com/api/v3/historical-price-full/MSFT,AAPL,GOOG

    Returns the data you are looking for.

    Full API Documentation can be found here

    Here's a sample code downloading a json with the data:

    import json
    import requests
    
    url = "https://financialmodelingprep.com/api/v3/historical-price-full/MSFT,AAPL,GOOG"
    session = requests.session()
    request = session.get(url, timeout=15)
    stock_data = request.json()