Metadata-Version: 2.4
Name: cl-forge
Version: 1.0.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python
Classifier: Programming Language :: Rust
Classifier: Typing :: Typed
Classifier: Topic :: Utilities
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: orjson>=3.11.7
Requires-Dist: pydantic>=2.12.5
Requires-Dist: cl-forge[interop] ; extra == 'all'
Requires-Dist: cl-forge[excel] ; extra == 'all'
Requires-Dist: cl-forge[notebook] ; extra == 'all'
Requires-Dist: cl-forge[polars] ; extra == 'analytics'
Requires-Dist: cl-forge[calamine] ; extra == 'analytics'
Requires-Dist: cl-forge[xlsxwriter] ; extra == 'analytics'
Requires-Dist: fastexcel>=0.19.0 ; extra == 'calamine'
Requires-Dist: cl-forge[calamine] ; extra == 'excel'
Requires-Dist: cl-forge[xlsxwriter] ; extra == 'excel'
Requires-Dist: cl-forge[openpyxl] ; extra == 'excel'
Requires-Dist: cl-forge[polars] ; extra == 'interop'
Requires-Dist: cl-forge[pandas] ; extra == 'interop'
Requires-Dist: ipykernel>=7.1.0 ; extra == 'notebook'
Requires-Dist: ipywidgets>=8.1.8 ; extra == 'notebook'
Requires-Dist: notebook>=7.5.3 ; extra == 'notebook'
Requires-Dist: openpyxl>=3.1.5 ; extra == 'openpyxl'
Requires-Dist: cl-forge[pyarrow] ; extra == 'pandas'
Requires-Dist: pandas-stubs>=3.0.0.260204 ; extra == 'pandas'
Requires-Dist: pandas[performance]>=3.0.0 ; extra == 'pandas'
Requires-Dist: cl-forge[pyarrow] ; extra == 'polars'
Requires-Dist: polars>=1.38.0 ; extra == 'polars'
Requires-Dist: pyarrow>=23.0.0 ; extra == 'pyarrow'
Requires-Dist: xlsxwriter>=3.2.9 ; extra == 'xlsxwriter'
Provides-Extra: all
Provides-Extra: analytics
Provides-Extra: calamine
Provides-Extra: excel
Provides-Extra: interop
Provides-Extra: notebook
Provides-Extra: openpyxl
Provides-Extra: pandas
Provides-Extra: polars
Provides-Extra: pyarrow
Provides-Extra: xlsxwriter
License-File: LICENSE
Summary: Simple yet powerful Chilean and other tools written in Rust and Python.
Keywords: chile,cl,utils,tools,rut,run,validators,api,python,rust
Author-email: Matías Schiaffino Tyrer <matias.scht@gmail.com>
License-Expression: Apache-2.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Project-URL: Documentation, https://mschiaff.github.io/cl-forge/
Project-URL: Homepage, https://mschiaff.github.io/cl-forge/
Project-URL: Issues, https://github.com/mschiaff/cl-forge/issues
Project-URL: Repository, https://github.com/mschiaff/cl-forge.git

# Welcome to CL Forge!

<img src="https://github.com/mschiaff/cl-forge/blob/main/docs/assets/banner.png?raw=true" align="center" style="border-radius: 25px;" alt="banner"/>

<h2 align="center">Simple yet powerful Chilean tools written in Rust and Python.</h2>

<div align="center">

