FredAPI Class¶
- class fedfred.FredAPI(api_key, cache_mode=False, cache_size=256)[source]¶
Bases:
object
The FredAPI class contains methods for interacting with the Federal Reserve Bank of St. Louis FRED® API.
- get_category(category_id)[source]¶
Get a FRED Category
Retrieve information about a specific category from the FRED API.
- Parameters:
category_id (int) – The ID of the category to retrieve.
- Returns:
If multiples categories are returned.
- Return type:
List[Category]
- Raises:
ValueError – If the response from the FRED API indicates an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> category = fred.get_category(125) >>> print(category[0].name) 'Trade Balance'
- FRED API Documentation:
- get_category_children(category_id, realtime_start=None, realtime_end=None)[source]¶
Get a FRED Category’s Child Categories
Get the child categories for a specified category ID from the FRED API.
- Parameters:
- Returns:
If multiple categories are returned.
- Return type:
List[Category]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = FredAPI('your_api_key') >>> children = fred.get_category_children(13) >>> for child in children: >>> print(child.name) 'Exports' 'Imports' 'Income Payments & Receipts' 'U.S. International Finance
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/category_children.html
Get a FRED Category’s Related Categories
Get related categories for a given category ID from the FRED API.
- Parameters:
- Returns:
If multiple categories are returned.
- Return type:
List[Category]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = FredAPI('your_api_key') >>> related = fred.get_category_related(32073) >>> for category in related: >>> print(category.name) 'Arkansas' 'Illinois' 'Indiana' 'Kentucky' 'Mississippi' 'Missouri' 'Tennessee'
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/category_related.html
Get a FRED Category’s Related Tags
Retrieve all tags related to a specified category from the FRED API.
- Parameters:
category_id (int) – The ID for the category.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon-delimited list of tag names to include.
exclude_tag_names (str | list, optional) – A semicolon-delimited list of tag names to exclude.
tag_group_id (int, optional) – The ID for a tag group.
search_text (str, optional) – The words to find matching tags with.
limit (int, optional) – The maximum number of results to return.
offset (int, optional) – The offset for the results.
order_by (str, optional) – Order results by values such as ‘series_count’, ‘popularity’, etc.
sort_order (str, optional) – Sort order, either ‘asc’ or ‘desc’.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the request to the FRED API fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_category_related_tags(125) >>> for tag in tags: >>> print(tag.name) 'balance' 'bea' 'nation' 'usa'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/category_related_tags.html
- get_category_series(category_id, realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None, filter_variable=None, filter_value=None, tag_names=None, exclude_tag_names=None)[source]¶
Get a FRED Category’s FRED Series
Get the series info for all series in a category from the FRED API.
- Parameters:
category_id (int) – The ID for a category.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
order_by (str, optional) – Order results by values. Options are ‘series_id’, ‘title’, ‘units’, ‘frequency’, ‘seasonal_adjustment’, ‘realtime_start’, ‘realtime_end’, ‘last_updated’, ‘observation_start’, ‘observation_end’, ‘popularity’, ‘group_popularity’.
sort_order (str, optional) – Sort results in ascending or descending order. Options are ‘asc’ or ‘desc’.
filter_variable (str, optional) – The attribute to filter results by. Options are ‘frequency’, ‘units’, ‘seasonal_adjustment’.
filter_value (str, optional) – The value of the filter_variable to filter results by.
tag_names (str | list, optional) – A semicolon-separated list of tag names to filter results by.
exclude_tag_names (str | list, optional) – A semicolon-separated list of tag names to exclude results by.
- Returns:
If multiple series are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the request to the FRED API fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> series = fred.get_category_series(125) >>> for s in series: >>> print(s.frequency) 'Quarterly' 'Annual' 'Quarterly'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/category_series.html
- get_category_tags(category_id, realtime_start=None, realtime_end=None, tag_names=None, tag_group_id=None, search_text=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get a FRED Category’s Tags
Get the all the tags for a category from the FRED API.
- Parameters:
category_id (int) – The ID for a category.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon delimited list of tag names to filter tags by.
tag_group_id (int, optional) – A tag group ID to filter tags by type.
search_text (str, optional) – The words to find matching tags with.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
order_by (str, optional) – Order results by values. Options are ‘series_count’, ‘popularity’, ‘created’, ‘name’. Default is ‘series_count’.
sort_order (str, optional) – Sort results in ascending or descending order. Options are ‘asc’, ‘desc’. Default is ‘desc’.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the request to the FRED API fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_category_tags(125) >>> for tag in tags: >>> print(tag.notes) 'U.S. Department of Commerce: Bureau of Economic Analysis' 'Country Level' 'United States of America'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/category_tags.html
Get FRED related tags
Retrieve related tags for a given set of tags from the FRED API.
- Parameters:
realtime_start (str | datetime, optional) – The start of the real-time period. Strinng format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon-delimited list of tag names to include in the search.
exclude_tag_names (str | list, optional) – A semicolon-delimited list of tag names to exclude from the search.
tag_group_id (str, optional) – A tag group ID to filter tags by group.
search_text (str, optional) – The words to match against tag names and descriptions.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
order_by (str, optional) – Order results by values. Options: ‘series_count’, ‘popularity’, ‘created’, ‘name’, ‘group_id’.
sort_order (str, optional) – Sort order of results. Options: ‘asc’ (ascending), ‘desc’ (descending). Default is ‘asc’.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_related_tags() >>> for tag in tags: >>> print(tag.name) 'nation' 'usa' 'frb'...
- FRED API Documentation:
- get_release(release_id, realtime_start=None, realtime_end=None)[source]¶
Get a FRED release
Get the release for a given release ID from the FRED API.
- Parameters:
- Returns:
If multiple releases are returned.
- Return type:
List[Release]
- Raises:
ValueError – If the request to the FRED API fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> release = fred.get_release(53) >>> print(release[0].name) 'Gross Domestic Product'
- FRED API Documentation:
- get_release_dates(release_id, realtime_start=None, realtime_end=None, limit=None, offset=None, sort_order=None, include_releases_dates_with_no_data=None)[source]¶
Get FRED release dates
Get the release dates for a given release ID from the FRED API.
- Parameters:
release_id (int) – The ID for the release.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return.
offset (int, optional) – The offset for the results.
sort_order (str, optional) – The order of the results. Possible values are ‘asc’ or ‘desc’.
include_releases_dates_with_no_data (bool, optional) – Whether to include release dates with no data.
- Returns:
If multiple release dates are returned.
- Return type:
List[ReleaseDate]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> release_dates = fred.get_release_dates(82) >>> for release_date in release_dates: >>> print(release_date.date) '1997-02-10' '1998-02-10' '1999-02-04'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/release_dates.html
Get FRED release related tags
Get release related tags for a given series search text.
- Parameters:
series_search_text (str, optional) – The text to match against economic data series.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon delimited list of tag names to match.
exclude_tag_names (str | list, optional) – A semicolon-separated list of tag names to exclude results by.
tag_group_id (str, optional) – A tag group id to filter tags by type.
tag_search_text (str, optional) – The text to match against tags.
limit (int, optional) – The maximum number of results to return.
offset (int, optional) – The offset for the results.
order_by (str, optional) – Order results by values. Options: ‘series_count’, ‘popularity’, ‘created’, ‘name’, ‘group_id’.
sort_order (str, optional) – Sort order of results. Options: ‘asc’, ‘desc’.
release_id (int)
search_text (str | None)
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_release_related_tags('86') >>> for tag in tags: >>> print(tag.name) 'commercial paper' 'frb' 'nation'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/release_related_tags.html
- get_release_series(release_id, realtime_start=None, realtime_end=None, limit=None, offset=None, sort_order=None, filter_variable=None, filter_value=None, exclude_tag_names=None)[source]¶
Get FRED release series
Get the series in a release.
- Parameters:
release_id (int) – The ID for the release.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Default is 0.
sort_order (str, optional) – Order results by values. Options are ‘asc’ or ‘desc’.
filter_variable (str, optional) – The attribute to filter results by.
filter_value (str, optional) – The value of the filter variable.
exclude_tag_names (str | list, optional) – A semicolon-separated list of tag names to exclude.
- Returns:
If multiple series are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> series = fred.get_release_series(51) >>> for s in series: >>> print(s.id) 'BOMTVLM133S' 'BOMVGMM133S' 'BOMVJMM133S'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/release_series.html
- get_release_sources(release_id, realtime_start=None, realtime_end=None)[source]¶
Get FRED release sources
Retrieve the sources for a specified release from the FRED API.
- Parameters:
release_id (int) – The ID of the release for which to retrieve sources.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD. Defaults to None.
realtime_end (str| datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD. Defaults to None.
- Returns:
If multiple sources are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> sources = fred.get_release_sources(51) >>> for source in sources: >>> print(source.name) 'U.S. Department of Commerce: Bureau of Economic Analysis' 'U.S. Department of Commerce: Census Bureau'
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/release_sources.html
- get_release_tables(release_id, element_id=None, include_observation_values=None, observation_date=None)[source]¶
Get FRED release tables
Fetches release tables from the FRED API.
- Parameters:
release_id (int) – The ID for the release.
element_id (int, optional) – The ID for the element. Defaults to None.
include_observation_values (bool, optional) – Whether to include observation values. Defaults to None.
observation_date (str | datetime, optional) – The observation date in YYYY-MM-DD string format. Defaults to None.
- Returns:
If multiple elements are returned.
- Return type:
List[Element]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> elements = fred.get_release_tables(53) >>> for element in elements: >>> print(element.series_id) 'DGDSRL1A225NBEA' 'DDURRL1A225NBEA' 'DNDGRL1A225NBEA'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/release_tables.html
- get_release_tags(release_id, realtime_start=None, realtime_end=None, tag_names=None, tag_group_id=None, search_text=None, limit=None, offset=None, order_by=None)[source]¶
Get FRED release tags
Get the release tags for a given release ID from the FRED API.
- Parameters:
release_id (int) – The ID for the release.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon delimited list of tag names.
tag_group_id (int, optional) – The ID for a tag group.
search_text (str, optional) – The words to find matching tags with.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Default is 0.
order_by (str, optional) – Order results by values. Options are ‘series_count’, ‘popularity’, ‘created’, ‘name’, ‘group_id’. Default is ‘series_count’.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_release_tags(86) >>> for tag in tags: >>> print(tag.name) 'commercial paper' 'frb' 'nation'...
- FRED API Documentation:
- get_releases(realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get FRED releases
Get all economic data releases from the FRED API.
- Parameters:
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is None.
offset (int, optional) – The offset for the results. Default is None.
order_by (str, optional) – Order results by values such as ‘release_id’, ‘name’, ‘press_release’, ‘realtime_start’, ‘realtime_end’. Default is None.
sort_order (str, optional) – Sort results in ‘asc’ (ascending) or ‘desc’ (descending) order. Default is None.
- Returns:
If multiple Releases are returned.
- Return type:
List[Releases]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> releases = fred.get_releases() >>> for release in releases: >>> print(release.name) 'Advance Monthly Sales for Retail and Food Services' 'Consumer Price Index' 'Employment Cost Index'...
- FRED API Documentation:
- get_releases_dates(realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None, include_releases_dates_with_no_data=None)[source]¶
Get FRED releases dates
Get all release dates for economic data releases from the FRED API.
- Parameters:
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str |datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is None.
offset (int, optional) – The offset for the results. Default is None.
order_by (str, optional) – Order results by values. Options include ‘release_id’, ‘release_name’, ‘release_date’, ‘realtime_start’, ‘realtime_end’. Default is None.
sort_order (str, optional) – Sort order of results. Options include ‘asc’ (ascending) or ‘desc’ (descending). Default is None.
include_releases_dates_with_no_data (bool, optional) – Whether to include release dates with no data. Default is None.
- Returns:
If multiple release dates are returned.
- Return type:
List[ReleaseDate]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> release_dates = fred.get_releases_dates() >>> for release_date in release_dates: >>> print(release_date.release_name) 'Advance Monthly Sales for Retail and Food Services' 'Failures and Assistance Transactions' 'Manufacturing and Trade Inventories and Sales'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/releases_dates.html
- get_series(series_id, realtime_start=None, realtime_end=None)[source]¶
Get a FRED series
Retrieve economic data series information from the FRED API.
- Parameters:
- Returns:
If multiple series are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> series = fred.get_series('GNPCA') >>> print(series[0].title) 'Real Gross National Product'
- FRED API Documentation:
- get_series_categories(series_id, realtime_start=None, realtime_end=None)[source]¶
Get FRED series categories
Get the categories for a specified series.
- Parameters:
- Returns:
If multiple categories are returned.
- Return type:
List[Category]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> categories = fred.get_series_categories('EXJPUS') >>> for category in categories: >>> print(category.id) 95 275
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_categories.html
- get_series_observations(series_id, dataframe_method='pandas', realtime_start=None, realtime_end=None, limit=None, offset=None, sort_order=None, observation_start=None, observation_end=None, units=None, frequency=None, aggregation_method=None, output_type=None, vintage_dates=None)[source]¶
Get FRED series observations
Get observations for a FRED series as a pandas or polars DataFrame.
- Parameters:
series_id (str) – The ID for a series.
dataframe_method (str, optional) – The method to use to convert the response to a DataFrame. Options: ‘pandas’, ‘polars’, or ‘dask’. Default is ‘pandas’.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is 100000.
offset (int, optional) – The offset for the results. Used for pagination.
sort_order (str, optional) – Sort results by observation date. Options: ‘asc’, ‘desc’.
observation_start (str | datetime, optional) – The start of the observation period. String format: YYYY-MM-DD.
observation_end (str | datetime, optional) – The end of the observation period. String format: YYYY-MM-DD.
units (str, optional) – A key that indicates a data transformation. Options: ‘lin’, ‘chg’, ‘ch1’, ‘pch’, ‘pc1’, ‘pca’, ‘cch’, ‘cca’, ‘log’.
frequency (str, optional) – An optional parameter to change the frequency of the observations. Options: ‘d’, ‘w’, ‘bw’, ‘m’, ‘q’, ‘sa’, ‘a’, ‘wef’, ‘weth’, ‘wew’, ‘wetu’, ‘wem’, ‘wesu’, ‘wesa’, ‘bwew’, ‘bwem’.
aggregation_method (str, optional) – A key that indicates the aggregation method used for frequency aggregation. Options: ‘avg’, ‘sum’, ‘eop’.
output_type (int, optional) – An integer indicating the type of output. Options: 1 (observations by realtime period), 2 (observations by vintage date, all observations), 3 (observations by vintage date, new and revised observations only), 4 (observations by initial release only).
vintage_dates (str | list, optional) – A comma-separated string of vintage dates. String format: YYYY-MM-DD.
- Returns:
If dataframe_method=’pandas’ or is left blank. Polars DataFrame: If dataframe_method=’polars’. Dask DataFrame: If dataframe_method=’dask’.
- Return type:
Pandas DataFrame
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> observations = fred.get_series_observations('GNPCA') >>> print(observations.head()) date realtime_start realtime_end value 1929-01-01 2025-02-13 2025-02-13 1202.659 1930-01-01 2025-02-13 2025-02-13 1100.670 1931-01-01 2025-02-13 2025-02-13 1029.038 1932-01-01 2025-02-13 2025-02-13 895.802 1933-01-01 2025-02-13 2025-02-13 883.847
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_observations.html
- get_series_release(series_id, realtime_start=None, realtime_end=None)[source]¶
Get FRED series release
Get the release for a specified series from the FRED API.
- Parameters:
- Returns:
If multiple releases are returned.
- Return type:
List[Release]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> release = fred.get_series_release('GNPCA') >>> print(release[0].name) 'Gross National Product'
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_release.html
- get_series_search(search_text, search_type=None, realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None, filter_variable=None, filter_value=None, tag_names=None, exclude_tag_names=None)[source]¶
Get FRED series search
Searches for economic data series based on text queries.
- Parameters:
search_text (str) – The text to search for in economic data series. if ‘search_type’=’series_id’, it’s possible to put an ‘*’ in the middle of a string. ‘m*sl’ finds any series starting with ‘m’ and ending with ‘sl’.
search_type (str, optional) – The type of search to perform. Options include ‘full_text’ or ‘series_id’. Defaults to None.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD. Defaults to None.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD. Defaults to None.
limit (int, optional) – The maximum number of results to return. Defaults to None.
offset (int, optional) – The offset for the results. Defaults to None.
order_by (str, optional) – The attribute to order results by. Options include ‘search_rank’, ‘series_id’, ‘title’, etc. Defaults to None.
sort_order (str, optional) – The order to sort results. Options include ‘asc’ or ‘desc’. Defaults to None.
filter_variable (str, optional) – The variable to filter results by. Defaults to None.
filter_value (str, optional) – The value to filter results by. Defaults to None.
tag_names (str | list, optional) – A comma-separated list of tag names to include in the search. Defaults to None.
exclude_tag_names (str | list, optional) – A comma-separated list of tag names to exclude from the search. Defaults to None.
- Returns:
If multiple series are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> series = fred.get_series_search('monetary services index') >>> for s in series: >>> print(s.id) 'MSIM2' 'MSIM1P' 'OCM1P'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_search.html
Get FRED series search related tags
Get related tags for a series search text.
- Parameters:
series_search_text (str) – The text to search for series.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon-delimited list of tag names to include.
exclude_tag_names (str | list, optional) – A semicolon-delimited list of tag names to exclude.
tag_group_id (str, optional) – The tag group id to filter tags by type.
tag_search_text (str, optional) – The text to search for tags.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
order_by (str, optional) – Order results by values. Options are ‘series_count’, ‘popularity’, ‘created’, ‘name’, ‘group_id’.
sort_order (str, optional) – Sort order of results. Options are ‘asc’ (ascending) or ‘desc’ (descending).
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_series_search_related_tags('mortgage rate') >>> for tag in tags: >>> print(tag.name) 'conventional' 'h15' 'interest rate'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_search_related_tags.html
- get_series_search_tags(series_search_text, realtime_start=None, realtime_end=None, tag_names=None, tag_group_id=None, tag_search_text=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get FRED series search tags
Get the tags for a series search.
- Parameters:
series_search_text (str) – The words to match against economic data series.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon-delimited list of tag names to match.
tag_group_id (str, optional) – A tag group id to filter tags by type.
tag_search_text (str, optional) – The words to match against tags.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Default is 0.
order_by (str, optional) – Order results by values of the specified attribute. Options are ‘series_count’, ‘popularity’, ‘created’, ‘name’, ‘group_id’.
sort_order (str, optional) – Sort results in ascending or descending order. Options are ‘asc’ or ‘desc’. Default is ‘asc’.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_series_search_tags('monetary services index') >>> for tag in tags: >>> print(tag.name) 'academic data' 'anderson & jones' 'divisia'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_search_tags.html
- get_series_tags(series_id, realtime_start=None, realtime_end=None, order_by=None, sort_order=None)[source]¶
Get FRED series tags
Get the tags for a series.
- Parameters:
series_id (str) – The ID for a series.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
order_by (str, optional) – Order results by values such as ‘series_id’, ‘name’, ‘popularity’, etc.
sort_order (str, optional) – Sort results in ‘asc’ (ascending) or ‘desc’ (descending) order.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_series_tags('GNPCA') >>> for tag in tags: >>> print(tag.name) 'nation' 'nsa' 'usa'...
- FRED API Documentation:
- get_series_updates(realtime_start=None, realtime_end=None, limit=None, offset=None, filter_value=None, start_time=None, end_time=None)[source]¶
Get FRED series updates
Retrieves updates for a series from the FRED API.
- Parameters:
realtime_start (str |, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
filter_value (str, optional) – Filter results by this value.
start_time (str, optional) – The start time for the updates. Format: HH:MM.
end_time (str, optional) – The end time for the updates. Format: HH:MM.
- Returns:
If multiple series are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> series = fred.get_series_updates() >>> for s in series: >>> print(s.id) 'PPIITM' 'PPILFE' 'PPIFGS'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_updates.html
- get_series_vintagedates(series_id, realtime_start=None, realtime_end=None, limit=None, offset=None, sort_order=None)[source]¶
Get FRED series vintage dates
Get the vintage dates for a given FRED series.
- Parameters:
series_id (str) – The ID for the FRED series.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return.
offset (int, optional) – The offset for the results.
sort_order (str, optional) – The order of the results. Possible values: ‘asc’ or ‘desc’.
- Returns:
If multiple vintage dates are returned.
- Return type:
List[VintageDate]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> vintage_dates = fred.get_series_vintagedates('GNPCA') >>> for vintage_date in vintage_dates: >>> print(vintage_date.vintage_date) '1958-12-21' '1959-02-19' '1959-07-19'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/series_vintagedates.html
- get_source(source_id, realtime_start=None, realtime_end=None)[source]¶
Get a FRED source
Retrieves information about a source from the FRED API.
- Parameters:
- Returns:
If multiple sources are returned.
- Return type:
List[Source]
- Raises:
ValueError – If the request to the FRED API fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> source = fred.get_source(1) >>> print(source[0].name) 'Board of Governors of the Federal Reserve System'
- FRED API Documentation:
- get_source_releases(source_id, realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get FRED source releases
Get the releases for a specified source from the FRED API.
- Parameters:
source_id (int) – The ID for the source.
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return.
offset (int, optional) – The offset for the results.
order_by (str, optional) – Order results by values such as ‘release_id’, ‘name’, etc.
sort_order (str, optional) – Sort order of results. ‘asc’ for ascending, ‘desc’ for descending.
- Returns:
If multiple Releases are returned.
- Return type:
List[Releases]
- Raises:
ValueError – If the request to the FRED API fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> releases = fred.get_source_releases(1) >>> for release in releases: >>> print(release.name) 'G.17 Industrial Production and Capacity Utilization' 'G.19 Consumer Credit' 'G.5 Foreign Exchange Rates'...
- FRED API Documentation:
https://fred.stlouisfed.org/docs/api/fred/source_releases.html
- get_sources(realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get FRED sources
Retrieve sources of economic data from the FRED API.
- Parameters:
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is 1000, maximum is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
order_by (str, optional) – Order results by values. Options are ‘source_id’, ‘name’, ‘realtime_start’, ‘realtime_end’.
sort_order (str, optional) – Sort order of results. Options are ‘asc’ (ascending) or ‘desc’ (descending).
- Returns:
If multiple sources are returned.
- Return type:
List[Source]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> sources = fred.get_sources() >>> for source in sources: >>> print(source.name) 'Board of Governors of the Federal Reserve System' 'Federal Reserve Bank of Philadelphia' 'Federal Reserve Bank of St. Louis'...
- FRED API Documentation:
- get_tags(realtime_start=None, realtime_end=None, tag_names=None, tag_group_id=None, search_text=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get FRED tags
Retrieve FRED tags based on specified parameters.
- Parameters:
realtime_start (str | datetime, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str | datetime, optional) – The end of the real-time period. String format: YYYY-MM-DD.
tag_names (str | list, optional) – A semicolon-delimited list of tag names to filter results.
tag_group_id (str, optional) – A tag group ID to filter results.
search_text (str, optional) – The words to match against tag names and descriptions.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Used for pagination.
order_by (str, optional) – Order results by values such as ‘series_count’, ‘popularity’, etc.
sort_order (str, optional) – Sort order of results. ‘asc’ for ascending, ‘desc’ for descending.
- Returns:
If multiple tags are returned.
- Return type:
List[Tag]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> tags = fred.get_tags() >>> for tag in tags: >>> print(tag.name) 'nation' 'nsa' 'oecd'...
- FRED API Documentation:
- get_tags_series(tag_names=None, exclude_tag_names=None, realtime_start=None, realtime_end=None, limit=None, offset=None, order_by=None, sort_order=None)[source]¶
Get FRED tags series
Get the series matching tags.
- Parameters:
tag_names (str, optional) – A semicolon delimited list of tag names to include in the search.
exclude_tag_names (str, optional) – A semicolon delimited list of tag names to exclude in the search.
realtime_start (str, optional) – The start of the real-time period. String format: YYYY-MM-DD.
realtime_end (str, optional) – The end of the real-time period. String format: YYYY-MM-DD.
limit (int, optional) – The maximum number of results to return. Default is 1000.
offset (int, optional) – The offset for the results. Default is 0.
order_by (str, optional) – Order results by values. Options: ‘series_id’, ‘title’, ‘units’, ‘frequency’, ‘seasonal_adjustment’, ‘realtime_start’, ‘realtime_end’, ‘last_updated’, ‘observation_start’, ‘observation_end’, ‘popularity’, ‘group_popularity’.
sort_order (str, optional) – Sort results in ascending or descending order. Options: ‘asc’, ‘desc’.
- Returns:
If multiple series are returned.
- Return type:
List[Series]
- Raises:
ValueError – If the API request fails or returns an error.
Example
>>> import fedfred as fd >>> fred = fd.FredAPI('your_api_key') >>> series = fred.get_tags_series('slovenia') >>> for s in series: >>> print(s.id) 'CPGDFD02SIA657N' 'CPGDFD02SIA659N' 'CPGDFD02SIM657N'...
FRED API Documentation: https://fred.stlouisfed.org/docs/api/fred/tags_series.html