ChileAtiende Python SDK
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
httpxfor 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
--strictmypy 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80d9e3ae2025ab8316900efcdbe20a1f3da4d62aa8507ea3c27e0b6af16cfe34
|
|
| MD5 |
befb193125a9d84976446bf3ed8f7c96
|
|
| BLAKE2b-256 |
7aaf858193a014726ab38dbea5db9b32e2f2b026177820752bf6cb80a0d2ba65
|
Provenance
The following attestation bundles were made for chileatiende_sdk-0.1.0.tar.gz:
Publisher:
publish.yml on ezer-mackenzie/chileatiende-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chileatiende_sdk-0.1.0.tar.gz -
Subject digest:
80d9e3ae2025ab8316900efcdbe20a1f3da4d62aa8507ea3c27e0b6af16cfe34 - Sigstore transparency entry: 2682525416
- Sigstore integration time:
-
Permalink:
ezer-mackenzie/chileatiende-sdk@8d2c2525702102a964d7363b648e7ecb30a5db42 -
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@8d2c2525702102a964d7363b648e7ecb30a5db42 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file chileatiende_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chileatiende_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.6 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 |
412471b577264047e6a5b93d072b0c9a498ec053cd05451f14e5c07d62ebf54d
|
|
| MD5 |
87d91f9fcf7662c01b0641321746da29
|
|
| BLAKE2b-256 |
969b81755c7dce1c15bf4b06c2a7c6674ba4f6995aa838544b6ea2c7d17718bf
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chileatiende_sdk-0.1.0-py3-none-any.whl -
Subject digest:
412471b577264047e6a5b93d072b0c9a498ec053cd05451f14e5c07d62ebf54d - Sigstore transparency entry: 2682525479
- Sigstore integration time:
-
Permalink:
ezer-mackenzie/chileatiende-sdk@8d2c2525702102a964d7363b648e7ecb30a5db42 -
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@8d2c2525702102a964d7363b648e7ecb30a5db42 -
Trigger Event:
workflow_dispatch
-
Statement type: