Search code examples
pythonpython-3.xmachine-learningquandl

Quandl is not working, some error is popping out


I am trying to import Quandl data using the following instruction:

quandl.get('WIKI/GOOGL')

The following error getting popped out:

Traceback (most recent call last):
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/connection.py", line 55, in parse
    return response.json()
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/requests/models.py", line 850, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/shravilp/anaconda3/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/home/shravilp/anaconda3/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/shravilp/anaconda3/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ml1.py", line 4, in <module>
    df = quandl.get('WIKI/GOOGL')
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/get.py", line 48, in get
    data = Dataset(dataset_args['code']).data(params=kwargs, handle_column_not_found=True)
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/model/dataset.py", line 47, in data
    return Data.all(**updated_options)
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/operations/list.py", line 14, in all
    r = Connection.request('get', path, **options)
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/connection.py", line 36, in request
    return cls.execute_request(http_verb, abs_url, **options)
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/connection.py", line 44, in execute_request
    cls.handle_api_error(response)
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/connection.py", line 61, in handle_api_error
    error_body = cls.parse(resp)
  File "/home/shravilp/anaconda3/lib/python3.6/site-packages/quandl/connection.py", line 57, in parse
    raise QuandlError(http_status=response.status_code, http_body=response.text)
quandl.errors.quandl_error.QuandlError: (Status 403) Something went wrong. Please try again. If you continue to have problems, please contact us.

Following is my code:

import pandas as pd
import quandl
df = quandl.get("FRED/GDP")
print(df.head())

Solution

  • An error 403, as stated on the Quandl API docs states that you need an API key to access that. Here are the steps to rectify it-

    1.Create a free/premium account on Quandl.

    2.Generate an API key from account settings options.

    3.Include your API key in the script as, quandl.ApiConfig.api_key = "YOURAPIKEY".