The Federal Reserve Economic Data (FRED) database, provided by the Federal Reserve Bank of St. Louis, is one of the most widely used sources for U.S. and international macroeconomic time series. It offers access to hundreds of thousands of economic indicators—from unemployment rates and GDP to financial market data, all freely available to researchers, students, and the public.
FRED’s web interface is excellent for browsing or quick downloads, but the FRED API is essential if you want to:
Download data programmatically (for Python, R, Stata, etc.)
Automate updates for your datasets and research projects
Pull large sets of series or timeframes
To use the API, you’ll need a free API key!
Create a FRED account:
Go to FRED API Key Signup and sign in (or register if you don’t have an account).
Request an API key:
Once logged in, you’ll see an option to generate your key. FRED will display it—copy and save it somewhere secure (don’t share it publicly).
Keep your API key private:
Treat your key like a password. Don’t publish it in public GitHub repos or on websites.
This example below demonstrates how to securely connect to the FRED service using Python. With just a few lines of code, you can pull and visualize a wide range of U.S. macroeconomic time series directly from the official FRED API.
To keep your data safe, this demo uses Python’s getpass library to securely enter your API key (for example, copying it from your LastPass vault), so your key never appears in your notebook or code files.