Security error using fred/fetch

147 views (last 30 days)
Luca
Luca on 26 Jul 2025
Edited: Edu Benet Cerda on 3 Sep 2025 at 15:36
Hi,
I recently updated the Mac software to Sequoia, and started to receive the following error for a code that has always worked before:
Error using fred/fetch
Unable to retrieve data. Verify valid security request.
Do you know how to fix this? I have updated the Matlab version to the latest, and the error still persists.
Thanks!
  11 Comments
Gauthier
Gauthier on 29 Jul 2025
Moved: dpb on 29 Jul 2025
Hi,
Same error with MATLAB R2024b and windows OS.
Best
Yvan Becard
Yvan Becard on 19 Aug 2025 at 17:56
Same error with MATLAB R2025a and Ubuntu 24.04.3 LTS

Sign in to comment.

Accepted Answer

Meet
Meet on 29 Jul 2025
Hi Luca,
I was facing a similar issue and figured out that the FRED website recently changed its API and the built-in "fetch" command is no longer able to access the data. This issue can be resolved by downloading the updated "fetch" function and replacing the old function in the toolbox.
Please rename the MATLAB Script "fetch" to "fetch_old" in the below folder on your macOS:
/Applications/MATLAB_R2025a/toolbox/datafeed/datafeed/@fred/
After, please insert the new "fetch" function into the above location. After doing so, the "fetch" function will be able to retrieve data from the FRED website. This set of operations may require administrator privileges.
Note that because of this API change, the output of "fetch" is slightly different and now only includes "SeriesID" and "Data". Also, the "Data" field in the return structure now contains a cell array with an array of doubles, a table or a timetable depending on the input property "DataReturnFormat". Previously, it was either an array of doubles, a table or a timetable not nested in a cell array.
An alternative solution is to use the https://www.mathworks.com/matlabcentral/fileexchange/68247-fred-rest-for-matlab support package on MATLAB File exchange. However, this requires an API key from the FRED website, and has some syntactical changes.
I hope this helps resolve the issue!
  6 Comments
Yvan Becard
Yvan Becard on 3 Sep 2025 at 13:57
I was redirected to this page by a Matlab employee:
Does anyone know how to make FRED© REST work?
Edu Benet Cerda
Edu Benet Cerda on 3 Sep 2025 at 14:42
Edited: Edu Benet Cerda on 3 Sep 2025 at 15:36
get an API key from the fred website: St. Louis Fed Web Services: API Key
And the code as:
c = fredrs(<KEY>);
tt = c.series('NYGDPPCAPKDWLD','observations');
tt.observations{1}
Follow the api options described here:

Sign in to comment.

More Answers (0)

Categories

Find more on Help and Support in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!