Skip to main content

Chile Public Market SDK

codecov

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

[!WARNING] This is an unofficial, community-driven initiative. It is not developed, endorsed, or supported by ChileCompra or Mercado Público. Consumers remain responsible for validating its behavior against the official API contracts.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chile_public_market_sdk-1.0.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chile_public_market_sdk-1.0.1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file chile_public_market_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: chile_public_market_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chile_public_market_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0f729cd82ac34b0cbf1fc701235bd4398ed6f79bbaf4dcb24c69309b69c504fe
MD5 1ec2d0cc1c753f3cf16df619dc535807
BLAKE2b-256 19870221ee97855c1b176e3d086f2397b19ea2b47e9e62e104bed0a01ec31bb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for chile_public_market_sdk-1.0.1.tar.gz:

Publisher: publish.yml on ezer-mackenzie/chile-public-market-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chile_public_market_sdk-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for chile_public_market_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 74791dcb6ff10d43a6655a3b834c3524dd4c0c2713505beade3e3f55076a529c
MD5 dd4b7522c83bbf53601cf76a88449b5a
BLAKE2b-256 7729346c08d47ae742c47487a51d13ea701bd53c32aab583047e3e90c51aa2f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for chile_public_market_sdk-1.0.1-py3-none-any.whl:

Publisher: publish.yml on ezer-mackenzie/chile-public-market-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

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