Skip to main content

Kobo API v2 Python client

PyPI version Python License: MIT

A minimal, synchronous Python client for downloading surveys from the KoboToolbox API v2.

Installation

pip install kobo-api-v2

Requires Python ≥ 3.10.

Quick start

from kobo import KoboClient

client = KoboClient(api_token="<your_api_token>")

# List available surveys
surveys = client.get_surveys()

# Download the first survey as Excel in one synchronous call
saved = client.get_excel(surveys[0]["uid"])
print(saved)  # → /absolute/path/to/data_survey.xlsx

Your API token is under Account Settings → Security → API key in your KoboToolbox account.


API reference

KoboClient(api_token, base_url=...)

# Global server (default)
client = KoboClient(api_token="...")

# European Union server
client = KoboClient(api_token="...", base_url="https://eu.kobotoolbox.org")

# Self-hosted instance
client = KoboClient(api_token="...", base_url="https://kobo.myserver.org")

get_surveys(limit=100, offset=0, search=None)

surveys = client.get_surveys()
surveys = client.get_surveys(search="census", limit=50, offset=0)
Parameter Default Description
limit 100 Results per page (API max: 300)
offset 0 Pagination offset
search None Free-text filter

get_excel(asset_uid, path="data_survey.xlsx", setting_name="python-client", **overrides)

Downloads survey data synchronously as an .xlsx file using a reusable KoboToolbox export setting (no async tasks or polling):

# Minimal — saves to data_survey.xlsx in the current directory
saved = client.get_excel(uid)

# Custom output path and pipeline-friendly export settings
saved = client.get_excel(
    uid,
    path="outputs/survey.xlsx",
    setting_name="pipeline_v1",
    group_sep="_",
    multiple_select="details",
    xls_types_as_text=True,
)
Parameter Default Description
asset_uid — Survey UID
path "data_survey.xlsx" Local destination path
setting_name "python-client" Name of the reusable export setting in KoboToolbox
**overrides — Export setting overrides applied when creating a new named setting

Default export settings (overridable via **overrides):

Field Default Description
lang "_xml" "_xml" = XLSForm internal names; or a language label, e.g. "English"
fields_from_all_versions True Include fields from older form versions
group_sep "/" Column name separator for groups
hierarchy_in_labels False Prepend group hierarchy to labels
multiple_select "summary" "summary", "both", or "details"
flatten False Flatten group structure
xls_types_as_text False Export all values as strings
include_media_url False Include attachment download URLs
fields [] Specific fields to export (empty = all)
query {} MongoDB-style server-side filter

Error handling

from kobo import KoboClient, KoboError

try:
    saved = client.get_excel(uid, path="out.xlsx")
except KoboError as e:
    print(f"API error: {e}")

Documentation

Detailed guides (in Spanish) are available in docs/:


License

MIT — see LICENSE.

Metadata

Release files for kobo-api-v2 0.2.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 kobo-api-v2 0.2.1
File Size Uploaded Provenance Actions
kobo_api_v2-0.2.1.tar.gz 21.9 kB Without provenance Details for kobo_api_v2-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kobo-api-v2 0.2.1
File Interpreter ABI Platform Actions
kobo_api_v2-0.2.1-py3-none-any.whl Python 3 none any Details for kobo_api_v2-0.2.1-py3-none-any.whl

Total release size: 28.3 kB

Release files / kobo_api_v2-0.2.1.tar.gz

Download URL kobo_api_v2-0.2.1.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b98d4276b48ae9fe7bafd3907e7b474a61d7ade78bd5f82c51719da50a92d767
BLAKE2b-256 checksum
How to use checksums
2e031c65f8c145d83fd73b0a8c8d731d41b560392029c5f858766b88682ec70c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kobo_api_v2-0.2.1-py3-none-any.whl

Download URL kobo_api_v2-0.2.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62da1b35e462b06063901a8377a358952af3aaa6065781e59eb2ca0957bccb6c
BLAKE2b-256 checksum
How to use checksums
ca40503e698960547b6cbfa9de7b0b08ca1efbda1ba045be25569a2c9e91c929
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kobo-api-v2 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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