Skip to content

Repository files navigation

CL Forge

CL Forge banner

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

PyPI version Supported Python versions Test status License Documentation

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

Using uv:

uv add cl-forge

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.

Note

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.

Note

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 reference

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

Explore the full documentation for installation details and the complete API reference.

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.

About

Simple yet powerful Chilean and other tools written in Rust and Python.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages