Thank you very much for sharing this nice code. I am trying to use loop to get ALFRED data using your function. At some point in the loop, I get error message like below. When I manually execute the command at that point, it does work. Can I ask why this happens? Is it because of I am extracting data from the server too fast?
Error using xmlread (line 116)
Java exception occurred:
java.io.IOException: Server returned HTTP response code: 429 for URL:
https://api.stlouisfed.org/fred/series?series_id=COMPNFB&observation_start=1949-10-01&observation_end=2015-12-02&units=lin&frequency=q&aggregation_method=avg&realtime_start=2015-12-02&realtime_end=2015-12-02&api_key=190e4c2ccb2c648cd2cf41d0b1999b96
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
Error in getFredData (line 116)
xDoc=xmlread(['https://api.stlouisfed.org/fred/series?series_id=',series_id,optionstring,'&api_key=',api_key]);