Skip to main content

MTN Mobile Money (MoMo) Python SDK

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

CI PyPI 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

pip install mtn-momo-python

Or with uv:

uv add mtn-momo-python

Requires Python 3.10+. The distribution name is mtn-momo-python and the import is mtn_momo; the two differ because PyPI's similarity rules reserve the shorter names.

To work on the SDK itself, clone the repository and run uv sync --dev. Release and publishing steps are documented in RELEASE.md.

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.1

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.1
File Size Uploaded Provenance Actions
mtn_momo_python-0.1.1.tar.gz 18.9 kB With provenance Details for mtn_momo_python-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 46.4 kB

Release files / mtn_momo_python-0.1.1.tar.gz

Download URL mtn_momo_python-0.1.1.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
119fa742ad56c3423bbfd690c11f0334a2c23dce7f100206282da8bc4f1e50e9
BLAKE2b-256 checksum
How to use checksums
1adac9d41f996dbf8fb98b955100ce135a048b83ba5969253b89883d57d2e59a
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.1-py3-none-any.whl

Download URL mtn_momo_python-0.1.1-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4cc037ef5567c08f07921ba3a337df1a55aa5f12c136154224290eb736b3ce2
BLAKE2b-256 checksum
How to use checksums
dcc91b6ae3c16a1091fd1ffd7a3bd479545de9ae01bab42e031d9d24111f4fe5
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.1

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.1.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.1 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