mortada / fredapi

Python API for FRED (Federal Reserve Economic Data) and ALFRED (Archival FRED)
Apache License 2.0
902 stars 159 forks source link

Question: Bad Request. The value for variable api_key is not registered. #45

Open Yushan-Liu opened 2 years ago

Yushan-Liu commented 2 years ago

Dear developer,

I want to request 5 datasets, in total there are probably 2000 data points. Sometimes I can get them all without any issue. However, most of times after getting 2 or 3 datasets, the API threw an error "The value for variable api_key is not registered.". I googled online and it seems most people can get way more data points than me without a problem.

Here is how I query all my five datasets.

fred = Fred(api_key='xxxxxxxxxxxxxxxxx')

fetch_start_date='2000-01-01'

UMich_CCI_df = fred.get_series('UMCSENT', observation_start=fetch_start_date)
time.sleep(5)
Gas_Price_df = fred.get_series('GASREGCOVM', observation_start=fetch_start_date)
time.sleep(5)
GDP_Annual_Rate = fred.get_series('CPGDPAI', observation_start=fetch_start_date)
time.sleep(5)
Housing_Starts_df = fred.get_series('HOUST', observation_start=fetch_start_date)
time.sleep(5)
Unemployment_Rate_df = fred.get_series('UNRATE', observation_start=fetch_start_date)

I registered my API yesterday and pass it directly as the 'api_key' parameter. I am wondering if I am doing anything wrong here so I cannot always get all datasets.

I use Python 3.6 in conda environment. the Pandas version is 1.1.5.

I am sure this is not a bug in your repo but I just couldn't find a solution and don't understand why. Really appreciate if you can provide any help.

Best regards,

Yushan-Liu commented 2 years ago

I also send an email to Fred to ask the limitation of API usage. Here is the response I got:

Thank you for your message. The FRED API allows 1000 items per request, with a rate limit of 120 requests per minute.

Have a great day, FRED Team

I feel my request does not exceed the limits.

TomasKoutek commented 2 years ago

Thank you for sharing answer with limits.