Skip to content

CL Forge

CL Forge banner

Fast, typed Python tools for Chilean data and public APIs.

PyPI version Supported Python versions Test status License

CL Forge combines Rust-backed validation utilities with a clean Python interface for the CMF and Mercado Público APIs. It includes synchronous and asynchronous clients, typed responses, configurable HTTP behavior, and flexible credential providers.

Install

CL Forge supports Python 3.12–3.14.

pip install cl-forge
uv add cl-forge

See the installation guide for source installs and optional dependencies.

Quick start

Validate Chilean identifiers

from cl_forge import Ppu, calculate_verifier, validate_rut

validate_rut(12_345_678, "5")     # True
calculate_verifier(12_345_678)    # "5"

plate = Ppu("PHZF55")
plate.complete                    # "PHZF55-K"
plate.numeric                     # 69455

Query CMF indicators

from cl_forge import CmfClient

cmf = CmfClient("your-cmf-api-key")

latest_uf = cmf.uf.latest()
ipc_2025 = cmf.ipc.year(2025)
usd_for_day = cmf.usd.day(2025, 12, 1)

The CMF client provides resources for ipc, uf, utm, usd, eur (also euro), tip, and tmc, plus raw JSON and XML access.

CMF credentials

CMF requests require an API key. You can request one through the CMF API portal.

Query Mercado Público

from cl_forge import MarketClient

market = MarketClient("your-mercado-publico-ticket")

active_tenders = market.tender.active()
today_orders = market.order.today()
suppliers = market.supplier.search("70.017.820-K")

The Mercado Público client includes typed resources for tenders, purchase orders, suppliers, and buyers, plus raw v1 and v2 access.

Mercado Público credentials

Mercado Público requests require an API ticket. See the Mercado Público API portal for access details.

Use async clients

The asynchronous clients mirror the synchronous resource interface:

from cl_forge import AsyncCmfClient

cmf = AsyncCmfClient("your-cmf-api-key")
latest_uf = await cmf.uf.latest()

Credentials and configuration

Pass a credential directly, load it from the environment, or read it from a dotenv file:

export CLFORGE_CMF_API_KEY="your-cmf-api-key"
export CLFORGE_MARKET_API_KEY="your-mercado-publico-ticket"
from cl_forge import ClientConfig, CmfClient, DotEnvCredentials, EnvCredentials

cmf = CmfClient(
    credentials=EnvCredentials(),
    config=ClientConfig(timeout=20, http2=True, retries=5),
)

cmf_from_dotenv = CmfClient(DotEnvCredentials(".env"))

API at a glance

Area Public API
CMF CmfClient · AsyncCmfClient
Mercado Público MarketClient · AsyncMarketClient
Credentials EnvCredentials · DotEnvCredentials
HTTP configuration ClientConfig
RUT/RUN validate_rut · calculate_verifier
License plates Ppu

Contributing

Contributions are welcome. Please read the contributing guide before opening a pull request.

License

CL Forge is available under the Apache License 2.0.