quandl / quandl-python

MIT License
1.36k stars 336 forks source link

NotFoundError: (Status 404) (Quandl Error QECx02) You have submitted an incorrect Quandl code. Please check your Quandl codes and try again. #130

Closed RedBullTrend closed 5 years ago

RedBullTrend commented 5 years ago

NotFoundError Traceback (most recent call last)

in () 1 for abbv in fiddy_states[0][0][1:]: 2 query = "FMAC/HPI_"+str(abbv) ----> 3 df = Quandl.get(query, authtoken=api_key) 4 5 if main_df.empty: ~\Anaconda3\lib\site-packages\quandl\get.py in get(dataset, **kwargs) 46 if dataset_args['column_index'] is not None: 47 kwargs.update({'column_index': dataset_args['column_index']}) ---> 48 data = Dataset(dataset_args['code']).data(params=kwargs, handle_column_not_found=True) 49 # Array 50 elif isinstance(dataset, list): ~\Anaconda3\lib\site-packages\quandl\model\dataset.py in data(self, **options) 45 updated_options = Util.merge_options('params', params, **options) 46 try: ---> 47 return Data.all(**updated_options) 48 except NotFoundError: 49 if handle_not_found_error: ~\Anaconda3\lib\site-packages\quandl\operations\list.py in all(cls, **options) 13 options['params'] = {} 14 path = Util.constructed_path(cls.list_path(), options['params']) ---> 15 r = Connection.request('get', path, **options) 16 response_data = r.json() 17 Util.convert_to_dates(response_data) ~\Anaconda3\lib\site-packages\quandl\connection.py in request(cls, http_verb, url, **options) 36 abs_url = '%s/%s' % (ApiConfig.api_base, url) 37 ---> 38 return cls.execute_request(http_verb, abs_url, **options) 39 40 @classmethod ~\Anaconda3\lib\site-packages\quandl\connection.py in execute_request(cls, http_verb, url, **options) 45 response = session.request(method=http_verb, url=url, **options) 46 if response.status_code < 200 or response.status_code >= 300: ---> 47 cls.handle_api_error(response) 48 else: 49 return response ~\Anaconda3\lib\site-packages\quandl\connection.py in handle_api_error(cls, resp) 109 klass = d_klass.get(code_letter, QuandlError) 110 --> 111 raise klass(message, resp.status_code, resp.text, resp.headers, code) NotFoundError: (Status 404) (Quandl Error QECx02) You have submitted an incorrect Quandl code. Please check your Quandl codes and try again. So far I have not found any solutions. Could anyone help me with this? Thank you, Richard.
VictorZhang2014 commented 5 years ago

What is the value of str(abbv)? I guess that you entered a wrong stock code to quandl

RedBullTrend commented 5 years ago

Hello, thank you for answer. Here is my code:

import quandl as Quandl

import pandas as pd

import pickle

api_key = open('quandl_api_key.txt','r').read()

fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')

main_df = pd.DataFrame()

for abbv in fiddystates[0][0][1:]: query = "FMAC/HPI"+str(abbv) df = Quandl.get(query, authtoken=api_key)

if main_df.empty:
    main_df = df
else:
    main_df = main_df.join(df)

Then I saw the error above

fengshuo commented 5 years ago

Hi @RedBullTrend, it looks like you were trying to query data from the Freddie Mac Product. The error you saw is caused by invalid area code passed to quandl.get().

If you go to the documentation page of FMAC, you should see a table with area codes and corresponding quandl code, such as Abilene TX | 10180 | FMAC/HPI_10180.

fengshuo commented 5 years ago

We are going to close off this issue but if you have any further questions about data products, feel free to contact our support team via the quandl.com website.

samayo commented 4 years ago

I am having the same issue. For example, in this page: https://blog.quandl.com/api-for-commodity-data I can see two example APIs listed

http://www.quandl.com/api/v3/datasets/WORLDBANK/WLD_TEA_MOMBASA http://www.quandl.com/api/v3/datasets/WORLDBANK/WLD_PHOSROCK

Both of them show the same error.

{
  "quandl_error": {
    "code": "QECx02",
    "message": "You have submitted an incorrect Quandl code. Please check your Quandl codes and try again."
  }
}

I can't tell if the web is defunct or I have forgotten something. I don't think I have, as I see no placeholder for a KEY or anything that suggests I am doing something wrong, so it looks like this is a bug

bcaton85 commented 3 years ago

Using just a curl with example here gives the same issue: curl http://www.quandl.com/api/v3/datasets/ZILL/Z90210_SPY.csv?api_token=[token]