Skip to content

Repository files navigation

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

importasyncioimportosimportuuidfrombron_sdk_pythonimportBronClientfrombron_sdk_python.types.create_transactionimportCreateTransactionfrombron_sdk_python.types.transaction_typeimportTransactionTypeasyncdefmain() ->None:
client=BronClient(
api_key=os.environ["BRON_API_KEY"],
workspace_id=os.environ["BRON_WORKSPACE_ID"],
)
ws=awaitclient.workspaces.get_workspace_by_id()
print(f"your workspace: {ws}")
accounts=awaitclient.accounts.get_accounts()
print("accounts:")
forainaccounts.get("accounts", []):
print(f" - {a.get('accountId')}{a.get('accountName')}")
ifnotaccounts.get("accounts"):
awaitclient.aclose()
returnaccount_id=accounts["accounts"][0]["accountId"]
balances=awaitclient.balances.get_balances({"accountIds": [account_id], "limit": 5})
print("balances (limit 5):")
forbinbalances.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=awaitclient.transactions.create_transaction(tx_body)
print(f"created tx: {tx.get('transactionId')}")
awaitclient.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:

frombron_sdk_python.utils.key_generatorimportgenerate_key_pairpublic_jwk, private_jwk, kid=generate_key_pair()

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages