tools.tools.toolkits.fred_toolkit¶
Federal Reserve Economic Data (FRED) Toolkit Module.
This toolkit provides tools for accessing economic data from the Federal Reserve Bank of St. Louis FRED API. It allows retrieval of economic time series data, categories, and related metadata.
FRED is a comprehensive database containing hundreds of thousands of economic time series from dozens of national, international, public, and private sources.
- Required Environment Variables:
FRED_API_KEY: Your FRED API key from https://fred.stlouisfed.org/docs/api/api_key.html
Examples
>>> from haive.tools.toolkits.fred_toolkit import get_series
>>> # Get information about GDP series
>>> gdp_info = get_series("GDP")
>>> print(f"Series title: {gdp_info['seriess'][0]['title']}")
Series title: Gross Domestic Product
>>> from haive.tools.toolkits.fred_toolkit import get_series_observations
>>> # Get GDP values for 2020-2022
>>> gdp_data = get_series_observations("GDP", "2020-01-01", "2022-12-31")
>>> for obs in gdp_data['observations'][:3]:
... print(f"Date: {obs['date']}, Value: ${obs['value']} billion")
Date: 2020-01-01, Value: $21477.597 billion
Attributes¶
Classes¶
Input schema for FRED category queries. |
|
Toolkit for accessing Federal Reserve Economic Data (FRED). |
|
Input schema for FRED series queries. |
|
Input schema for FRED series observations queries. |
Functions¶
|
Helper function to call the FRED API with proper authentication and formatting. |
|
Get information about a FRED category by its ID. |
|
Get the child categories of a specified FRED category. |
|
Get all series belonging to a specified FRED category. |
|
Get metadata about a specific FRED data series. |
|
Get the actual data values (observations) for a FRED time series. |
Module Contents¶
- class tools.tools.toolkits.fred_toolkit.CategoryInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input schema for FRED category queries.
- class tools.tools.toolkits.fred_toolkit.FREDToolkit(/, **data: Any)¶
Bases:
langchain_core.tools.BaseToolkit
Toolkit for accessing Federal Reserve Economic Data (FRED).
This toolkit provides a collection of tools for interacting with the FRED API to retrieve economic data series, categories, and related information.
The Federal Reserve Economic Data (FRED) database contains hundreds of thousands of economic time series from dozens of national, international, public, and private sources.
- class tools.tools.toolkits.fred_toolkit.SeriesInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input schema for FRED series queries.
- class tools.tools.toolkits.fred_toolkit.SeriesObservationsInput(/, **data: Any)¶
Bases:
pydantic.BaseModel
Input schema for FRED series observations queries.
- tools.tools.toolkits.fred_toolkit.fred_get(endpoint: str, params: dict[str, Any]) dict[str, Any] ¶
Helper function to call the FRED API with proper authentication and formatting.
This function adds the API key and sets the response format to JSON before making the request to the specified FRED API endpoint.
- Parameters:
- Returns:
The JSON response from the FRED API.
- Return type:
Dict[str, Any]
- Raises:
requests.RequestException – If the API request fails.
ValueError – If FRED_API_KEY is not set in the environment.
- tools.tools.toolkits.fred_toolkit.get_category(category_id: int) dict[str, Any] ¶
Get information about a FRED category by its ID.
Categories in FRED organize data series into groups like ‘Money, Banking, & Finance’, ‘Population, Employment, & Labor Markets’, etc.
- tools.tools.toolkits.fred_toolkit.get_category_children(category_id: int) dict[str, Any] ¶
Get the child categories of a specified FRED category.
This function retrieves subcategories for a given parent category, allowing exploration of the FRED category hierarchy.
- tools.tools.toolkits.fred_toolkit.get_category_series(category_id: int) dict[str, Any] ¶
Get all series belonging to a specified FRED category.
This function retrieves the economic data series that are classified under the specified category.
- tools.tools.toolkits.fred_toolkit.get_series(series_id: str) dict[str, Any] ¶
Get metadata about a specific FRED data series.
This function retrieves detailed information about an economic data series, including its title, units, frequency, seasonal adjustment, and more.
- tools.tools.toolkits.fred_toolkit.get_series_observations(series_id: str, start_date: str | None = None, end_date: str | None = None) dict[str, Any] ¶
Get the actual data values (observations) for a FRED time series.
This function retrieves the time series data points for a specified economic indicator, with optional date range filtering.
- Parameters:
- Returns:
Series observations with dates and values.
- Return type:
Dict[str, Any]
- Raises:
requests.RequestException – If the API request fails.
- tools.tools.toolkits.fred_toolkit.BASE_URL = 'https://api.stlouisfed.org/fred'¶
- tools.tools.toolkits.fred_toolkit.FRED_API_KEY¶
- tools.tools.toolkits.fred_toolkit.fred_toolkit¶
- tools.tools.toolkits.fred_toolkit.fred_tools¶