How do you use the python alpha_vantage API to return extended intraday data?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Question
01:52 Accepted answer (Score 4)
02:36 Answer 2 (Score 1)
02:53 Answer 3 (Score 0)
03:08 Thank you
--
Full question
https://stackoverflow.com/questions/6562...
Question links:
[alpha vantage python API]: https://github.com/RomelTorres/alpha_van...
[TimeSeries class]: https://github.com/RomelTorres/alpha_van...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #json #alphavantage #csvreader
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Question
01:52 Accepted answer (Score 4)
02:36 Answer 2 (Score 1)
02:53 Answer 3 (Score 0)
03:08 Thank you
--
Full question
https://stackoverflow.com/questions/6562...
Question links:
[alpha vantage python API]: https://github.com/RomelTorres/alpha_van...
[TimeSeries class]: https://github.com/RomelTorres/alpha_van...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #json #alphavantage #csvreader
#avk47
ACCEPTED ANSWER
Score 4
Seems like TIME_SERIES_INTRADAY_EXTENDED can return only CSV format, but the alpha_vantage wrapper applies JSON methods, which results in the error.
My workaround:
from alpha_vantage.timeseries import TimeSeries
import pandas as pd
apiKey = 'MY API KEY'
ts = TimeSeries(key = apiKey, output_format = 'csv')
#download the csv
totalData = ts.get_intraday_extended(symbol = 'NIO', interval = '15min', slice = 'year1month1')
#csv --> dataframe
df = pd.DataFrame(list(totalData[0]))
#setup of column and index
header_row=0
df.columns = df.iloc[header_row]
df = df.drop(header_row)
df.set_index('time', inplace=True)
#show output
print(df)
ANSWER 2
Score 1
This is an easy way to do it.
ticker = 'IBM'
date= 'year1month2'
apiKey = 'MY API KEY'
df = pd.read_csv('https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY_EXTENDED&symbol='+ticker+'&interval=15min&slice='+date+'&apikey='+apiKey+'&datatype=csv&outputsize=full')
#Show output
print(df)
ANSWER 3
Score 0
import pandas as pd
symbol = 'AAPL'
interval = '15min'
slice = 'year1month1'
api_key = ''
adjusted = '&adjusted=true&'
csv_url = 'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY_EXTENDED&symbol='+symbol+'&interval='+interval+'&slice='+slice+adjusted+'&apikey='+api_key
data = pd.read_csv(csv_url)
print(data.head)