Python client library for interacting with IASO APIs
Project description
iaso-client
iaso-client is a Python client library for interacting with IASO APIs.
Installation
From the project root:
uv sync
Configuration
- Copy .env.sample to .env at the project root, then fill in your credentials:
The IASO_BASE_URL can't be provided with a trailing slash at the end.
IASO_BASE_URL=https://your.iaso-server.com
IASO_LOGIN=your_login
IASO_PASSWORD=your_password
- Create a symlink so Bruno can read the root
.envfile:- Windows (Run Command Prompt as Administrator):
cd bruno mklink .env ..\.env
- Mac / Linux:
cd bruno ln -s ../.env .env
- Windows (Run Command Prompt as Administrator):
Quickstart
import os
from iaso_client import IasoClient
IASO_BASE_URL = os.getenv("IASO_BASE_URL")
IASO_LOGIN = os.getenv("IASO_LOGIN")
IASO_PASSWORD = os.getenv("IASO_PASSWORD")
client = IasoClient(base_url=IASO_BASE_URL)
client.login(IASO_LOGIN, IASO_PASSWORD)
page = client.org_unit_types_list_page(page=1, limit=10, project=975)
items = client.org_unit_types_list(search="District/Zone de sante - DIST")
print(page)
print(items)
Authentication
Use login() to authenticate and automatically store the bearer token for subsequent requests.
client.login("your_login", "your_password")
Current typed resources
The current typed client API supports:
| Resource | Endpoint |
|---|---|
| Org unit types | /api/v2/orgunittypes/ |
| Forms | /api/forms/ |
| Form versions | /api/formversions/ |
| Instances | /api/instances/ |
| Instance files | /api/instances/attachments/, /api/instances/attachments_count/ |
Org unit types:
client.org_unit_types_list(...)
client.org_unit_types_list_page(...)
client.org_unit_types_retrieve(...)
client.org_unit_types_hierarchy(...)
Forms:
client.forms_list(...)
client.forms_list_page(...)
client.forms_retrieve(...)
Form versions:
client.form_versions_list(...)
client.form_versions_list_page(...)
client.form_versions_retrieve(...)
Instances:
client.instances_list(...)
client.instances_list_page(...)
client.instances_retrieve(...)
Instance files:
client.instance_files_list(...)
client.instance_files_list_page(...)
client.instance_files_count(...)
Instances:
client.instances_list(...)
client.instances_list_page(...)
client.instances_retrieve(...)
Pagination behavior
list() fetches and aggregates results across all pages.
list_page() returns a single paginated response.
HTTP request logging
You can enable request logging when creating the client:
import logging
from iaso_client import IasoClient
logging.basicConfig(level=logging.INFO)
client = IasoClient(
base_url="https://your.iaso-server.com",
enable_logging=True,
)
Example log output:
GET https://iaso-staging.bluesquare.org/api/v2/orgunittypes/ -> 200 [143.21 ms]
Development
Run tests
uv run pytest
Run the main script
uv run .\examples\main.py
Setup Pre-commit hooks
- To ensure your code is properly formatted and linted before every commit, install the pre-commit hook:
uv run pre-commit install
- Linting & Formatting (Ruff) Format the code (auto-fix styling issues):
uv run ruff format .
- Check for logic errors and bad practices:
uv run ruff check .
Bruno
This repository also contains a Bruno collection for manually testing IASO API requests.
Configure the environment
Copy .env.sample to .env in the bruno folder, then fill in your credentials:
IASO_BASE_URL=https://your.iaso-server.com
IASO_LOGIN=your_login
IASO_PASSWORD=your_password
Run Bruno requests
- Open Bruno.
- In the top-left corner, open the collection and select the
brunodirectory from this repository. - In the top-right corner, select the
iaso_clientenvironment for the current collection. - Before running any protected request, run the
loginrequest first to authenticate. - Then select the request you want to run and click
->to execute it.
Project details
Release history Release notifications | RSS feed
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 iaso_client-1.1.0.tar.gz.
File metadata
- Download URL: iaso_client-1.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5b93627a6ed4e9ead13ff55b90e7f3855867c8f73e6e28ce31fcf8684c3f988
|
|
| MD5 |
3b219a877055ac1fe522276932fcbd13
|
|
| BLAKE2b-256 |
e449bd1f7f47fa9a2378898b78631701a4733acc428c1e2298061d2cb5414f29
|
File details
Details for the file iaso_client-1.1.0-py3-none-any.whl.
File metadata
- Download URL: iaso_client-1.1.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cb149dc1f593670050c8554079e24fb95cc0d1d48477c3ed7baa015fc1fa2d1
|
|
| MD5 |
be95029fec29f43d6cfda8e403e8bdb5
|
|
| BLAKE2b-256 |
c608b235a6cd7e5540e71fb0ff054c2238d57d22148322d07f5a21762a6b6a4f
|