Skip to main content

Official Python SDK for the NezaHub API

Project description

NezaHub Python SDK

Official Python client for the NezaHub REST API (/api/v1/).

  • Developer docs: nezahub.com/docs — authentication, checkout, webhooks, API reference

Install

pip install nezahub

Local development (monorepo):

cd sdks/python
pip install -e ".[dev]"
# or from repo root:
make sdk-python

Requires Python 3.10+.

Environments

Environment base_url
Sandbox https://sandbox-api.nezahub.com
Live https://api.nezahub.com
export NEZAHUB_BASE_URL=https://api.nezahub.com
export NEZAHUB_API_KEY=nz_live_...

Server client (API key)

from nezahub import NezaHubClient, nezahub_setup

nezahub_setup(api_key="nz_test_xxx", on_error=print)

with NezaHubClient() as client:
    print(client.health())
    for product in client.products.list_auto():
        print(product["name"])

Server client (JWT login)

from nezahub import NezaHubClient

bootstrap = NezaHubClient(base_url="https://sandbox-api.nezahub.com")

# Phone + password
session = bootstrap.auth.login(phone="+254700000099", password="demo12345")

client = NezaHubClient(access_token=session["tokens"]["access"])
print(client.auth.me())

Email + password login is supported by the API (POST /auth/login/ with email) but not yet on auth.login — use client._http.request("POST", "/api/v1/auth/login/", json={...}) or REST directly.

Phone OTP login uses POST /auth/otp/send/ and POST /auth/otp/verify/ — call via HTTP until dedicated SDK methods ship.

Browser-safe checkout

No API key — public checkout endpoints only:

from nezahub.checkout import NezaHubCheckoutClient

with NezaHubCheckoutClient(environment="test") as checkout:
    session = checkout.start_from_link("your-link-slug", customer_phone="+254700000099")
    checkout.confirm_stk(session["id"], otp_code="123456")

For hosted sandbox, set base_url="https://sandbox-api.nezahub.com".

Resources

Namespace Examples
client.auth login, me, refresh_token, verify_2fa
client.products list, create, update, delete
client.prices create, update, charge distribution
client.checkout create_session, confirm
client.transactions list, get
client.agents CRUD, assignments
client.payouts balance, create (2FA)
client.wallets FX quote, transfer (2FA)

Webhooks

from nezahub.webhooks import construct_event

event = construct_event(payload, signature, secret)

Integration tests

make dev && make migrate
# seed demo seller (see sdks/flows in the monorepo)

cd sdks/python
NEZAHUB_INTEGRATION=1 NEZAHUB_2FA_CODE=123456 pytest tests/test_integration_flow.py -v

Tests (unit)

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nezahub-0.2.2.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nezahub-0.2.2-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file nezahub-0.2.2.tar.gz.

File metadata

  • Download URL: nezahub-0.2.2.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for nezahub-0.2.2.tar.gz
Algorithm Hash digest
SHA256 05deed56a72835b4a5670134971414937000a6c6cb338b2275750945691b8c62
MD5 6d5c6bdf6abdf4f38d751b696c40c37e
BLAKE2b-256 5537b629f9b4af640378f733764a189d86bc6b6d2bb6c37e0e73ff717f031f53

See more details on using hashes here.

File details

Details for the file nezahub-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: nezahub-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for nezahub-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d081437cea63cd99465198b9b7b5149308b216d3a99c2cacb1f3213fe05235
MD5 adb33146498bf5cc0aea05bdc36c036e
BLAKE2b-256 71c066fe5a54b8b32df9d70abdbf7a5c6d53d28f81bacc52803f500552556a0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page