Typed
Async, typed, validated Python clients for every crypto venue we trade on. One namespace. Every exchange.
One prompt with the typed-binance install command, its env
vars, and a working first call. Paste it into Claude Code, Cursor, or Codex.
- 1Create a
.envCreate a
.envwith your API credentials — see API keys setup for how to create them.# .env BINANCE_API_KEY="your_api_key" BINANCE_SECRET_KEY="your_api_secret" - 2Install
Install the client and
python-dotenvto load the.envfile.pip install typed-binance python-dotenv - 3Make your first call
Load the environment, then make your first call.
from dotenv import load_dotenv load_dotenv() from typed_binance import Binance async with Binance.new() as client: account = await client.spot.http.account.info() print(account['balances'])
How To
Fetch market data
Order books, candles, recent trades, and the tradeable symbol list — all public.
book = await client.spot.http.market.order_book(symbol='BTCUSDT', limit=20) # order book
candles = await client.spot.http.market.klines(symbol='BTCUSDT', interval='1h', limit=10) # candles
trades = await client.spot.http.market.recent_trades(symbol='BTCUSDT', limit=20) # recent trades
info = await client.spot.http.market.exchange_info(symbol='BTCUSDT') # tradeable symbolsListen to streams
A public market-data channel, and your own account's order/balance events.
async with client.spot.streams.ticker('BTCUSDT') as stream: # public ticker updates
async for update in stream:
print(update)
async with client.spot.ws.subscribe_user_data() as events: # this account's order/balance events
async for event in events:
print(event)Place & manage orders
Submit, query, cancel, and list spot orders. Needs credentials.
order = await client.spot.http.trading.order({
'symbol': 'BTCUSDT', 'side': 'BUY', 'type': 'LIMIT',
'timeInForce': 'GTC', 'quantity': '0.0001', 'price': '20000',
}) # place a limit order
status = await client.spot.http.account.order(symbol='BTCUSDT', order_id=order['orderId']) # check its status
open_orders = await client.spot.http.account.open_orders(symbol='BTCUSDT') # list open orders
await client.spot.http.trading.cancel_order(symbol='BTCUSDT', order_id=order['orderId']) # cancel itFetch account data
Balances, futures positions, and trade history. Needs credentials.
account = await client.spot.http.account.info() # spot balances
trades = await client.spot.http.account.my_trades(symbol='BTCUSDT', limit=50) # trade history
positions = await client.usdm_futures.http.trading.position_risk_v3(symbol='BTCUSDT') # futures positionsQuery & manage earn instruments
List Simple Earn products, subscribe, check your positions, and redeem.
products = await client.spot.http.simple_earn.flexible.list(asset='USDT') # available products
subscription = await client.spot.http.simple_earn.flexible.subscribe(
product_id='USDT001', amount='10',
) # subscribe
positions = await client.spot.http.simple_earn.flexible.position(asset='USDT') # your positions
await client.spot.http.simple_earn.flexible.redeem(product_id='USDT001', redeem_all=True) # redeemManage deposits & withdrawals
Deposit addresses/history, and submitting or listing withdrawals.
deposit = await client.spot.http.wallet.capital.deposit.address(coin='USDT', network='TRX') # deposit address
deposits = await client.spot.http.wallet.capital.deposit.history(coin='USDT') # deposit history
withdrawal = await client.spot.http.wallet.capital.withdraw.apply(
coin='USDT', network='TRX', address='...', amount=10,
) # submit a withdrawal
withdrawals = await client.spot.http.wallet.capital.withdraw.history(coin='USDT') # withdrawal history