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.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 branta 4.0.1
File Size Uploaded Provenance Actions
branta-4.0.1.tar.gz 25.6 kB Without provenance Details for branta-4.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 41.4 kB

Release files / branta-4.0.1.tar.gz

Download URL branta-4.0.1.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d75147118b936a99bec24afafd2be19df120e8b8a9680d774554954e7769fe28
BLAKE2b-256 checksum
How to use checksums
98941164ad2bf525d8470433802b0b63f6868ab9af4d37721ff4ceb8be4fa85f
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.1-py3-none-any.whl

Download URL branta-4.0.1-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
220472d3bc0ea3834a56c25f564f86024a126be7e28f1a26b15c38e3e994639d
BLAKE2b-256 checksum
How to use checksums
4e87cfdba29ea4105d152fc1e928fa6982c4770f25a896636c8ecc30f9ee2b79
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.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.

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