Skip to main content

Bron SDK for Python

Project description

Bron SDK Python

Python SDK for Bron API

Features

  • Complete API Coverage: All Bron API endpoints supported
  • Async I/O: Non-blocking HTTP using httpx
  • JWT Authentication: Automatic ES256 JWT for requests
  • Typed Queries: Typed query objects for all API endpoints

Installation

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Or add this line to your requirements.txt:

git+https://github.com/bronlabs/bron-sdk-python.git@main

Then run the following command to install dependencies:

pip install -r requirements.txt

Example

import asyncio
import os
import uuid

from bron_sdk_python import BronClient
from bron_sdk_python.types.create_transaction import CreateTransaction
from bron_sdk_python.types.transaction_type import TransactionType


async def main() -> None:
    client = BronClient(
        api_key=os.environ["BRON_API_KEY"],
        workspace_id=os.environ["BRON_WORKSPACE_ID"],
    )

    ws = await client.workspaces.get_workspace_by_id()
    print(f"your workspace: {ws}")

    accounts = await client.accounts.get_accounts()
    print("accounts:")
    for a in accounts.get("accounts", []):
        print(f" - {a.get('accountId')} {a.get('accountName')}")
    if not accounts.get("accounts"):
        await client.aclose()
        return

    account_id = accounts["accounts"][0]["accountId"]

    balances = await client.balances.get_balances({"accountIds": [account_id], "limit": 5})
    print("balances (limit 5):")
    for b in balances.get("balances", []):
        print(f" - {b.get('assetId')} {b.get('symbol')} {b.get('totalBalance')}")

    tx_body: CreateTransaction = {
        "accountId": account_id,
        "externalId": str(uuid.uuid4()),
        "transactionType": TransactionType.WITHDRAWAL.value,
        "params": {
            "amount": "0.0001",
            "assetId": "10002",
            "toAddress": "0x39695a3B42aae1Fb89De54A0cef03fbC30Aa9B80",
        },
    }
    tx = await client.transactions.create_transaction(tx_body)
    print(f"created tx: {tx.get('transactionId')}")

    await client.aclose()


if __name__ == "__main__":
    asyncio.run(main())

Async requirement

All public API methods are async. Use await (or asyncio.run(...)). Close with await client.aclose().

Configuration

  • api_key: Your private JWK (required)
  • workspace_id: Your workspace ID (required)
  • base_url: API base URL (defaults to https://api.bron.org)

Authentication

The SDK generates an ES256 JWT per request from your private JWK and sends it in Authorization: ApiKey <jwt>.

Query Parameters

Methods accept typed query objects or compatible dicts.

Key Generation

CLI:

python -m bron_sdk_python.utils.key_generator

Programmatic:

from bron_sdk_python.utils.key_generator import generate_key_pair

public_jwk, private_jwk, kid = generate_key_pair()

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bron_sdk_python-0.2.3.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bron_sdk_python-0.2.3-py3-none-any.whl (62.9 kB view details)

Uploaded Python 3

File details

Details for the file bron_sdk_python-0.2.3.tar.gz.

File metadata

  • Download URL: bron_sdk_python-0.2.3.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for bron_sdk_python-0.2.3.tar.gz
Algorithm Hash digest
SHA256 23863a1588f7883b8e52b3a7501dec1cfc027f52b8efa394e27b4433547c9840
MD5 64b6dff1efe5ea1a000a7b5c26226511
BLAKE2b-256 9ab8faa7d342ef4dda7ef9364b75680d0f75fda2277daabfd263eb6b218f8e2e

See more details on using hashes here.

File details

Details for the file bron_sdk_python-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bron_sdk_python-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 674a19342688a802d4912eb858588a74e164bac5d95fb80ba8856fef2e95646d
MD5 9fbf1365435decc34e84b33330faf00a
BLAKE2b-256 3e05fe336194ab1f2c03020733bd8febe8a462b838b01ff44a0e8272955b3d21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page