Skip to main content

nakopay

PyPI Python License

Official NakoPay SDK for Python. Accept Bitcoin, Lightning, Litecoin, Monero and more with a developer-first REST API.

Install

pip install nakopay

Requires Python 3.8+.

Quickstart (sync)

import os
from nakopay import NakoPay

client = NakoPay(api_key=os.environ["NAKOPAY_SECRET_KEY"])

invoice = client.invoices.create(
    amount="19.99",
    currency="USD",
    coin="BTC",
    description="Pro plan",
    metadata={"order_id": "ORD-1042"},
    idempotency_key="ord_1042",
)

print(invoice.id, invoice.checkout_url)

Async client

import asyncio
from nakopay import AsyncNakoPay

async def main():
    async with AsyncNakoPay() as client:
        invoice = await client.invoices.create(
            amount="9.99",
            currency="USD",
            coin="BTC",
        )
        print(invoice.checkout_url)

        # Async pagination
        page = await client.invoices.list(status="paid")
        async for inv in page.auto_paging_iter():
            print(inv.id, inv.amount)

asyncio.run(main())

Verifying webhooks (Flask)

from flask import request
from nakopay import NakoPay, NakoPayError

client = NakoPay(api_key=os.environ["NAKOPAY_SECRET_KEY"])

@app.post("/webhook")
def webhook():
    try:
        event = client.webhooks.construct_event(
            payload=request.data,
            signature_header=request.headers["X-NakoPay-Signature"],
            secret=os.environ["NAKOPAY_WEBHOOK_SECRET"],
        )
    except NakoPayError:
        return "", 400

    if event.type == "invoice.paid":
        fulfill(event.data["object"])

    return "", 200

Error handling

from nakopay import NakoPayError, AuthenticationError, RateLimitError, IdempotencyError

try:
    client.invoices.create(amount="0", currency="USD", coin="BTC")
except AuthenticationError as e:
    print("Bad API key:", e.message)
except RateLimitError as e:
    print("Slow down:", e.message)
except IdempotencyError as e:
    print("Duplicate request with different params:", e.message)
except NakoPayError as e:
    print(e.code, e.message, e.param, e.request_id, e.http_status)

Pagination

for inv in client.invoices.list(status="paid").auto_paging_iter():
    print(inv.id, inv.amount)

License

MIT

Metadata

Release files for nakopay 1.0.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 nakopay 1.0.0
File Size Uploaded Provenance Actions
nakopay-1.0.0.tar.gz 7.8 kB With provenance Details for nakopay-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nakopay 1.0.0
File Interpreter ABI Platform Actions
nakopay-1.0.0-py3-none-any.whl Python 3 none any Details for nakopay-1.0.0-py3-none-any.whl

Total release size: 19.2 kB

Release files / nakopay-1.0.0.tar.gz

Download URL nakopay-1.0.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b82c8f3372e5d15bb9fa07779769318e488e8f8df57f0d847d0c2c20adab5a6a
BLAKE2b-256 checksum
How to use checksums
9d1355a4f9dc449579244a506658a49e0d74ba2166b337afcc8d3358e391f20f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 27, 2026.

Transparency log

Release files / nakopay-1.0.0-py3-none-any.whl

Download URL nakopay-1.0.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72c5fe913d156a89cba1cb5a7d324cec87f3adf54a86934b4bf49ce2e5b5cd52
BLAKE2b-256 checksum
How to use checksums
e38c154b972b97733275d50f9787ccf44971e04330d27192493a2c53c113e138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 27, 2026.

Transparency log

Security for nakopay 1.0.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 nakopay-1.0.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 May 27, 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

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