[![PyPI - Version](https://img.shields.io/pypi/v/cl-forge)](https://pypi.org/project/cl-forge/)
[![GitHub Release](https://img.shields.io/github/v/release/mschiaff/cl-forge)](https://github.com/mschiaff/cl-forge/releases/latest)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cl-forge)](https://pypi.org/project/cl-forge/)
[![GH Pages - Docs](https://img.shields.io/badge/Pages-Docs-blue?logo=github)](https://mschiaff.github.io/cl-forge/)

![PyPI - Status](https://img.shields.io/pypi/status/cl-forge)
![PyPI - Types](https://img.shields.io/pypi/types/cl-forge)
[![GitHub License](https://img.shields.io/github/license/mschiaff/cl-forge)](https://github.com/mschiaff/cl-forge/blob/main/LICENSE)

[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mschiaff/cl-forge/python-package.yml?logo=github&label=Tests)](https://github.com/mschiaff/cl-forge/actions/workflows/python-package.yml)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mschiaff/cl-forge/release-python.yml?logo=github&label=Release)](https://github.com/mschiaff/cl-forge/actions/workflows/release-python.yml)
[![pages-build-deployment](https://github.com/mschiaff/cl-forge/actions/workflows/pages/pages-build-deployment/badge.svg?branch=gh-pages)](https://github.com/mschiaff/cl-forge/actions/workflows/pages/pages-build-deployment)

</div>

`cl-forge` provides a collection of high-performance utilities for common Chilean data formats and API integrations. The core logic is implemented in Rust for maximum speed, with a clean and easy-to-use Python interface.

## Features

- **High Performance**: Core logic written in Rust.
- **Verify**: Efficiently validate Chilean RUT/RUN and PPU (License Plates).
- **API Integrations**: Simple clients to interact with the [CMF](https://api.cmfchile.cl) and [Public Market](https://api.mercadopublico.cl) APIs.
- **Type Safety**: Full type hints and `.pyi` stubs for excellent IDE support.

## Examples

### Validate

You can validate if a verifier digit is correct for a given numeric part of a RUT/RUN.

```python
from cl_forge import verify

is_valid = verify.validate_rut(8750720, "3")

print(f"RUT is valid: {is_valid}")
# RUT is valid: True
```

... Or you can calculate the verifier digit yourself.

```python
from cl_forge import verify

dv = verify.calculate_verifier(8750720)

print(f"Verifier digit: {dv}")
# Verifier digit: 3
```

### Generate

Need to generate a bunch of random, unique and valid RUTs? No problem! And you can even specify a random seed, so you can reproduce the same results every time.

```python
from cl_forge import verify

ruts = verify.generate(
   n=100,
   min=1_000_000,
   max=20_000_000,
   seed=42
)

print(ruts)
# [{'correlative': 8750720, 'verifier': '3'}, ...]
```

### API Clients

The CMF API client allows you to easily interact with the [CMF](https://api.cmfchile.cl) API.

```python
from cl_forge.cmf import CmfClient

client = CmfClient(api_key="your-api-key")

# Get latest IPC data
ipc_data = client.get(path="/ipc")

print(ipc_data)
# {'IPCs': [{'Valor': '-0,2', 'Fecha': '2025-12-01'}]}
```

> [!IMPORTANT]
> To use the CMF API, you need an API key. You can request one at [Contact CMF](https://api.cmfchile.cl/api_cmf/contactanos.jsp).

See the [API Reference](https://mschiaff.github.io/cl-forge/api/cmf/base_client/) for endpoint-specific clients, and the [CMF API documentation](https://api.cmfchile.cl/documentacion/index.html) for details about all the available endpoints.

The Public Market API client also allows you to easily interact with the [Mercado Público](https://api.mercadopublico.cl) API.

```python
from cl_forge.market import MarketClient

client = MarketClient(ticket='your-api-ticket')

tenders_data = client.get(path="/licitaciones")

print(tenders_data)
#{'Cantidad': 463,
# 'FechaCreacion': '2026-02-12T16:07:58.813315Z',
# 'Version': 'v1',
# 'Listado': [{'CodigoExterno': '1057049-30-B226',
#   'Nombre': 'CSP- SERVICIO DE INMUNOHISTOQUÍMICA Y CISH',
#   'CodigoEstado': 5,
#   'FechaCierre': '2026-02-23T15:30:00'},
#  {'CodigoExterno': '1057374-8-L126',
# ...}
```

> [!IMPORTANT]
> To use the Mercado Público API, you need an API ticket. You can request one at [Contact Mercado Público](https://api.mercadopublico.cl/modules/IniciarSesion.aspx). To request this API ticket, you will also have to request and activate your [ClaveÚnica](https://claveunica.gob.cl).

See the [Mercado Público API documentation](https://api.mercadopublico.cl/modules/api.aspx) for details about all the available endpoints. **Endpoint-specific clients coming soon in future updates.**

## Contributing

Pull requests are welcome. For changes and reporting bugs, please open an issue first to discuss it. Read our [Contributing Guide](CONTRIBUTING.md) for more details.

## License

This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
