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.0

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.0
File Size Uploaded Provenance Actions
kobo_api_v2-0.2.0.tar.gz 22.0 kB Without provenance Details for kobo_api_v2-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 28.4 kB

Release files / kobo_api_v2-0.2.0.tar.gz

Download URL kobo_api_v2-0.2.0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4d21a2445a765b4da601ed7911d3a360535eca712c79c35a515db9298ebaa94d
BLAKE2b-256 checksum
How to use checksums
9f99bf7d7b57eaa61918a0eb2b3fce7769e5bc49159a8ef29c142f9fb4ed3f85
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.0-py3-none-any.whl

Download URL kobo_api_v2-0.2.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3754f4d7786e4b3836ac28421024bc68d96ef6a9908d73763458c7bd1002523
BLAKE2b-256 checksum
How to use checksums
a88d7d07cbf1959e6b58b40a875b24714161995d52bc4f7cd24e08d366e8ca6e
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.0

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