Reputation: 21
I have recently been looking after API:s to collect OHLC stock data and read about the yahoo finance API. After browsing the web for a while I was unable to find any documentation for their API but it seems like it still possible to collect the data through the pandas-datareader library. These lines of codes is taken from a youtube-video. However I was wondering if anyone knows if their API is still open and what this command is doing.
def get_data(ticker):
try:
stock_data = data.DataReader(ticker,
'yahoo',
START_DATE,
END_DATE)
stock_data.dropna(axis=1, inplace=True)
return stock_data
except RemoteDataError:
print('No data found for {t}'.format(t=ticker))
Upvotes: 2
Views: 6512
Reputation: 1
Try to use that API https://rapidapi.com/telescopeanalytics-hl8pcoeL44o/api/telescope-stocks-options-price-charts/. This API provide an access to actual information from stock exchanges worldwide. It supports getting information about emitents and the history of share price changes.
Example:
import requests
url = "https://telescope-stocks-options-price-charts.p.rapidapi.com/stocks/AAPL"
querystring = {"modules":"assetProfile,summaryProfile,price"}
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "telescope-stocks-options-price-charts.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
Upvotes: 0
Reputation: 12195
Even though the Yahoo API has gone, you may be able to find one that suits your needs from here: https://www.programmableweb.com/category/financial/apis?category=19968&keyword=stock
In terms of what the code is doing:
def get_data(ticker):
try:
# get data for the given `ticker` symbol, from Yahoo, between the two dates
stock_data = data.DataReader(ticker,
'yahoo',
START_DATE,
END_DATE)
# Drop empty values from the data:
stock_data.dropna(axis=1, inplace=True)
return stock_data
except RemoteDataError:
print('No data found for {t}'.format(t=ticker))
Upvotes: 1
Reputation: 2876
The Official Yahoo Finance API was closed in 2017, however there are unofficial versions. The most popular is this, hosted on RapidAPI, however I believe you have to pay for some functionalities. I would recommend using an alternative like Alpha Vantage.
Upvotes: -1
Reputation: 25
Actually my search shows that the Yahoo Finance API was shut down in 2017.
Upvotes: 0