Mike C.
Mike C.

Reputation: 1921

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)

Upvotes: 0

Views: 2623

Answers (1)

alphazeta
alphazeta

Reputation: 493

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()

Upvotes: 1

Related Questions