Skip to main content

ChileAtiende Python SDK

PyPI version Python Versions License: MIT Codecov

A modern, fully typed synchronous and asynchronous Python SDK for consuming the official ChileAtiende API provided by the Government of Chile (https://www.chileatiende.gob.cl/desarrolladores).


🚀 Features

  • Full Async & Sync Support: Built on httpx for both synchronous workflows and asynchronous (async/await) executions.
  • Pydantic v2 Models: Strongly typed and validated response models (Ficha, Servicio, Sucursal, feeds, and envelopes).
  • Typed Error Hierarchy: Clear, actionable exceptions (AuthenticationError, NotFoundError, RequestValidationError, APIError).
  • PEP 561 / Strict Mypy: Fully annotated with type hints, ready for --strict mypy type checking.
  • Flexible Authentication: Configure API credentials via direct parameters or environment variables (CHILEATIENDE_ACCESS_TOKEN).

📦 Installation

pip install chileatiende-sdk

Or using Poetry:

poetry add chileatiende-sdk

🔑 Authentication

To make requests to the ChileAtiende API, an access_token is required. You can obtain one from the official developers portal and supply it directly or set it in your environment:

export CHILEATIENDE_ACCESS_TOKEN="your_access_token_here"

💡 Quick Examples

Synchronous Usage (SyncChileAtiendeSDK)

from chileatiende_sdk import ChileAtiendeSDK

with ChileAtiendeSDK(access_token="your_access_token") as client:
    # Fetch a procedure sheet (Ficha) by ID
    ficha = client.get_ficha(1)
    print(f"Ficha ID: {ficha.id}")
    print(f"Title: {ficha.titulo}")
    print(f"Institution: {ficha.servicio}")

    # Search and list Fichas
    fichas_feed = client.list_fichas(query="pension", max_results=5)
    for item in fichas_feed.items:
        print(f"- {item.titulo}")

    # List all state services/institutions
    servicios_feed = client.list_servicios()
    print(f"Total Institutions: {len(servicios_feed.items)}")

Asynchronous Usage (AsyncChileAtiendeSDK)

import asyncio
from chileatiende_sdk import AsyncChileAtiendeSDK

async def main():
    async with AsyncChileAtiendeSDK(access_token="your_access_token") as client:
        # Fetch detailed service information
        servicio = await client.get_servicio("AD001")
        print(f"Service: {servicio.titulo} ({servicio.sigla})")

        # List physical branch offices
        sucursales = await client.list_sucursales(mobile_offices=False)
        print(f"Total Branches: {sucursales.total or len(sucursales.items)}")

asyncio.run(main())

🛠️ API Resource Coverage

Resource Method Name Description
Fichas get_ficha(ficha_id) Retrieve details for a procedure sheet by ID
Fichas list_fichas(query, max_results, page_token) List and search procedure sheets with pagination
Fichas by Service list_fichas_by_servicio(servicio_id) List procedure sheets for a specific state institution
Servicios get_servicio(servicio_id) Retrieve details for a state service/institution
Servicios list_servicios() List all state services publishing in ChileAtiende
Sucursales get_sucursal(sucursal_id) Retrieve details for a branch office
Sucursales list_sucursales(mobile_offices) List branch offices or filter mobile offices

🚨 Exception Handling

from chileatiende_sdk import ChileAtiendeSDK
from chileatiende_sdk.errors import (
    AuthenticationError,
    NotFoundError,
    RequestValidationError,
    APIError,
)

try:
    with ChileAtiendeSDK() as client:
        ficha = client.get_ficha(999999)
except AuthenticationError:
    print("Invalid or missing access token.")
except NotFoundError:
    print("The requested procedure sheet does not exist.")
except RequestValidationError as e:
    print(f"Invalid parameter value: {e}")
except APIError as e:
    print(f"API request error: {e}")

📄 License

This project is licensed under the MIT License. See LICENSE.md for details.

Download files

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

Source Distribution

chileatiende_sdk-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

chileatiende_sdk-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file chileatiende_sdk-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for chileatiende_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 80d9e3ae2025ab8316900efcdbe20a1f3da4d62aa8507ea3c27e0b6af16cfe34
MD5 befb193125a9d84976446bf3ed8f7c96
BLAKE2b-256 7aaf858193a014726ab38dbea5db9b32e2f2b026177820752bf6cb80a0d2ba65

See more details on using hashes here.

Provenance

The following attestation bundles were made for chileatiende_sdk-0.1.0.tar.gz:

Publisher: publish.yml on ezer-mackenzie/chileatiende-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 chileatiende_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chileatiende_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 412471b577264047e6a5b93d072b0c9a498ec053cd05451f14e5c07d62ebf54d
MD5 87d91f9fcf7662c01b0641321746da29
BLAKE2b-256 969b81755c7dce1c15bf4b06c2a7c6674ba4f6995aa838544b6ea2c7d17718bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for chileatiende_sdk-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ezer-mackenzie/chileatiende-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

0.1.0 This release

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