mortada / fredapi

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

Receiving an AttributeError indicating that the API is returning XML data #50

Closed kburchfiel closed 1 year ago

kburchfiel commented 2 years ago

After installing the latest version of fredapi and running the following code (from the library homepage):

from fredapi import Fred
fred = Fred(api_key=fred_key)
data = fred.get_series('SP500')

I received the following error message:

[AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren']()

It seems as though the API is retrieving XML data. How can I resolve this?

kburchfiel commented 2 years ago

Update: I installed the latest version available on conda-forge (0.42), but this is less recent than the version available through pip (0.50). After using pip to install the latest version, the code worked. So the error is probably related to conda-forge's outdated fredapi version.

mortada commented 2 years ago

yes this issue should have been solved since version 0.4.3, similar discussion here: https://github.com/mortada/fredapi/issues/41