Skip to main content

Chile Public Market SDK

codecov

Unofficial, typed, synchronous and asynchronous Python SDK for Chile's Mercado Público APIs.

Status: stable (1.0.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 SyncChilePublicMarketSDK

sdk = SyncChilePublicMarketSDK(ticket="YOUR_TICKET")

Or define CHILE_PUBLIC_MARKET_TICKET:

export CHILE_PUBLIC_MARKET_TICKET="YOUR_TICKET"

Git ignores .env and env.yaml. Loading them through Docker Compose, Kubernetes, envyaml, python-dotenv, or another secret-management mechanism is the consumer application's responsibility. The SDK itself does not read configuration files.

Synchronous usage

from chile_public_market_sdk import SyncChilePublicMarketSDK

ticket = "YOUR_TICKET"

with SyncChilePublicMarketSDK(ticket=ticket) as client:
    response = client.get_buyers()

    print(f"Companies found: {len(response.companies)}")
    for company in response.companies[:5]:
        print(company.company_code, company.company_name)

Asynchronous usage

import asyncio

from chile_public_market_sdk import AsyncChilePublicMarketSDK


async def main() -> None:
    ticket = "YOUR_TICKET"

    async with AsyncChilePublicMarketSDK(ticket=ticket) as client:
        response = await client.get_buyers()

        print(f"Companies found: {len(response.companies)}")
        for company in response.companies[:5]:
            print(company.company_code, company.company_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.

Client classes and API versions

The SDK exposes separate synchronous and asynchronous classes:

  • SyncChilePublicMarketClient / SyncChilePublicMarketSDK
  • AsyncChilePublicMarketClient / AsyncChilePublicMarketSDK

SDK classes construct and own a client through sdk.client. Their context managers return that managed client, while endpoint methods remain on client classes.

ChileCompra endpoint constants are grouped by upstream version in chile_public_market_sdk.core.constants.api. Dynamic version-specific path builders live under chile_public_market_sdk.api. SDK releases follow Semantic Versioning independently from ChileCompra's upstream versions.

Errors

Every public exception inherits from ChilePublicMarketError:

  • ConfigurationError: no ticket was supplied.
  • RequestValidationError: incompatible or invalid filters.
  • AuthenticationError: HTTP 401 or 403.
  • NotFoundError: HTTP 404.
  • RateLimitError: HTTP 429; exposes retry_after.
  • APIError: any other API error.
  • RequestTimeoutError: a configured timeout was exceeded.
  • NetworkError: a connection or network protocol failed.
  • TransportError: another HTTP transport failure.
  • ResponseValidationError: invalid JSON or an unexpected contract.

Reliability

The SDK uses HTTPX directly. Pass a native httpx.Timeout for granular limits:

import httpx

from chile_public_market_sdk import ClientConfig, SyncChilePublicMarketSDK

config = ClientConfig(
    ticket="YOUR_TICKET",
    timeout=httpx.Timeout(connect=5, read=30, write=10, pool=5),
)

with SyncChilePublicMarketSDK(config=config) as client:
    tenders = client.get_tenders()

Applications that need retries can inject an HTTPX client configured for their own policy. The SDK does not hide HTTPX behind another transport abstraction.

Development

poetry install --extras "dev docs"
poetry run pytest
poetry run ruff check .
poetry run mypy
poetry run pyright
poetry build

Read CONTRIBUTING.md and SECURITY.md before submitting changes or reporting vulnerabilities.

Metadata

Release files for chile-public-market-sdk 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chile-public-market-sdk 1.0.1
File Size Uploaded Provenance Actions
chile_public_market_sdk-1.0.1.tar.gz 18.0 kB With provenance Details for chile_public_market_sdk-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chile-public-market-sdk 1.0.1
File Interpreter ABI Platform Actions
chile_public_market_sdk-1.0.1-py3-none-any.whl Python 3 none any Details for chile_public_market_sdk-1.0.1-py3-none-any.whl

Total release size: 46.3 kB

Release files / chile_public_market_sdk-1.0.1.tar.gz

Download URL chile_public_market_sdk-1.0.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0f729cd82ac34b0cbf1fc701235bd4398ed6f79bbaf4dcb24c69309b69c504fe
BLAKE2b-256 checksum
How to use checksums
19870221ee97855c1b176e3d086f2397b19ea2b47e9e62e104bed0a01ec31bb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Release files / chile_public_market_sdk-1.0.1-py3-none-any.whl

Download URL chile_public_market_sdk-1.0.1-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74791dcb6ff10d43a6655a3b834c3524dd4c0c2713505beade3e3f55076a529c
BLAKE2b-256 checksum
How to use checksums
7729346c08d47ae742c47487a51d13ea701bd53c32aab583047e3e90c51aa2f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Security for chile-public-market-sdk 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for chile_public_market_sdk-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page