-
Notifications
You must be signed in to change notification settings - Fork 3
Usage
This documentation will guide you through using the Command-line Interface and the fred-py-api
python package, from installation to fetching datasets & more in notime!
Installation using brew
:
- Simple install - one command:
$ brew install fred
- Basic Command-line usage:
$ export FRED_API_KEY="<your API key>" # or you can pass the key into the command! $ $ fred series get-series-observations --series-id DFF limit=1 sort_order=desc # will return JSON string by default $ $ fred series get-series-observations -i DFF limit=1 sort_order=desc file_type=xml # will return XML string $ $ fred --api-key <your api key> series get-series-observations --series-id DFF limit=1 sort_order=desc
Installation using pip
:
- Create a new python virtual environment:
$ python3 -m venv env $ source env/bin/activate $ pip install -U pip
- Install FRED Python API:
$ pip install fred-py-api
- Basic Python usage using environment variables:
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPI >>> client = FredAPI() >>> client.get_series_observations("dff", observation_start="2022-06-01")
The FRED CLI includes several namespaces each with their own subcommands.
$ fred --help
Usage: fred [OPTIONS] COMMAND [ARGS]...
CLI for the Federal Reserve Economic Data (FRED).
Options:
--api-key TEXT FRED API key.
--help Show this message and exit.
Commands:
categories Categories CLI Namespace.
releases Releases CLI Namespace.
series Series CLI Namespace.
sources Sources CLI Namespace.
tags Tags CLI Namespace.
To view a namespace's subcommands, you can invoke the --help
option on any of the namespaces.
$ fred categories --help
Usage: categories [OPTIONS] COMMAND [ARGS]...
Categories CLI Namespace.
Options:
--api-key TEXT FRED API key.
--help Show this message and exit.
Commands:
get-category Get a category.
get-category-children Get the child categories.
get-category-related Get related categories.
get-category-related-tags Get related FRED tags for a category.
get-category-series Get series in a category.
get-category-tags Get FRED tags for a category.
Note: You can also invoke the subcommand directly for less typing!
$ categories --help
Usage: categories [OPTIONS] COMMAND [ARGS]...
Categories CLI Namespace.
Options:
--api-key TEXT FRED API key.
--help Show this message and exit.
Commands:
get-category Get a category.
get-category-children Get the child categories.
get-category-related Get related categories.
get-category-related-tags Get related FRED tags for a category.
get-category-series Get series in a category.
get-category-tags Get FRED tags for a category.
To see any options that a subcommand has, you can invoke the --help
option on any of the subcommands within a namespace.
$ fred series get-series-observations --help
Usage: fred series get-series-observations [OPTIONS] [ARGS]...
Get series observations.
Options:
-i, --series-id TEXT Series ID. [required]
--help Show this message and exit.
Additionally, you can pass in any endpoint parameters specified in FRED's documentation as follows (example with a limit
and file_type
specified).
$ fred series get-series-observations -i dff limit=1 file_type=xml
<observations realtime_start="2024-01-04" realtime_end="2024-01-04" observation_start="1600-01-01" observation_end="9999-12-31" units="lin" output_type="1" file_type="xml" order_by="observation_date" sort_order="asc" count="25389" offset="0" limit="1">
<observation realtime_start="2024-01-04" realtime_end="2024-01-04" date="1954-07-01" value="1.13" />
</observations>
The default data output format is JSON.
Some useful examples:
- Get latest Fed Funds Rate in JSON
$ fred series get-series-observations -i dff limit=1 sort_order=desc
- Get latest Fed Funds Rate in XML
$ fred series get-series-observations -i dff limit=1 sort_order=desc file_type=xml
- Redirect output to a file
$ fred series get-series-observations -i dff limit=1 sort_order=desc file_type=xml > latest-fed-funds-rate.xml
Make sure you have a FRED API key. If you need to obtain one, please follow the instructions HERE.
- Initialize client using environment variables:
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPI >>> client = FredAPI() >>> client.get_category()
- Initialize client using an explicit API key:
>>> from fred import FredAPI >>> client = FredAPI("<your API key>") >>> client.get_category_tags(15)
- Initialize client using another client object:
>>> from fred import FredAPI >>> client = FredAPI(api_key="<your API key>") >>> another_client = FredAPI(base_client=client) >>> client.get_category_children(15) >>> another_client.get_series_observations("GNPCA")
This library was designed to be modular, and attempts to follow "The Zen of Python" as closely as possible. Each endpoint namespace that exists in FRED also exists in this library, and can be used separately as its own client.
- Categories Client
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPICategories >>> categories_client = FredAPICategories() # only Categories endpoints
- Releases Client
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPIReleases >>> releases_client = FredAPIReleases() # only Releases endpoints
- Series Client
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPISeries >>> series_client = FredAPISeries() # only Series endpoints
- Sources Client
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPISources >>> sources_client = FredAPISources() # only Sources endpoints
- Tags Client
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPITags >>> tags_client = FredAPITags() # only Tags endpoints
- General Client
$ export FRED_API_KEY="<your API key>" $ python3 >>> from fred import FredAPI >>> client = FredAPI() # contains all endpoints
$ python3
>>> from fred import FredAPICategories
>>> client = FredAPICategories()
-
fred/category -> Get a category.
>>> client.get_category(125) # JSON {'categories': [{'id': 125, 'name': 'Trade Balance', 'parent_id': 13}]} >>> >>> xml_data = client.get_category(125, file_type="xml") # XML >>> xml_data <Element 'categories' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '125', 'name': 'Trade Balance', 'parent_id': '13'} >>>
-
fred/category/children -> Get the child categories for a specified parent category.
>>> client.get_category_children(13) # JSON {'categories': [{'id': 16, 'name': 'Exports', 'parent_id': 13}, {'id': 17, 'name': 'Imports', 'parent_id': 13}, {'id': 3000, 'name': 'Income Payments & Receipts', 'parent_id': 13}, {'id': 33705, 'name': 'International Investment Position', 'parent_id': 13}, {'id': 125, 'name': 'Trade Balance', 'parent_id': 13}, {'id': 127, 'name': 'U.S. International Finance', 'parent_id': 13}]} >>> >>> xml_data = client.get_category_children(13, file_type="xml") # XML >>> xml_data <Element 'categories' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '16', 'name': 'Exports', 'parent_id': '13'} {'id': '17', 'name': 'Imports', 'parent_id': '13'} {'id': '3000', 'name': 'Income Payments & Receipts', 'parent_id': '13'} {'id': '33705', 'name': 'International Investment Position', 'parent_id': '13'} {'id': '125', 'name': 'Trade Balance', 'parent_id': '13'} {'id': '127', 'name': 'U.S. International Finance', 'parent_id': '13'} >>>
-
fred/category/related -> Get the related categories for a category
>>> client.get_category_related(32073) # JSON {'categories': [{'id': 149, 'name': 'Arkansas', 'parent_id': 27281}, {'id': 150, 'name': 'Illinois', 'parent_id': 27281}, {'id': 151, 'name': 'Indiana', 'parent_id': 27281}, {'id': 152, 'name': 'Kentucky', 'parent_id': 27281}, {'id': 153, 'name': 'Mississippi', 'parent_id': 27281}, {'id': 154, 'name': 'Missouri', 'parent_id': 27281}, {'id': 193, 'name': 'Tennessee', 'parent_id': 27281}]} >>> >>> xml_data = client.get_category_related(32073, file_type="xml") # XML >>> xml_data <Element 'categories' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '149', 'name': 'Arkansas', 'parent_id': '27281'} {'id': '150', 'name': 'Illinois', 'parent_id': '27281'} {'id': '151', 'name': 'Indiana', 'parent_id': '27281'} {'id': '152', 'name': 'Kentucky', 'parent_id': '27281'} {'id': '153', 'name': 'Mississippi', 'parent_id': '27281'} {'id': '154', 'name': 'Missouri', 'parent_id': '27281'} {'id': '193', 'name': 'Tennessee', 'parent_id': '27281'} >>>
-
fred/category/series -> Get the series in a category.
>>> client.get_category_series(125, limit = 1) # JSON {'realtime_start': '2022-07-21', 'realtime_end': '2022-07-21', 'order_by': 'series_id', 'sort_order': 'asc', 'count': 47, 'offset': 0, 'limit': 1, 'seriess': [{'id': 'AITGCBN', 'realtime_start': '2022-07-21', 'realtime_end': '2022-07-21', 'title': 'Advance U.S. International Trade in Goods: Balance', 'observation_start': '2022-05-01', 'observation_end': '2022-05-01', 'frequency': 'Monthly', 'frequency_short': 'M', 'units': 'Millions of Dollars', 'units_short': 'Mil. of $', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2022-06-28 07:31:13-05', 'popularity': 2, 'group_popularity': 21, 'notes': 'This advance estimate represents the current month statistics of nearly complete coverage. The current month statistics reflecting complete coverage is available on the Census website at the U.S. International Trade in Goods and Services report (FT-900) https://www.census.gov/foreign-trade/statistics/historical/index.html \n\nFor more information on data collection and methodology, see https://www.census.gov/econ/indicators/methodology.html'}]} >>> >>> xml_data = client.get_category_series(125, file_type="xml") # XML >>> xml_data <Element 'seriess' at 0x1021414a0> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': 'AITGCBN', 'realtime_start': '2022-07-21', 'realtime_end': '2022-07-21', 'title': 'Advance U.S. International Trade in Goods: Balance', 'observation_start': '2022-05-01', 'observation_end': '2022-05-01', 'frequency': 'Monthly', 'frequency_short': 'M', 'units': 'Millions of Dollars', 'units_short': 'Mil. of $', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2022-06-28 07:31:13-05', 'popularity': '2', 'group_popularity': '21', 'notes': 'This advance estimate represents the current month statistics of nearly complete coverage. The current month statistics reflecting complete coverage is available on the Census website at the U.S. International Trade in Goods and Services report (FT-900) https://www.census.gov/foreign-trade/statistics/historical/index.html For more information on data collection and methodology, see https://www.census.gov/econ/indicators/methodology.html'} >>>
-
fred/category/tags -> Get the FRED tags for a category.
>>> client.get_category_tags(125) # JSON {'realtime_start': '2022-07-21', 'realtime_end': '2022-07-21', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 27, 'offset': 0, 'limit': 3, 'tags': [{'name': 'bea', 'group_id': 'src', 'notes': 'Bureau of Economic Analysis', 'created': '2012-02-27 10:18:19-06', 'popularity': 78, 'series_count': 52}, {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 99, 'series_count': 52}, {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': None, 'created': '2018-12-17 23:33:13-06', 'popularity': 99, 'series_count': 52}]} >>> >>> xml_data = client.get_category_series(125, file_type="xml", limit = 3) # XML >>> xml_data <Element 'tags' at 0x102141180> >>> for category in list(xml_data): ... print(category.attrib) ... {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '99', 'series_count': '40'} {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': '', 'created': '2018-12-17 23:33:13-06', 'popularity': '99', 'series_count': '40'} {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '40'} >>>
-
fred/category/related_tags -> Get the related FRED tags for one or more FRED tags within a category.
>>> client.get_category_related_tags(125, tag_names = "services") # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 15, 'offset': 0, 'limit': 1000, 'tags': [{'name': 'balance', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 46, 'series_count': 10}, {'name': 'bea', 'group_id': 'src', 'notes': 'Bureau of Economic Analysis', 'created': '2012-02-27 10:18:19-06', 'popularity': 78, 'series_count': 10}, {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 99, 'series_count': 10}, {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': None, 'created': '2018-12-17 23:33:13-06', 'popularity': 99, 'series_count': 10}, {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America', 'created': '2012-02-27 10:18:19-06', 'popularity': 100, 'series_count': 10}, {'name': 'discontinued', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 66, 'series_count': 6}, {'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': 99, 'series_count': 6}, {'name': 'annual', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 88, 'series_count': 4}, {'name': 'quarterly', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 84, 'series_count': 4}, {'name': 'sa', 'group_id': 'seas', 'notes': 'Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': 88, 'series_count': 4}, {'name': 'census', 'group_id': 'src', 'notes': 'Census', 'created': '2012-02-27 10:18:19-06', 'popularity': 79, 'series_count': 2}, {'name': 'goods', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 69, 'series_count': 2}, {'name': 'monthly', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 95, 'series_count': 2}, {'name': 'payments', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 39, 'series_count': 2}, {'name': 'trade', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 55, 'series_count': 2}]} >>> >>> xml_data = client.get_category_related_tags(125, tag_names = "services", file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x102141180> >>> for category in list(xml_data): ... print(category.attrib) ... {'name': 'balance', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '46', 'series_count': '18'} {'name': 'bea', 'group_id': 'src', 'notes': 'Bureau of Economic Analysis', 'created': '2012-02-27 10:18:19-06', 'popularity': '78', 'series_count': '18'} {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '99', 'series_count': '18'} {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': '', 'created': '2018-12-17 23:33:13-06', 'popularity': '99', 'series_count': '18'} {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '18'} {'name': 'goods', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '69', 'series_count': '12'} {'name': 'quarterly', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '84', 'series_count': '12'} {'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': '99', 'series_count': '10'} {'name': 'sa', 'group_id': 'seas', 'notes': 'Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': '88', 'series_count': '8'} {'name': 'discontinued', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '66', 'series_count': '6'} {'name': 'annual', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '88', 'series_count': '4'} {'name': 'bop', 'group_id': 'gen', 'notes': 'Balance of Payments', 'created': '2013-01-28 14:10:13-06', 'popularity': '46', 'series_count': '2'} {'name': 'census', 'group_id': 'src', 'notes': 'Census', 'created': '2012-02-27 10:18:19-06', 'popularity': '79', 'series_count': '2'} {'name': 'headline figure', 'group_id': 'gen', 'notes': '', 'created': '2013-11-19 13:55:53-06', 'popularity': '53', 'series_count': '2'} {'name': 'monthly', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '95', 'series_count': '2'} {'name': 'trade', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '55', 'series_count': '2'} >>>
$ python3
>>> from fred import FredAPIReleases
>>> client = FredAPIReleases()
-
fred/releases -> Get all releases of economic data.
>>> client.get_releases(limit = 1) # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'order_by': 'release_id', 'sort_order': 'asc', 'count': 307, 'offset': 0, 'limit': 1, 'releases': [{'id': 9, 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'Advance Monthly Sales for Retail and Food Services', 'press_release': True, 'link': 'http://www.census.gov/retail/', 'notes': 'The U.S. Census Bureau conducts the Advance Monthly Retail Trade and Food Services Survey to provide an early estimate of monthly sales by kind of business for retail and food service firms located in the United States. Each month, questionnaires are mailed to a probability sample of approximately 4,700 employer firms selected from the larger Monthly Retail Trade Survey. Advance sales estimates are computed using a link relative estimator. For each detailed industry, we compute a ratio of current-to previous month weighted sales using data from units for which we have obtained usable responses for both the current and previous month. For each detailed industry, the advance total sales estimates for the current month is computed by multiplying this ratio by the preliminary sales estimate for the previous month (derived from the larger MRTS) at the appropriate industry level. Total estimates for broader industries are computed as the sum of the detailed industry estimates. The link relative estimate is used because imputation is not performed for most nonrespondents in MARTS. For a limited number of nonresponding companies that have influential effects on the estimates, sales may be estimated based on historical performance of that company. The monthly estimates are benchmarked to the annual survey estimates from the Annual Retail Trade Survey once available. The estimates are adjusted for seasonal variation and holiday and trading day differences. Additional information on MARTS and MRTS can be found on the Census Bureau website at: www.census.gov/retail.\r\nDescription of the survey as provided by the Census, https://census.gov/retail/marts/www/marts_current.pdf'}]} >>> >>> xml_data = client.get_releases(limit = 1, file_type = "xml") # XML >>> xml_data <Element 'releases' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '9', 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'Advance Monthly Sales for Retail and Food Services', 'press_release': 'true', 'link': 'http://www.census.gov/retail/', 'notes': 'The U.S. Census Bureau conducts the Advance Monthly Retail Trade and Food Services Survey to provide an early estimate of monthly sales by kind of business for retail and food service firms located in the United States. Each month, questionnaires are mailed to a probability sample of approximately 4,700 employer firms selected from the larger Monthly Retail Trade Survey. Advance sales estimates are computed using a link relative estimator. For each detailed industry, we compute a ratio of current-to previous month weighted sales using data from units for which we have obtained usable responses for both the current and previous month. For each detailed industry, the advance total sales estimates for the current month is computed by multiplying this ratio by the preliminary sales estimate for the previous month (derived from the larger MRTS) at the appropriate industry level. Total estimates for broader industries are computed as the sum of the detailed industry estimates. The link relative estimate is used because imputation is not performed for most nonrespondents in MARTS. For a limited number of nonresponding companies that have influential effects on the estimates, sales may be estimated based on historical performance of that company. The monthly estimates are benchmarked to the annual survey estimates from the Annual Retail Trade Survey once available. The estimates are adjusted for seasonal variation and holiday and trading day differences. Additional information on MARTS and MRTS can be found on the Census Bureau website at: www.census.gov/retail. Description of the survey as provided by the Census, https://census.gov/retail/marts/www/marts_current.pdf'} >>>
-
fred/releases/dates -> Get release dates for all releases of economic data.
>>> client.get_releases_dates(limit = 1) # JSON {'realtime_start': '2022-01-01', 'realtime_end': '9999-12-31', 'order_by': 'release_date', 'sort_order': 'desc', 'count': 4886, 'offset': 0, 'limit': 1, 'release_dates': [{'release_id': 441, 'release_name': 'Coinbase Cryptocurrencies', 'date': '2022-07-22'}]} >>> >>> xml_data = client.get_releases_dates(limit = 1, file_type = "xml") # XML >>> xml_data <Element 'release_dates' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib) ... {'release_id': '441', 'release_name': 'Coinbase Cryptocurrencies'} >>>
-
fred/release -> Get a release of economic data.
>>> client.get_release(53) # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'releases': [{'id': 53, 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'Gross Domestic Product', 'press_release': True, 'link': 'https://www.bea.gov/data/gdp/gross-domestic-product'}]} >>> >>> xml_data = client.get_release(53, file_type = "xml") # XML >>> xml_data <Element 'releases' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '53', 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'Gross Domestic Product', 'press_release': 'true', 'link': 'https://www.bea.gov/data/gdp/gross-domestic-product'} >>>
-
fred/release/dates -> Get release dates for a release of economic data.
>>> client.get_release_dates(82) # JSON {'realtime_start': '1776-07-04', 'realtime_end': '9999-12-31', 'order_by': 'release_date', 'sort_order': 'asc', 'count': 25, 'offset': 0, 'limit': 10000, 'release_dates': [{'release_id': 82, 'date': '1997-02-10'}, {'release_id': 82, 'date': '1998-02-10'}, {'release_id': 82, 'date': '1999-02-04'}, {'release_id': 82, 'date': '2000-02-10'}, {'release_id': 82, 'date': '2001-01-16'}, {'release_id': 82, 'date': '2002-02-06'}, {'release_id': 82, 'date': '2003-02-07'}, {'release_id': 82, 'date': '2004-02-09'}, {'release_id': 82, 'date': '2005-02-17'}, {'release_id': 82, 'date': '2006-02-13'}, {'release_id': 82, 'date': '2007-02-16'}, {'release_id': 82, 'date': '2008-02-11'}, {'release_id': 82, 'date': '2009-03-03'}, {'release_id': 82, 'date': '2010-02-11'}, {'release_id': 82, 'date': '2011-02-23'}, {'release_id': 82, 'date': '2012-10-24'}, {'release_id': 82, 'date': '2013-04-10'}, {'release_id': 82, 'date': '2014-03-14'}, {'release_id': 82, 'date': '2015-02-02'}, {'release_id': 82, 'date': '2016-03-11'}, {'release_id': 82, 'date': '2017-06-29'}, {'release_id': 82, 'date': '2018-02-12'}, {'release_id': 82, 'date': '2019-03-19'}, {'release_id': 82, 'date': '2020-02-20'}, {'release_id': 82, 'date': '2022-04-18'}]} >>> >>> xml_data = client.get_release_dates(82, file_type = "xml") # XML >>> xml_data <Element 'release_dates' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib, category.text) ... {'release_id': '82'} 1997-02-10 {'release_id': '82'} 1998-02-10 {'release_id': '82'} 1999-02-04 {'release_id': '82'} 2000-02-10 {'release_id': '82'} 2001-01-16 {'release_id': '82'} 2002-02-06 {'release_id': '82'} 2003-02-07 {'release_id': '82'} 2004-02-09 {'release_id': '82'} 2005-02-17 {'release_id': '82'} 2006-02-13 {'release_id': '82'} 2007-02-16 {'release_id': '82'} 2008-02-11 {'release_id': '82'} 2009-03-03 {'release_id': '82'} 2010-02-11 {'release_id': '82'} 2011-02-23 {'release_id': '82'} 2012-10-24 {'release_id': '82'} 2013-04-10 {'release_id': '82'} 2014-03-14 {'release_id': '82'} 2015-02-02 {'release_id': '82'} 2016-03-11 {'release_id': '82'} 2017-06-29 {'release_id': '82'} 2018-02-12 {'release_id': '82'} 2019-03-19 {'release_id': '82'} 2020-02-20 {'release_id': '82'} 2022-04-18 >>>
-
fred/release/series -> Get the series on a release of economic data.
>>> client.get_release_series(51, limit = 1) # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'order_by': 'series_id', 'sort_order': 'asc', 'count': 565, 'offset': 0, 'limit': 1, 'seriess': [{'id': 'BOMTVLM133S', 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'title': 'U.S. Imports of Services - Travel', 'observation_start': '1992-01-01', 'observation_end': '2017-09-01', 'frequency': 'Monthly', 'frequency_short': 'M', 'units': 'Million of Dollars', 'units_short': 'Mil. of $', 'seasonal_adjustment': 'Seasonally Adjusted', 'seasonal_adjustment_short': 'SA', 'last_updated': '2017-11-03 08:12:15-05', 'popularity': 1, 'group_popularity': 1, 'notes': 'Further information related to the international trade data can be found at https://www.census.gov/foreign-trade/data/index.html \nMethodology details can be found at https://www.census.gov/foreign-trade/Press-Release/current_press_release/explain.pdf'}]} >>> >>> xml_data = client.get_release_series(51, limit = 1, file_type = "xml") # XML >>> xml_data <Element 'seriess' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib, category.text) ... {'id': 'BOMTVLM133S', 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'title': 'U.S. Imports of Services - Travel', 'observation_start': '1992-01-01', 'observation_end': '2017-09-01', 'frequency': 'Monthly', 'frequency_short': 'M', 'units': 'Million of Dollars', 'units_short': 'Mil. of $', 'seasonal_adjustment': 'Seasonally Adjusted', 'seasonal_adjustment_short': 'SA', 'last_updated': '2017-11-03 08:12:15-05', 'popularity': '1', 'group_popularity': '1', 'notes': 'Further information related to the international trade data can be found at https://www.census.gov/foreign-trade/data/index.html Methodology details can be found at https://www.census.gov/foreign-trade/Press-Release/current_press_release/explain.pdf'} >>>
-
fred/release/sources -> Get the sources for a release of economic data.
>>> client.get_release_sources(51) # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'sources': [{'id': 19, 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'U.S. Census Bureau', 'link': 'http://www.census.gov/'}, {'id': 18, 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'U.S. Bureau of Economic Analysis', 'link': 'http://www.bea.gov/'}]} >>> >>> xml_data = client.get_release_sources(51, file_type = "xml") # XML >>> xml_data <Element 'sources' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib, category.text) ... {'id': '19', 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'U.S. Census Bureau', 'link': 'http://www.census.gov/'} {'id': '18', 'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'name': 'U.S. Bureau of Economic Analysis', 'link': 'http://www.bea.gov/'} >>>
-
fred/release/tags -> Get the FRED tags for a release.
>>> client.get_release_tags(86, limit = 1) # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 53, 'offset': 0, 'limit': 1, 'tags': [{'name': 'commercial', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 59, 'series_count': 214}]} >>> >>> xml_data = client.get_release_sources(51, file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib, category.text) ... {'name': 'commercial', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '59', 'series_count': '200'} >>>
-
fred/release/related_tags -> Get the related FRED tags for one or more FRED tags within a release.
>>> client.get_release_related_tags(86, tag_names = "sa;foreign", limit = 1) # JSON {'realtime_start': '2022-07-22', 'realtime_end': '2022-07-22', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 11, 'offset': 0, 'limit': 1, 'tags': [{'name': 'commercial', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 59, 'series_count': 6}]} >>> >>> xml_data = client.get_release_related_tags(86, tag_names = "sa;foreign", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib, category.text) ... {'name': 'commercial', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '59', 'series_count': '6'} >>>
-
fred/release/tables -> Get release table trees for a given release.
>>> client.get_release_tables(53) # JSON {'release_id': '53', 'elements': {'13690': {'element_id': 13690, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 1 - DOMESTIC PRODUCT AND INCOME', 'level': '0', 'children': []}, '4081': {'element_id': 4081, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 2 - PERSONAL INCOME AND OUTLAYS', 'level': '0', 'children': []}, '5221': {'element_id': 5221, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 3 - GOVERNMENT CURRENT RECEIPTS AND EXPENDITURES', 'level': '0', 'children': []}, '5402': {'element_id': 5402, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 4 - FOREIGN TRANSACTIONS', 'level': '0', 'children': []}, '7579': {'element_id': 7579, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 5 - SAVING AND INVESTMENT', 'level': '0', 'children': []}, '15424': {'element_id': 15424, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 6 - INCOME AND EMPLOYMENT BY INDUSTRY', 'level': '0', 'children': []}, '15425': {'element_id': 15425, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 7 - SUPPLEMENTAL TABLES', 'level': '0', 'children': []}, '291652': {'element_id': 291652, 'release_id': 53, 'series_id': None, 'parent_id': None, 'line': None, 'type': 'section', 'name': 'SECTION 8 - NOT SEASONALLY ADJUSTED', 'level': '0', 'children': []}}} >>> >>> xml_data = client.get_release_related_tags(86, tag_names = "sa;foreign", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'elements' at 0x102159810> >>> for category in list(xml_data): ... print(category.attrib, category.text) ... UNKNOWN HOW TO GET ATTRIBUTE >>>
$ python3
>>> from fred import FredAPISeries
>>> client = FredAPISeries()
-
fred/series -> Get an economic data series.
>>> client.get_series("GNPCA") # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'seriess': [{'id': 'GNPCA', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'Real Gross National Product', 'observation_start': '1929-01-01', 'observation_end': '2021-01-01', 'frequency': 'Annual', 'frequency_short': 'A', 'units': 'Billions of Chained 2012 Dollars', 'units_short': 'Bil. of Chn. 2012 $', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2022-03-30 07:55:26-05', 'popularity': 14, 'notes': 'BEA Account Code: A001RX\n\n'}]} >>> >>> xml_data = client.get_category(125, file_type="xml") # XML >>> xml_data <Element 'seriess' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': 'GNPCA', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'Real Gross National Product', 'observation_start': '1929-01-01', 'observation_end': '2021-01-01', 'frequency': 'Annual', 'frequency_short': 'A', 'units': 'Billions of Chained 2012 Dollars', 'units_short': 'Bil. of Chn. 2012 $', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2022-03-30 07:55:26-05', 'popularity': '14', 'notes': 'BEA Account Code: A001RX '} >>>
-
fred/series/category -> Get the categories for an economic data series.
>>> client.get_series_categories("EXJPUS") # JSON {'categories': [{'id': 95, 'name': 'Monthly Rates', 'parent_id': 15}, {'id': 275, 'name': 'Japan', 'parent_id': 158}]} >>> >>> xml_data = client.get_series_categories("EXJPUS", file_type="xml") # XML >>> xml_data <Element 'categories' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '95', 'name': 'Monthly Rates', 'parent_id': '15'} {'id': '275', 'name': 'Japan', 'parent_id': '158'} >>>
-
fred/series/observations -> Get the observations or data values for an economic data series.
>>> client.get_series_observations("GNPCA", limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'observation_start': '1600-01-01', 'observation_end': '9999-12-31', 'units': 'lin', 'output_type': 1, 'file_type': 'json', 'order_by': 'observation_date', 'sort_order': 'asc' , 'count': 93, 'offset': 0, 'limit': 1, 'observations': [{'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'date': '1929-01-01', 'value': '1120.718'}]} >>> >>> xml_data = client.get_series_observations("GNPCA", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'observations' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'date': '1929-01-01', 'value': '1120.718'} >>>
-
fred/series/release -> Get the release for an economic data series.
>>> client.get_series_release("IRA") # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'releases': [{'id': 21, 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'H.6 Money Stock Measures', 'press_release': True, 'link': 'http://www.federalreserve. gov/releases/h6/'}]} >>> >>> xml_data = client.get_series_release("IRA", file_type = "xml") # XML >>> xml_data <Element 'releases' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': '21', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'H.6 Money Stock Measures', 'press_release': 'true', 'link': 'http://www.federalreserve.gov/releases/h6/'} >>>
-
fred/series/search -> Get economic data series that match search text.
>>> client.get_series_search("monetary service index", limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'search_rank', 'sort_order': 'desc', 'count': 885, 'offset': 0, 'limit': 1, 'seriess': [{'id': 'MSIMZMP', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'Monetary Services Index: MZM (preferred)', 'observation_start': '1967-01-01', 'observation_end': '2013-12-01', 'frequency': 'Monthly', 'frequency_short': 'M', 'units': 'Billions of Dollars', 'units_short': 'Bil. of $', 'seasonal_adjustment': 'Seasonally Adjusted', 'seasonal_adjustment_short': 'SA', 'last_updated': '2014-01-17 07:16:42-06', 'popularity': 22 'group_popularity': 22, 'notes': 'The MSI measure the flow of monetary services received each period by households and firms from their holdings of monetary assets (levels of the indexes are sometimes referred to as Divisia monetary aggregates).\nPreferred benchmark rate equals 100 basis points plus the largest rate in the set of rates. \nAlternative benchmark rate equals the larger of the preferred benchmark rate and the Baa corporate bond yield.'}]} >>> >>> xml_data = client.get_series_search("monetary service index", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'seriess' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': 'MSIMZMP', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'Monetary Services Index: MZM (preferred)', 'observation_start': '1967-01-01', 'observation_end': '2013-12-01', 'frequency': 'Monthly', 'frequency_short': 'M', 'units': 'Billions of Dollars', 'units_short': 'Bil. of $', 'seasonal_adjustment': 'Seasonally Adjusted', 'seasonal_adjustment_short': 'SA', 'last_updated': '2014-01-17 07:16:42-06', 'popularity': '22', 'group_popularity': '22', 'notes': 'The MSI measure the flow of monetary services received each period by households and firms from their holdings of monetary assets (levels of the indexes are sometimes referred to as Divisia monetary aggregates). Preferred benchmark rate equals 100 basis points plus the largest rate in the set of rates. Alternative benchmark rate equals the larger of the preferred benchmark rate and the Baa corporate bond yield.'} >>>
-
fred/series/search/tags -> Get the FRED tags for a series search.
>>> client.get_series_search_tags("monetary service index", limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 555, 'offset': 0, 'limit': 1, 'tags': [{'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': None, 'created': '2018-12-17 23:33:13-06', 'popularity': 99, 'series_count': 890}]} >>> >>> xml_data = client.get_series_search("monetary service index", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': '', 'created': '2018-12-17 23:33:13-06', 'popularity': '99', 'series_count': '908'} >>>
-
fred/series/search/related_tags -> Get the related FRED tags for one or more FRED tags matching a series search.
>>> client.get_series_search_related_tags("mortgage rate", "30-year", limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 41, 'offset': 0, 'limit': 1, 'tags': [{'name': 'mortgage', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 51, 'series_count': 36}]} >>> >>> xml_data = client.get_series_search_related_tags("mortgage rate", "30-year", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'name': 'mortgage', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '51', 'series_count': '36'} >>>
-
fred/series/tags -> Get the FRED tags for a series.
>>> client.get_series_tags("STLFSI") # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 11, 'offset': 0, 'limit': 1000, 'tags': [{'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': 100, 'series_count': 734394}, {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America', 'created': '2012-02-27 10:18:19-06', 'popularity': 100, 'series_count': 653094}, {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 99, 'series_count': 259720}, {'name': 'copyrighted: citation required', 'group_id': 'cc', 'notes': None, 'created': '2018-12-17 23:33:13-06', 'popularity': 88, 'series_count': 205376}, {'name': 'frb stl', 'group_id': 'src', 'notes': 'St. Louis Fed', 'created': '2012-02-27 10:18:19-06', 'popularity': 68, 'series_count': 78114}, {'name': 'indexes', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 88, 'series_count': 48278}, {'name': 'discontinued', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 66, 'series_count': 45080}, {'name': 'financial', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 55, 'series_count': 21882}, {'name': 'weekly', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 66, 'series_count': 3504}, {'name': 'fsi', 'group_id': 'gen', 'notes': 'Financial Stress Index', 'created': '2014-08-08 14:01:37-05', 'popularity': 27, 'series_count': 32}, {'name': 'stlfsi', 'group_id': 'rls', 'notes': 'St. Louis Financial Stress Index', 'created': '2012-08-16 15:21:17-05', 'popularity': 22, 'series_count': 4}]} >>> >>> xml_data = client.get_series_tags("STLFSI", file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '734394'} {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '653094'} {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '99', 'series_count': '259720'} {'name': 'copyrighted: citation required', 'group_id': 'cc', 'notes': '', 'created': '2018-12-17 23:33:13-06', 'popularity': '88', 'series_count': '205376'} {'name': 'frb stl', 'group_id': 'src', 'notes': 'St. Louis Fed', 'created': '2012-02-27 10:18:19-06', 'popularity': '68', 'series_count': '78114'} {'name': 'indexes', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '88', 'series_count': '48278'} {'name': 'discontinued', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '66', 'series_count': '45080'} {'name': 'financial', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '55', 'series_count': '21882'} {'name': 'weekly', 'group_id': 'freq', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '66', 'series_count': '3504'} {'name': 'fsi', 'group_id': 'gen', 'notes': 'Financial Stress Index', 'created': '2014-08-08 14:01:37-05', 'popularity': '27', 'series_count': '32'} {'name': 'stlfsi', 'group_id': 'rls', 'notes': 'St. Louis Financial Stress Index', 'created': '2012-08-16 15:21:17-05', 'popularity': '22', 'series_count': '4'} >>>
-
fred/series/updates -> Get economic data series sorted by when observations were updated on the FRED® server.
>>> client.get_series_updates(limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'filter_variable': 'geography', 'filter_value': 'all', 'order_by': 'last_updated', 'sort_order': 'desc', 'count': 102683, 'offset': 0, 'limit': 1, 'seriess': [{'id': 'USRECDP' , 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'NBER based Recession Indicators for the United States from the Peak through the Period preceding the Trough', 'observation_start': '1854-12-01', 'observation_end': '2022-07-25' , 'frequency': 'Daily, 7-Day', 'frequency_short': 'D', 'units': '+1 or 0', 'units_short': '+1 or 0', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2022-07-26 18:02:05-05', 'popularity': 31, 'notes': "This time series is an interpretation of US Business Cycle Expansions and Contractions data provided by The National Bureau of Economic Research (NBER) at http://www.nber.org/cycles/cyclesmain.html. Our time series is composed of dummy variables that represent periods of expansion and recession. The NBER identifies months and quarters of turning points without designating a date within the period that turning points occurred. The dummy variable adopts an arbitrary convention that the turning point occurred at a specific date within the period. The arbitrary convention does not reflect any judgment on this issue by the NBER's Business Cycle Dating Committee. A value of 1 is a recessionary period, while a value of 0 is an expansionary period. For this time series, the recession begins the first day of the period of the peak and ends on the last day of the period before the trough. For more options on recession shading, see the notes and links below.\n\nThe recession shading data that we provide initially comes from the source as a list of dates that are either an economic peak or trough. We interpret dates into recession shading data using one of three arbitrary methods. All of our recession shading data is available using all three interpretations. The period between a peak and trough is always shaded as a recession. The peak and trough are collectively extrema. Depending on the application, the extrema, both individually and collectively, may be included in the recession period in whole or in part. In situations where a portion of a period is included in the recession, the whole period is deemed to be included in the recession period.\n\nThe first interpretation, known as the midpoint method, is to show a recession from the midpoint of the peak through the midpoint of the trough for monthly and quarterly data. For daily data, the recession begins on the 15th of the month of the peak and ends on the 15th of the month of the trough. Daily data is a disaggregation of monthly data. For monthly and quarterly data, the entire peak and trough periods are included in the recession shading. This method shows the maximum number of periods as a recession for monthly and quarterly data. The Federal Reserve Bank of St. Louis uses this method in its own publications. A version of this time series represented using the midpoint method can be found at:\n\nhttps://fred.stlouisfed.org/series/USRECDM\n\nThe second interpretation, known as the trough method, is to show a recession from the period following the peak through the trough (i.e. the peak is not included in the recession shading, but the trough is). For daily data, the recession begins on the first day of the first month following the peak and ends on the last day of the month of the trough. Daily data is a disaggregation of monthly data. The trough method is used when displaying data on FRED graphs. A version of this time series represented using the trough method can be found at:\n\nhttps://fred.stlouisfed.org/series/USRECD\n\nThe third interpretation, known as the peak method, is to show a recession from the period of the peak to the trough (i.e. the peak is included in the recession shading, but the trough is not). For daily data, the recession begins on the first day of the month of the peak and ends on the last day of the month preceding the trough. Daily data is a disaggregation of monthly data. The peak method is used for this series."}]} >>> >>> xml_data = client.get_series_updates(limit = 1, file_type = "xml") # XML >>> xml_data <Element 'seriess' at 0x103231a90> >>> for category in list(xml_data): ... print(category.attrib) ... {'id': 'USRECDP', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'NBER based Recession Indicators for the United States from the Peak through the Period preceding the Trough', 'observation_start': '1854-12-01', 'observation_end': '2022-07-25', 'frequency': 'Daily, 7-Day', 'frequency_short': 'D', 'units': '+1 or 0' , 'units_short': '+1 or 0', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2022-07-26 18:02:05-05', 'popularity': '31', 'notes': "This time series is an interpretation of US Business Cycle Expansions and Contractions data provided by The National Bureau of Economic Research (NBER) at http://www.nber.org/cycles/cyclesmain.html. Our time series is composed of dummy variables that represent periods of expansion and recession. The NBER identifies months and quarters of turning points without designating a date within the period that turning points occurred. The dummy variable adopts an arbitrary convention that the turning point occurred at a specific date within the period. The arbitrary convention does not reflect any judgment on this issue by the NBER's Business Cycle Dating Committee. A value of 1 is a recessionary period, while a value of 0 is an expansionary period. For this time series, the recession begins the first day of the period of the peak and ends on the last day of the period before the trough. For more options on recession shading, see the notes and links below. The recession shading data that we provide initially comes from the source as a list of dates that are either an economic peak or trough. We interpret dates into recession shading data using one of three arbitrary methods. All of our recession shading data is available using all three interpretations. The period between a peak and trough is always shaded as a recession. The peak and trough are collectively extrema. Depending on the application, the extrema, both individually and collectively, may be included in the recession period in whole or in part. In situations where a portion of a period is included in the recession, the whole period is deemed to be included in the recession period. The first interpretation, known as the midpoint method, is to show a recession from the midpoint of the peak through the midpoint of the trough for monthly and quarterly data. For daily data, the recession begins on the 15th of the month of the peak and ends on the 15th of the month of the trough. Daily data is a disaggregation of monthly data. For monthly and quarterly data, the entire peak and trough periods are included in the recession shading. This method shows the maximum number of periods as a recession for monthly and quarterly data. The Federal Reserve Bank of St. Louis uses this method in its own publications. A version of this time series represented using the midpoint method can be found at: https://fred.stlouisfed.org/series/USRECDM The second interpretation, known as the trough method, is to show a recession from the period following the peak through the trough (i.e. the peak is not included in the recession shading, but the trough is). For daily data, the recession begins on the first day of the first month following the peak and ends on the last day of the month of the trough. Daily data is a disaggregation of monthly data. The trough method is used when displaying data on FRED graphs. A version of this time series represented using the trough method can be found at: https://fred.stlouisfed.org/series/USRECD The third interpretation, known as the peak method, is to show a recession from the period of the peak to the trough (i.e. the peak is included in the recession shading, but the trough is not). For daily data, the recession begins on the first day of the month of the peak and ends on the last day of the month preceding the trough. Daily data is a disaggregation of monthly data. The peak method is used for this series."} >>>
-
fred/series/vintagedates -> Get the dates in history when a series' data values were revised or new data values were released.
>>> client.get_series_vintagedates("GNPCA", limit = 1) # JSON {'realtime_start': '1776-07-04', 'realtime_end': '9999-12-31', 'order_by': 'vintage_date', 'sort_order': 'asc', 'count': 180, 'offset': 0, 'limit': 1, 'vintage_dates': ['1958-12-21']} >>> >>> xml_data = client.get_series_vintagedates("GNPCA", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'vintage_dates' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... 1958-12-21 >>>
$ python3
>>> from fred import FredAPISources
>>> client = FredAPISources()
-
fred/sources -> Get all sources of economic data.
>>> client.get_sources(limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'source_id', 'sort_order': 'asc', 'count': 108, 'offset': 0, 'limit': 1, 'sources': [{'id': 1, 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'Board of Governors of the Federal Reserve System (US)', 'link': 'http://www.federalreserve.gov/'}]} >>> >>> xml_data = client.get_sources(limit = 1, file_type = "xml") # XML >>> xml_data <Element 'sources' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... {'id': '1', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'Board of Governors of the Federal Reserve System (US)', 'link': 'http://www.federalreserve.gov/'} >>>
-
fred/source -> Get a source of economic data.
>>> client.get_source(1) # JSON {{'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'sources': [{'id': 1, 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'Board of Governors of the Federal Reserve System (US)', 'link': 'http://www.federalreserve.gov/'}]} >>> >>> xml_data = client.get_series_tags("STLFSI", file_type = "xml") # XML >>> xml_data <Element 'sources' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... {'id': '1', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'Board of Governors of the Federal Reserve System (US)', 'link': 'http://www.federalreserve.gov/'} >>>
-
fred/source/releases -> Get the releases for a source.
>>> client.get_source_releases(1, limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'release_id', 'sort_order': 'asc', 'count': 34, 'offset': 0, 'limit': 1, 'releases': [{'id': 13, 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'G.17 Industrial Production and Capacity Utilization', 'press_release': True, 'link': 'http://www.federalreserve.gov/releases/g17/'}]} >>> >>> xml_data = client.get_source_releases(1, limit = 1, file_type = "xml") # XML >>> xml_data <Element 'releases' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... {'id': '13', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'name': 'G.17 Industrial Production and Capacity Utilization', 'press_release': 'true', 'link': 'http://www.federalreserve.gov/releases/g17/'} >>>
$ python3
>>> from fred import FredAPITags
>>> client = FredAPITags()
-
fred/tags -> Get FRED tags.
>>> client.get_tags(limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 5957, 'offset': 0, 'limit': 1, 'tags': [{'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': 100, 'series_count': 734636}]} >>> >>> xml_data = client.get_tags(limit = 1, file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... {'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '733756'} >>>
-
fred/related_tags -> Get the related tags for one or more tags.
>>> client.get_related_tags("monetary aggregates;weekly") # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'series_count', 'sort_order': 'desc', 'count': 16, 'offset': 0, 'limit': 1000, 'tags': [{'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 99, 'series_count': 18}, {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America' , 'created': '2012-02-27 10:18:19-06', 'popularity': 100, 'series_count': 18}, {'name': 'frb', 'group_id': 'src', 'notes': 'Board of Governors', 'created': '2012-02-27 10:18:19-06', 'popularity': 79, 'series_count': 16}, {'name': 'h6', 'group_id': 'rls', 'notes': 'H.6 Money Stock Measures', 'created': '2012-08-16 15:21:17-05', 'popularity': 49, 'series_count': 16}, {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': None, 'created': '2018-12-17 23:33:13-06', 'popularity': 99, 'series_count': 16}, {'name': 'discontinued', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 66, 'series_count': 14}, {'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': 100, 'series_count': 12}, {'name': 'm3', 'group_id': 'gen', 'notes': 'M3 Money Stock', 'created': '2012-02-27 10:18:19-06', 'popularity': 40, 'series_count': 8}, {'name': 'sa', 'group_id': 'seas', 'notes': 'Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': 88, 'series_count': 6}, {'name': 'm1', 'group_id': 'gen', 'notes': 'M1 Money Stock', 'created': '2012-02-27 10:18:19-06' , 'popularity': 46, 'series_count': 4}, {'name': 'm2', 'group_id': 'gen', 'notes': 'M2 Money Stock', 'created': '2012-02-27 10:18:19-06', 'popularity': 43, 'series_count': 4}, {'name': 'copyrighted: citation required', 'group_id': 'cc', 'notes': None, 'created': '2018-12-17 23:33:13-06', 'popularity': 88, 'series_count': 2}, {'name': 'currency', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': 61, 'series_count': 2}, {'name': ' frb stl', 'group_id': 'src', 'notes': 'St. Louis Fed', 'created': '2012-02-27 10:18:19-06', 'popularity': 68, 'series_count': 2}, {'name': 'funds', 'group_id': 'gen', 'notes': None, 'created': '2020-05-11 13:13:02-05', 'popularity': 25, 'series_count': 2}, {'name': 'mzm', 'group_id': 'gen', 'notes': 'MZM Money Stock', 'created': '2012-02-27 10:18:19-06', 'popularity': 24, 'series_count': 2}]} >>> >>> xml_data = client.get_related_tags("monetary aggregates;weekly", file_type = "xml") # XML >>> xml_data <Element 'tags' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... {'name': 'frb', 'group_id': 'src', 'notes': 'Board of Governors', 'created': '2012-02-27 10:18:19-06', 'popularity': '79', 'series_count': '18'} {'name': 'h6', 'group_id': 'rls', 'notes': 'H.6 Money Stock Measures', 'created': '2012-08-16 15:21:17-05', 'popularity': '49', 'series_count': '18'} {'name': 'nation', 'group_id': 'geot', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '99', 'series_count': '18'} {'name': 'public domain: citation requested', 'group_id': 'cc', 'notes': '', 'created': '2018-12-17 23:33:13-06', 'popularity': '99', 'series_count': '18'} {'name': 'usa', 'group_id': 'geo', 'notes': 'United States of America', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '18'} {'name': 'discontinued', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '66', 'series_count': '16'} {'name': 'nsa', 'group_id': 'seas', 'notes': 'Not Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': '100', 'series_count': '10'} {'name': 'm3', 'group_id': 'gen', 'notes': 'M3 Money Stock', 'created': '2012-02-27 10:18:19-06', 'popularity': '40', 'series_count': '8'} {'name': 'sa', 'group_id': 'seas', 'notes': 'Seasonally Adjusted', 'created': '2012-02-27 10:18:19-06', 'popularity': '88', 'series_count': '8'} {'name': 'm1', 'group_id': 'gen', 'notes': 'M1 Money Stock', 'created': '2012-02-27 10:18:19-06', 'popularity': '46', 'series_count': '6'} {'name': 'currency', 'group_id': 'gen', 'notes': '', 'created': '2012-02-27 10:18:19-06', 'popularity': '61', 'series_count': '4'} {'name': 'm2', 'group_id': 'gen', 'notes': 'M2 Money Stock', 'created': '2012-02-27 10:18:19-06', 'popularity': '43', 'series_count': '4'} {'name': 'funds', 'group_id': 'gen', 'notes': '', 'created': '2020-05-11 13:13:02-05', 'popularity': '25', 'series_count': '2'} >>>
-
fred/tags/series -> Get the series matching all tags in the tag_names parameter and no tags in the exclude_tag_names parameter.
>>> client.get_tags_series("slovenia;food;oecd", limit = 1) # JSON {'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'order_by': 'series_id', 'sort_order': 'asc', 'count': 18, 'offset': 0, 'limit': 1, 'seriess': [{'id': 'CPGDFD02SIA657N', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'Consumer Price Index: Total Food Excluding Restaurants for Slovenia', 'observation_start': '1996-01-01', 'observation_end': '2017-01-01', 'frequency': 'Annual', 'frequency_short': 'A', 'units': 'Growth Rate Previous Period', 'units_short': 'Growth Rate Previous Period', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2018-03-09 15:10:44-06', 'popularity': 0, 'group_popularity': 1, 'notes': 'OECD descriptor ID: CPGDFD02\nOECD unit ID: GP\nOECD country ID: SVN\n\nAll OECD data should be cited as follows: OECD, "Main Economic Indicators - complete database", Main Economic Indicators (database),http://dx.doi.org/10.1787/data-00052-en (Accessed on date)\nCopyright, 2016, OECD. Reprinted with permission.'}]} >>> >>> xml_data = client.get_tags_series("slovenia;food;oecd", limit = 1, file_type = "xml") # XML >>> xml_data <Element 'seriess' at 0x103231a90> >>> for category in list(xml_data): ... print(category.text) ... {'id': 'CPGDFD02SIA657N', 'realtime_start': '2022-07-26', 'realtime_end': '2022-07-26', 'title': 'Consumer Price Index: Total Food Excluding Restaurants for Slovenia', 'observation_start': '1996-01-01', ' observation_end': '2017-01-01', 'frequency': 'Annual', 'frequency_short': 'A', 'units': 'Growth Rate Previous Period', 'units_short': 'Growth Rate Previous Period', 'seasonal_adjustment': 'Not Seasonally Adjusted', 'seasonal_adjustment_short': 'NSA', 'last_updated': '2018-03-09 15:10:44-06', 'popularity': '0', 'group_popularity': '1', 'notes': 'OECD descriptor ID: CPGDFD02 OECD unit ID: GP OECD country ID: SVN All OECD data should be cited as follows: OECD, "Main Economic Indicators - complete database", Main Economic Indicators (database),http://dx.doi.org/10.1787/data-00052-en (Accessed on date) Copyright, 2016, OECD. Reprinted with permission.'} >>>