Python SDK

The official Python SDK isn't shipped yet. Until it is, generate a typed client from the OpenAPI document, or call REST directly or over MCP.

The official Hannu Python SDK is not yet available. It's scaffolded but not shipped, so there's no package to pip install. Don't add a hannu dependency yet — there isn't a published one.

Until the SDK ships, you have three well-supported ways to call the platform from Python.

Generate a typed client from OpenAPI

The API's machine-readable contract is an OpenAPI 3.1 document. Point any OpenAPI client generator at it to get typed methods and models for the whole surface. Because the client is generated from the same contract the API serves, it stays in sync with the platform.

shell
# fetch the contract
curl https://api.hannu.africa/v1/openapi.json -o hannu-openapi.json
 
# then run your preferred OpenAPI 3.1 client generator against it

Any generator that supports OpenAPI 3.1 works. Regenerate to pick up the latest additive changes; within /v1, changes are additive, so a regenerated client stays compatible.

Call REST directly

For a few calls, an HTTP library is enough. Send your bearer key, and add an Idempotency-Key on every mutating request.

Python
import os, requests
 
res = requests.post(
    "https://api.hannu.africa/v1/estimate_task",
    headers={
        "Authorization": f"Bearer {os.environ['HANNU_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "type": "field_verification",
        "reward_major": "2500.00",
        "zone_ref": "lagos_yaba",
    },
)
data = res.json()["data"]

Responses are { data } — list endpoints return a bounded { data: [...] } array — and errors are RFC 9457 problem+json with a stable code. See the API reference.

Use MCP for agents

If you're building an agent rather than a service, the MCP server exposes the platform as native tools — no client to generate or maintain. See MCP vs REST to choose.

Coming soon

A first-party Python SDK is planned. Until it lands, the generated-from-OpenAPI client is the recommended path — build against the contract, not a package name that doesn't exist yet.