Chile Public Market SDK
Unofficial, typed, synchronous and asynchronous Python SDK for Chile's Mercado Público APIs.
Status: alpha (
0.1.0). The upstream services include legacy contracts and may add fields. Models validate known fields while preserving new ones.
Requirements
- Python 3.12 or newer.
- An access ticket requested through ChileCompra.
Installation
pip install chile-public-market-sdk
Secure configuration
The SDK never includes or manages tickets. Pass one explicitly:
from chile_public_market_sdk import MercadoPublico
sdk = MercadoPublico(ticket="YOUR_TICKET")
Or define MERCADO_PUBLICO_TICKET:
export MERCADO_PUBLICO_TICKET="YOUR_TICKET"
Git ignores .env and env.yaml. Loading them through Docker Compose,
Kubernetes, python-dotenv, or another secret-management mechanism is the
consumer application's responsibility.
Synchronous usage
from datetime import date
from chile_public_market_sdk import MercadoPublico
from chile_public_market_sdk.enums import TenderStatus
with MercadoPublico() as sdk:
response = sdk.get_tenders(
date=date(2026, 6, 12),
status=TenderStatus.PUBLISHED,
)
for tender in response.items:
print(tender.external_code, tender.name)
order = sdk.get_purchase_orders(code="2097-241-SE14")
supplier = sdk.find_supplier("70.017.820-k")
buyers = sdk.get_buyers()
Asynchronous usage
import asyncio
from chile_public_market_sdk import AsyncMercadoPublico
from chile_public_market_sdk.enums import AgilePurchaseStatus
async def main() -> None:
async with AsyncMercadoPublico() as sdk:
page = await sdk.get_agile_purchases(
last_change_ttl_ms=300_000,
statuses=[AgilePurchaseStatus.PUBLISHED],
page_size=50,
)
detail = await sdk.get_agile_purchase(page.items[0].code)
print(detail.name)
asyncio.run(main())
Endpoint coverage
| Resource | SDK method | API |
|---|---|---|
| Tenders | get_tenders |
v1 |
| Purchase orders | get_purchase_orders |
v1 |
| Suppliers | find_supplier |
v1 |
| Buyer organizations | get_buyers |
v1 |
| Agile Purchase listing and filters | get_agile_purchases |
v2 |
| Agile Purchase details | get_agile_purchase |
v2 |
V1 date filters accept a date or the original ddmmyyyy format. Agile
Purchase accepts ISO-8601 dates, multiple statuses and regions, pagination,
and sorting.
Errors
Every public exception inherits from MercadoPublicoError:
ConfigurationError: no ticket was supplied.RequestValidationError: incompatible or invalid filters.AuthenticationError: HTTP 401 or 403.NotFoundError: HTTP 404.RateLimitError: HTTP 429; exposesretry_after.APIError: any other API error.TransportError: network, DNS, or timeout failure.ResponseValidationError: invalid JSON or an unexpected contract.
Development
poetry install --extras "dev docs"
poetry run pytest
poetry run ruff check .
poetry run mypy
poetry build
Read CONTRIBUTING.md and SECURITY.md before submitting changes or reporting vulnerabilities.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chile_public_market_sdk-0.1.0.tar.gz.
File metadata
- Download URL: chile_public_market_sdk-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15b52f3b4f90f8481bd0e256d2eb33c6970b30812f7fde2b7a0d255aade8bae7
|
|
| MD5 |
740948084f7eac40efdb196d2e2c9a4f
|
|
| BLAKE2b-256 |
c2244dd5484f9c75e7ac29975c5c1bca78a6eb18b968e20aeb34058c824ab333
|
Provenance
The following attestation bundles were made for chile_public_market_sdk-0.1.0.tar.gz:
Publisher:
publish.yml on ezer-mackenzie/chile-public-market-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chile_public_market_sdk-0.1.0.tar.gz -
Subject digest:
15b52f3b4f90f8481bd0e256d2eb33c6970b30812f7fde2b7a0d255aade8bae7 - Sigstore transparency entry: 2308035227
- Sigstore integration time:
-
Permalink:
ezer-mackenzie/chile-public-market-sdk@5c617c91df4ae7fd949b578c8a4138d5800adb89 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ezer-mackenzie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5c617c91df4ae7fd949b578c8a4138d5800adb89 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file chile_public_market_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chile_public_market_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638e0cd342ff7083dac2bf06b2ee6a525f7138f97ca11711418fe26da559c2d1
|
|
| MD5 |
1a5adc9afbcefb3897a9377d6fb9fc9e
|
|
| BLAKE2b-256 |
b2d93bcd4843d759197aedd4efe2fcd7e6c5b453edc5addd1ea2a52451ea7cea
|
Provenance
The following attestation bundles were made for chile_public_market_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ezer-mackenzie/chile-public-market-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chile_public_market_sdk-0.1.0-py3-none-any.whl -
Subject digest:
638e0cd342ff7083dac2bf06b2ee6a525f7138f97ca11711418fe26da559c2d1 - Sigstore transparency entry: 2308036412
- Sigstore integration time:
-
Permalink:
ezer-mackenzie/chile-public-market-sdk@5c617c91df4ae7fd949b578c8a4138d5800adb89 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ezer-mackenzie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5c617c91df4ae7fd949b578c8a4138d5800adb89 -
Trigger Event:
workflow_dispatch
-
Statement type: