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.4.tar.gz (18.2 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.4-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nezahub-0.2.4.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

Hashes for nezahub-0.2.4.tar.gz
Algorithm Hash digest
SHA256 8dffff95822ef3ab99b8f0ff952df1fb2f9d0beb136d670e37f9665d2fb093aa
MD5 eeda9b05125c966232006f15fbdb3534
BLAKE2b-256 50e796824c5d359bd3e0ddf9ef69b84f6e6e2ebfad5fb60e77939148951a94b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nezahub-0.2.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3d8b2e80f895245ce3fb876d7f12fd603e5f33027d33074a684527c2e5726ae6
MD5 4fbd1168b589e547da558022f76905de
BLAKE2b-256 83e626b328559ccab93d0520739c7433490420cc10fe079600287909d70c0019

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