Skip to content

category module

The category module provides functions to request data from the FRED API Categories endpoints.

CategoryApiParameters

Bases: BaseModel

Represents the parameters accepted by the FRED Category endpoints.

get_category

get_category(category_id: Optional[int] = None, api_key: ApiKeyType = None, **kwargs: KwargsType) -> JsonType

Get category by ID. Endpoint documentation.

Parameters:

Name Type Description Default
category_id str | None

Category id of interest.

None
api_key str | None

FRED API key. Defaults to None. If None, will search for FRED_API_KEY in environment variables.

None
**kwargs KwargsType

Additional parameters to FRED API category/ endpoint. Refer to the FRED documentation for a list of all possible parameters.

{}

Returns:

Type Description
dict

Dictionary representing the json response.

Examples:

>>> import pyfredapi as pf
>>> pf.get_category(category_id=125)

get_category_children

get_category_children(category_id: Optional[int] = None, api_key: ApiKeyType = None, **kwargs: KwargsType) -> JsonType

Get category children by category ID. Endpoint documentation.

Parameters:

Name Type Description Default
category_id str | None

Category id of interest.

None
api_key str | None

FRED API key. Defaults to None. If None, will search for FRED_API_KEY in environment variables.

None
**kwargs dict

Additional parameters to FRED API category/children endpoint. Refer to the FRED documentation for a list of all possible parameters.

{}

Returns:

Type Description
dict

Dictionary representing the json response.

Examples:

>>> import pyfredapi as pf
>>> pf.get_category_children(category_id=13)
get_category_related(category_id: int, api_key: ApiKeyType = None, **kwargs: KwargsType) -> JsonType

Get related categories by category ID. Endpoint documentation.

Parameters:

Name Type Description Default
category_id str

Category id of interest.

required
api_key str | None

FRED API key. Defaults to None. If None, will search for FRED_API_KEY in environment variables.

None
**kwargs dict

Additional parameters to FRED API category/children endpoint. Refer to the FRED documentation for a list of all possible parameters.

{}

Returns:

Type Description
dict

Dictionary representing the json response.

get_category_related_tags(category_id: Optional[int] = None, api_key: ApiKeyType = None, return_format: ReturnFormats = 'json', **kwargs: KwargsType) -> ReturnTypes

Get the related FRED tags for a category by category ID. Endpoint documentation.

Parameters:

Name Type Description Default
category_id str | None

Category id of interest.

None
api_key str | None

FRED API key. Defaults to None. If None, will search for FRED_API_KEY in environment variables.

None
return_format str | ReturnFormat

Define how to return the response. Must be either 'json' or 'pandas'.

'json'
**kwargs dict

Additional parameters to FRED API category/children endpoint. Refer to the FRED documentation for a list of all possible parameters.

{}

Returns:

Type Description
dict | DataFrame | DataFrame

get_category_series

get_category_series(category_id: int, api_key: ApiKeyType = None, **kwargs: KwargsType) -> Dict[str, SeriesInfo]

Get the series info for each series in a category by category ID. Endpoint documentation.

Parameters:

Name Type Description Default
category_id str

Category id of interest.

required
api_key str | None

FRED API key. Defaults to None. If None, will search for FRED_API_KEY in environment variables.

None
**kwargs dict

Additional parameters to FRED API category/children endpoint. Refer to the FRED documentation for a list of all possible parameters.

{}

Returns:

Type Description
dict

A dictionary where the keys are series ids and the values for SeriesInfo objects.

get_category_tags

get_category_tags(category_id: Optional[int] = None, api_key: ApiKeyType = None, return_format: ReturnFormats = 'json', **kwargs: KwargsType) -> ReturnTypes

Get the FRED tags for a category by category ID. Endpoint documentation.

Parameters:

Name Type Description Default
category_id str | None

Category id of interest.

None
api_key str | None

FRED API key. Defaults to None. If None, will search for FRED_API_KEY in environment variables.

None
return_format str | ReturnFormat

Define how to return the response. Must be either 'json' or 'pandas'.

'json'
**kwargs dict

Additional parameters to FRED API category/children endpoint. Refer to the FRED documentation for a list of all possible parameters.

{}

Returns:

Type Description
dict | DataFrame | DataFrame