Closed 1995duoduo2018 closed 3 years ago
Same error here: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ts = TimeSeries(key=API_KEY, output_format='pandas')
data, meta_data = ts.get_intraday('GOOGL')
There seems to be something wrong in how the _output_format class handles this specific case. get_intraday_extended returns only the csv format:(https://www.alphavantage.co/documentation/). Until the there is some code changed, you could create a TimeSeries object with the output_format="csv" to force it to csv and then convert it to pandas yourself.
ts = TimeSeries(key=API_KEY, output_format='csv')
@Camelket Thank you for the answer, however I can not manage to convert it. After browsing for answers on how to do that I found that "pandas.read_csv" can be used, but It only works with a file that has a path to it. I have to mention that I use Google's Colab online platform to write my code. How should we convert "ts" or "data". Your attention is much appreciated.
Found out a way to get what I need here: https://github.com/RomelTorres/alpha_vantage/issues/269#issuecomment-748413167
Just use pandas.read_csv('URL')
@kalink0v iirc TimeSeries first output is a _csv.reader object if output_format="csv". So you could use (assuming it has headers):
csv_list = list(_csv.reader) df = pandas.DataFrame.from_records(csv_list[1:], columns=csv_list[0])
There is mostlikely a better way to do this. Never used the Google colab platform myself, so I hope this works for you. If you want a more fixed version check out this pull request: https://github.com/RomelTorres/alpha_vantage/pull/297
Temporarily closing this issue due to a prolonged period since the last response was posted. Will re-open if needed.
alpha_vantage version 2.3.1 This is my python code:
`from alpha_vantage.timeseries import TimeSeries
auth = "my key" ticker ="TSLA" time = TimeSeries(key=auth) data = time.get_intraday_extended(ticker)`
According to the timeseries.py, this method will give a defaut interval = "15min" and slice = "year1month1"
Here is the output I get from this code:
C:/Users/AlphaDelta/PycharmProjects/projectOne/test/testBug.py Traceback (most recent call last): File "C:\Users\AlphaDelta\PycharmProjects\projectOne\test\testBug.py", line 6, in
data = time.get_intraday_extended(ticker)
File "C:\Users\AlphaDelta\PycharmProjects\projectOne\venv\lib\site-packages\alpha_vantage\alphavantage.py", line 218, in _format_wrapper
call_response, data_key, meta_data_key = func(
File "C:\Users\AlphaDelta\PycharmProjects\projectOne\venv\lib\site-packages\alpha_vantage\alphavantage.py", line 160, in _call_wrapper
return self._handle_api_call(url), data_key, meta_data_key
File "C:\Users\AlphaDelta\PycharmProjects\projectOne\venv\lib\site-packages\alpha_vantage\alphavantage.py", line 354, in _handle_api_call
json_response = response.json()
File "C:\Users\AlphaDelta\PycharmProjects\projectOne\venv\lib\site-packages\requests\models.py", line 891, in json
return complexjson.loads(
File "C:\Users\AlphaDelta\AppData\Local\Programs\Python\Python39\lib\json__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\AlphaDelta\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\AlphaDelta\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Process finished with exit code 1