Skip to main content

branta

Python SDK for Branta.

Use verify() on send and add_payment() on receive. Status handling and parent platforms are in the developer docs.

Install

pip install branta

Send

import asyncio
from branta import BrantaApiOptions, BrantaEnvironment, BrantaService, VerifyStatus

service = BrantaService(BrantaApiOptions(environment=BrantaEnvironment.Production))


async def main(scanned_or_pasted: str) -> None:
    result = await service.verify(scanned_or_pasted)

    if result.status == VerifyStatus.Match:
        payment = result.payments[0]
        # Show the card. Link it to result.verify_url.
        print(payment.destinations[0].value, result.verify_url)
    elif result.status == VerifyStatus.Tampered:
        # Destination was altered. Warn. Do not show a verified card.
        print(result.verify_url)
    elif result.status == VerifyStatus.Incomplete:
        # 5xx, 429, or unreachable. Tell the user. Do not treat this as unknown.
        print(result.verify_url)
    # VerifyStatus.Unknown: not in Branta. Show nothing.


asyncio.run(main("bitcoin:bc1q…?branta_id=…&branta_secret=…"))

environment is Production on release and Staging everywhere else.

On-chain Bitcoin needs a bitcoin: URI with branta_id / branta_secret. bolt11, Ark, and silent payments resolve from the value. A bare address is unknown.

A 404 is unknown. 5xx, 429, or no network is incomplete.

Receive

import asyncio
from branta import BrantaApiOptions, BrantaEnvironment, BrantaService, DestinationType

service = BrantaService(
    BrantaApiOptions(environment=BrantaEnvironment.Production, api_key="<api-key>")
)


async def main() -> None:
    payment = (
        service.create_payment_builder()
        .set_description("Invoice #12345")
        .add_destination("bc1q…", DestinationType.BitcoinAddress)
        .set_ttl(600)  # seconds
        .build()
    )
    result = await service.add_payment(payment)
    # Store result.secret with the invoice.
    # Put branta_id and branta_secret on the invoice QR.
    print(result.secret, result.verify_url)


asyncio.run(main())

add_payment encrypts a copy. The Payment you pass in stays plaintext, so a failed post can be retried.

Per-call options

verify, add_payment, and is_api_key_valid take an optional BrantaApiOptions (environment, api_key, hmac_secret) that overrides the constructor for that call.

Changelog

Metadata

Release files for branta 4.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 branta 4.0.0
File Size Uploaded Provenance Actions
branta-4.0.0.tar.gz 25.1 kB Without provenance Details for branta-4.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 40.9 kB

Release files / branta-4.0.0.tar.gz

Download URL branta-4.0.0.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
67aa0784aa409524c8a4652dd194e41eb1a41c8f79ff006d731e65b0bcf81bf8
BLAKE2b-256 checksum
How to use checksums
d7aff1338eb60cc65b636ce6818483cd38ee4b57fba039b10d8784b42ae69f6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / branta-4.0.0-py3-none-any.whl

Download URL branta-4.0.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3930314ef491fc14edda5747174bb7a6c03edfe1690d3c02e8452febfa3b3d7a
BLAKE2b-256 checksum
How to use checksums
600b6a3c4b94d67a5e94712da7d48c01f3e9b3e7e121761cef73c6e84924c6cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Security for branta 4.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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