Skip to content

crown-xyz/python-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crown API Python Client

Python template for interacting with the Crown API.

Prerequisites

Setup

  1. Clone the repository and enter the directory:
cd python-template
  1. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -e .
  1. Configure environment variables:
cp .env.example .env

Edit .env with your credentials:

CROWN_API_KEY=your_api_key_here
CROWN_PRIVATE_KEY_PATH=./private_key.pem
CROWN_BASE_URL=https://app.brl.xyz
  1. Place your RSA private key at the path configured in CROWN_PRIVATE_KEY_PATH.

Usage

python main.py

main.py demonstrates calling the available API endpoints. Edit it to enable or adjust the examples as needed.

Partner account examples

Standalone, single-purpose scripts for the v1 partner account API live in examples/. They take every input from environment variables — tax ids, wallets and account ids are sensitive, so there are no in-code defaults:

# Create one sub-account (SUB_TAX_ID, SUB_TAX_DOCUMENT_TYPE, ...)
python examples/create_subaccount.py

# Mint BRLV funded by a dynamic PIX brcode (SUB_ACCOUNT_ID, TARGET_BRLV_WALLET, MINT_AMOUNT)
python examples/mint_via_qrcode.py

See .env.example for the full variable list per script.

Project Structure

├── .env.example        # Environment variable template
├── main.py             # Usage examples
├── examples/           # Partner account (v1) examples
├── pyproject.toml      # Project metadata and dependencies
└── crown/
    ├── __init__.py
    ├── auth.py         # JWT signing (RS256)
    └── client.py       # CrownClient and AccountClient with all API methods

Available Methods

Method Description
get_balance(asset) Get account balance
list_wallets() List wallets
create_wallet(name) Create a new wallet
create_quote(...) Create a conversion quote
list_orders() List all orders
get_order(id) Get a specific order
create_order(...) Create an order from a quote
list_transfers() List token transfers
create_transfer(...) Transfer tokens between wallets
list_deposits(asset) List deposits
list_withdrawals(asset) List withdrawals
get_withdrawal(id) Get a specific withdrawal
create_withdrawal_pix(...) Withdraw BRL via PIX
create_withdrawal_ted(...) Withdraw BRL via TED
list_claims() List all claims
simulate_claims() Get claimable operations
create_claim(...) Execute claims
list_sub_accounts() List the partner's sub-accounts
create_sub_account(...) Request creation of a sub-account
get_account(id) Get an account by id
account(id) Get an AccountClient scoped to one account

AccountClient (from client.account(account_id)) exposes the account-scoped v1 endpoints: get(), get_balance(asset), list_deposits(asset), get_pix_deposit(), list_wallets(), create_wallet(name, chain), create_quote(...), list_orders(), get_order(id), create_order(...), list_transfers(), create_transfer(...), list_withdrawals(), and get_withdrawal(id).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages