Skip to main content

MTN Mobile Money (MoMo) Python SDK

Unofficial Python SDK for the MTN Mobile Money (MoMo) Open API

CI Python 3.10+ Typed License: MIT

Collections, Disbursements, and Remittance — sync and async clients, built on httpx.

Not affiliated with, endorsed by, or officially connected to MTN Group.

Installation

Not yet on PyPI — install from source:

git clone https://github.com/kangwa/mtn-momo-sdk
cd mtn-momo-sdk
uv sync

Requires Python 3.10+.

The distribution name is mtn-momo-python and the import is mtn_momo. First-release preparation and Trusted Publishing setup are documented in RELEASE.md. The source-only instructions above remain intentional until publication succeeds.

Usage

Sign up at the MoMo Developer Portal and subscribe to the products you need — Collections, Disbursements, and Remittance are separate subscriptions, each with its own subscription key. Provision a sandbox API user and key once per product, against that product's key:

from mtn_momo import SandboxProvisioner

provisioner = SandboxProvisioner("YOUR_COLLECTIONS_SUBSCRIPTION_KEY")
credentials = provisioner.provision()
print(credentials.api_user, credentials.api_key)

Or from the command line, which prints output shaped for .env directly:

uv run mtn-momo-provision --product collections --subscription-key YOUR_COLLECTIONS_SUBSCRIPTION_KEY
# MOMO_COL_SUBSCRIPTION_KEY=...
# MOMO_COL_API_USER=...
# MOMO_COL_API_KEY=...

Repeat with --product disbursements/--product remittance and that product's own subscription key for the others. Copy .env.example to .env and fill in the values for whichever products you use:

Product Prefix Required variables
Collections MOMO_COL_ SUBSCRIPTION_KEY, API_USER, API_KEY
Disbursements MOMO_DIS_ SUBSCRIPTION_KEY, API_USER, API_KEY
Remittance MOMO_REM_ SUBSCRIPTION_KEY, API_USER, API_KEY

MomoClient() then builds each product client automatically from its environment variables the moment you touch it:

import mtn_momo as momo

client = momo.MomoClient()
reference_id = client.collections.request_to_pay(
    amount="500",
    currency="ZMW",
    payer=momo.Party(party_id_type=momo.PartyIdType.MSISDN, party_id="256770000000"),
    payer_message="Invoice 123",
)
status = client.collections.wait_for_transaction(reference_id)
print(status.status.value)
SUCCESSFUL

All endpoints are available on both the sync MomoClient/CollectionsClient and the async AsyncMomoClient/AsyncCollectionsClient:

import asyncio
import mtn_momo as momo


async def main() -> None:
    client = momo.AsyncMomoClient()
    reference_id = await client.collections.request_to_pay(
        amount="500",
        currency="ZMW",
        payer=momo.Party(party_id_type=momo.PartyIdType.MSISDN, party_id="256770000000"),
    )
    status = await client.collections.wait_for_transaction(reference_id)
    print(status.status.value)


asyncio.run(main())

Disbursements and Remittance work the same way — client.disbursements/client.remittance build themselves from MOMO_DIS_*/MOMO_REM_*, and transfer() takes a payee instead of a payer:

client = momo.MomoClient()
reference_id = client.disbursements.transfer(
    amount="1000",
    currency="ZMW",
    payee=momo.Party(party_id_type=momo.PartyIdType.MSISDN, party_id="256770000001"),
)

Balance and account-holder checks:

balance = client.collections.get_balance()  # or get_balance("ZMW")
print(balance.available_balance, balance.currency)

is_active = client.collections.is_account_holder_active(momo.PartyIdType.MSISDN, "256770000000")

Handling errors

If a request fails, the SDK raises a typed MomoAPIError subclass instead of a generic HTTP error, so you can match on what actually went wrong:

from mtn_momo import MomoAPIError, NotEnoughFundsError, PayerNotFoundError, PollTimeoutError

try:
    client.collections.request_to_pay(...)
except PayerNotFoundError:
    ...
except NotEnoughFundsError:
    ...
except PollTimeoutError as e:
    print("still pending after timeout:", e.last_status)
except MomoAPIError as e:
    # Any other rejection from the MoMo API.
    print(e.status_code, e.error_code, e.raw_body)

Configuration

Explicit config instead of environment variables

Pass a ProductConfig directly for secrets from a vault, or to run multiple accounts in one process — it takes priority over any environment variables for that product:

config = momo.ProductConfig(
    base_url="https://sandbox.momodeveloper.mtn.com",
    subscription_key="...",
    api_user="...",
    api_key="...",
)
client = momo.MomoClient(collections=config)

ProductConfig.from_env(prefix) is also available directly, if you want the same environment-loading behavior MomoClient() uses without the lazy client wrapper.

Long-running processes

The examples above skip explicit cleanup, since a one-shot script's connections close when the process exits. In a long-running service, use MomoClient()/AsyncMomoClient() as a context manager so idle HTTP connections get closed properly:

with momo.MomoClient() as client:
    ...

Examples

Runnable scripts in examples/:

Script Demonstrates
sync_request_to_pay.py Collections, sync client
async_request_to_pay.py Collections, async client
disbursement_transfer.py Disbursements payout
sandbox_provisioning.py SandboxProvisioner used as a library
poll_until_complete.py Custom poll timing/backoff

Verifying against a real sandbox

Once you have sandbox credentials, run the live smoke tests:

uv run --env-file .env pytest -m sandbox -v

These tests are skipped by default and excluded from normal CI; run them explicitly, or trigger the Sandbox Smoke Test GitHub Actions workflow with the equivalent secrets configured.

Development

uv sync --dev
uv run pre-commit install
uv run pytest                          # unit tests only, no network
uv run ruff check .
uv run ruff format --check
uv run mypy src

Resources

Metadata

Release files for mtn-momo-python 0.1.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 mtn-momo-python 0.1.0
File Size Uploaded Provenance Actions
mtn_momo_python-0.1.0.tar.gz 18.8 kB With provenance Details for mtn_momo_python-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mtn-momo-python 0.1.0
File Interpreter ABI Platform Actions
mtn_momo_python-0.1.0-py3-none-any.whl Python 3 none any Details for mtn_momo_python-0.1.0-py3-none-any.whl

Total release size: 46.3 kB

Release files / mtn_momo_python-0.1.0.tar.gz

Download URL mtn_momo_python-0.1.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7bc83c2a45ea0f29192c5beef7ef281f045d88a76c3c8281da0c08855590c0a6
BLAKE2b-256 checksum
How to use checksums
8231b5fa0ad1d7f2e48cdcacdd776989a784dce885829e46a7629bed43abe30e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / mtn_momo_python-0.1.0-py3-none-any.whl

Download URL mtn_momo_python-0.1.0-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8f732698ab5a35a09b6afff9e2000b279e384549b89dfa443118cad27f4046a
BLAKE2b-256 checksum
How to use checksums
48a8e5d26e28541670f9d6b157647d74be9f586c4ec281e6de8c4d695749a7d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for mtn-momo-python 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mtn_momo_python-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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