Skip to content

UfEndpoint

cl_forge.cmf.UfEndpoint dataclass

UfEndpoint(api_key: str)

Bases: CmfEndpoint[UfRecord]

Client for the CMF UF (Unidad de Fomento) endpoints.

Parameters:

Name Type Description Default
api_key str

CMF API key.

required
Source code in src/cl_forge/core/endpoints.py
def __init__(self, api_key: str) -> None:
    """
    Initialize the UF endpoint client.

    Parameters
    ----------
    api_key : str
        CMF API key.
    """
    super().__init__(api_key, "/uf", UfRecord, "UFs")

current

current() -> UfRecord

Get the latest available UF value.

Returns:

Type Description
UfRecord

The latest UF record.

Source code in src/cl_forge/core/endpoints.py
def current(self) -> UfRecord:
    """
    Get the latest available UF value.

    Returns
    -------
    UfRecord
        The latest UF record.
    """
    return super().current()

year

year(year: int | None = None) -> list[UfRecord]

Get the UF values for a given year.

Parameters:

Name Type Description Default
year int | None

The year for which to retrieve UF values. If None, defaults to the current year.

None

Returns:

Type Description
list[UfRecord]

A list of UF records for the specified year.

Source code in src/cl_forge/core/endpoints.py
def year(self, year: int | None = None) -> list[UfRecord]:
    """
    Get the UF values for a given year.

    Parameters
    ----------
    year : int | None
        The year for which to retrieve UF values. If None, defaults to the
        current year.

    Returns
    -------
    list[UfRecord]
        A list of UF records for the specified year.
    """
    return super().year(year)