Official Python SDK for interacting with the BIE Network.
pip install bie-sdkOr install from source:
git clone https://github.com/bie202512-droid/bie-python-sdk.git
cd bie-python-sdk
pip install -e .from bie_sdk import BieClient
# Initialize client
client = BieClient("https://rpc.bie.ai")
# Get latest block
block = client.get_latest_block()
print(f"Latest block: {block}")
# Get account balance
balance = client.get_balance("0x...")
print(f"Balance: {balance}")# Create account
client.create_account(address, initial_balance="0")
# Get balance
client.get_balance(address)
# Get account info
client.get_account(address)
# Transfer
client.transfer(from_addr, to_addr, amount, signature, public_key)# Create order
client.create_order({
"trader": "0x...",
"base": "BTC",
"quote": "USDT",
"side": "buy",
"price": "50000",
"quantity": "0.1",
"order_type": "limit"
})
# Cancel order
client.cancel_order(order_id, trader)
# Get order book depth
depth = client.get_orderbook("BTC", "USDT", depth=20)
# Get recent trades
trades = client.get_trades("BTC", "USDT", limit=50)# Update margin
client.update_margin(trader, amount)
# Open position
client.open_position({
"trader": "0x...",
"symbol": "BTC-PERP",
"side": "long",
"size": "0.1",
"leverage": 10,
"price": "50000"
})
# Close position
client.close_position(trader, position_id, price)
# Get position
position = client.get_position(position_id)
# Get all positions
positions = client.get_positions(trader)
# Get margin account
margin = client.get_margin_account(trader)# Submit price (for oracles)
client.submit_price(symbol, price, oracle, signature)
# Get current price
price = client.get_price("BTC")# Get block by height
block = client.get_block(12345)
# Get latest block
latest = client.get_latest_block()def on_price_update(data):
print(f"Price update: {data}")
# Subscribe to price feeds
client.subscribe_prices(on_price_update)export BIE_API_URL="https://rpc.bie.ai"client = BieClient("https://custom-rpc.example.com")| Method | Description |
|---|---|
create_account(address, initial_balance) |
Create new account |
get_balance(address) |
Get BIE balance |
get_account(address) |
Get account details |
transfer(from, to, amount, sig, pubkey) |
Transfer BIE |
create_order(payload) |
Place order |
cancel_order(order_id, trader) |
Cancel order |
get_orderbook(base, quote, depth) |
Get order book |
get_trades(base, quote, limit) |
Get recent trades |
update_margin(trader, amount) |
Update margin |
open_position(payload) |
Open perpetual position |
close_position(trader, id, price) |
Close position |
get_position(position_id) |
Get position |
get_positions(trader) |
Get all positions |
get_margin_account(trader) |
Get margin account |
submit_price(symbol, price, oracle, sig) |
Submit oracle price |
get_price(symbol) |
Get oracle price |
get_block(height) |
Get block by height |
get_latest_block() |
Get latest block |
subscribe_prices(callback) |
Subscribe to prices |
- Python 3.8+
- requests
- websocket-client (optional, for subscriptions)
See the examples directory for more usage examples.
| Network | Chain ID | RPC Endpoint |
|---|---|---|
| Mainnet | 1342 | https://rpc.bie.ai |
| Testnet | 13420 | https://testnet-rpc.bie.ai |
Contributions are welcome! Please read our contributing guidelines first.
MIT
- Website: https://bie.ai
- Documentation: https://docs.bie.ai
- Discord: https://discord.gg/bie
- Twitter: @BIE_Chain