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
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 nezahub-0.2.3.tar.gz.
File metadata
- Download URL: nezahub-0.2.3.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2676204e4c1e4e684072bffe6007b4eca6fefbfe754c67e57b86c4e4a421b069
|
|
| MD5 |
441fa7772fc1a56faf34574b4f3ffd54
|
|
| BLAKE2b-256 |
e3ca85379fe968f7b382a59730db5ac49294593075ac80f1baec1a9504b1dbb5
|
File details
Details for the file nezahub-0.2.3-py3-none-any.whl.
File metadata
- Download URL: nezahub-0.2.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbbee44860f0a629966f828905fd8aabfbf0ca6fb764fcd405bccfa7cacbda93
|
|
| MD5 |
4391e8007d4b8ca54d7352dbe28a08e9
|
|
| BLAKE2b-256 |
5e5983f184b527ba702ef9948cc2c1ac37ad6f5cc4c335a8ef45e674673c530f
|