{"id":4018,"library":"fredapi","title":"FRED API Client","description":"fredapi is a Python API for Federal Reserve Economic Data (FRED) from the St. Louis Fed, and also provides methods for analyzing point-in-time data from ALFRED. It leverages pandas for data output, returning data as Series or DataFrames. The current version is 0.5.2, with a release cadence of a few updates per year, primarily addressing Python and dependency compatibility.","status":"active","version":"0.5.2","language":"en","source_language":"en","source_url":"https://github.com/mortada/fredapi","tags":["finance","economics","data","fred","api-client","pandas"],"install":[{"cmd":"pip install fredapi","lang":"bash","label":"Install fredapi"}],"dependencies":[{"reason":"Core data structures (Series, DataFrame) for API responses.","package":"pandas","optional":false}],"imports":[{"symbol":"Fred","correct":"from fredapi import Fred"}],"quickstart":{"code":"import os\nfrom fredapi import Fred\n\n# Get a FRED API key from https://fred.stlouisfed.org/docs/api/api_key.html\n# Set it as an environment variable or pass directly.\napi_key = os.environ.get('FRED_API_KEY', 'YOUR_FRED_API_KEY')\n\nif not api_key or api_key == 'YOUR_FRED_API_KEY':\n    print(\"Warning: FRED_API_KEY environment variable not set or placeholder used. Get a key from fred.stlouisfed.org.\")\n    # Using a dummy key to allow the example to run without immediate error,\n    # but API calls will fail without a valid key.\n    api_key = 'abcdefghijklmnopqrstuvwxyz123456'\n\nfred = Fred(api_key=api_key)\n\n# Fetch a specific economic data series (e.g., S&P 500)\ndata = fred.get_series('SP500')\n\nprint(\"Fetched S&P 500 data (last 5 entries):\")\nprint(data.tail())\n\n# Search for data series\nsearch_results = fred.search('unemployment rate')\nprint(\"\\nSearch results for 'unemployment rate' (first 3):\")\nprint(search_results[['id', 'title']].head(3))","lang":"python","description":"Initialize the Fred client with your API key, then fetch or search for economic data series. Data is returned as a pandas Series or DataFrame."},"warnings":[{"fix":"Apply for a FRED API key at https://fred.stlouisfed.org/docs/api/api_key.html and configure it as an environment variable (`export FRED_API_KEY='your_key'`) or pass it directly: `fred = Fred(api_key='your_key')`.","message":"An API key is mandatory for all requests. You can obtain one for free from the FRED website. Ensure it's set as the 'FRED_API_KEY' environment variable or passed directly to the `Fred` constructor.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade fredapi to version 0.5.1 or newer: `pip install --upgrade fredapi`. This version replaced `DataFrame.append` with `pd.concat`.","message":"Older versions of fredapi (<0.5.1) used `DataFrame.append`, which is deprecated in newer pandas versions. Using such old fredapi versions with modern pandas will lead to `FutureWarning`s or errors.","severity":"breaking","affected_versions":"<0.5.1"},{"fix":"Upgrade fredapi to version 0.3.7 or newer: `pip install --upgrade fredapi`. This version switched to using HTTPS for all FRED API calls.","message":"Versions of fredapi prior to 0.3.7 used HTTP for API calls. FRED's API primarily uses HTTPS. Using very old versions might result in connection errors if FRED no longer supports HTTP for certain endpoints.","severity":"breaking","affected_versions":"<0.3.7"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}