Skip to content

Typed dYdX

A fully typed, validated async client for the dYdX Indexer, Node and CosmosSDK/CometBFT APIs.

from dydx import Dydx

async with Dydx.testnet(public=True) as client:
  market = await client.indexer.data.get_market('BTC-USD')
  stream = await client.indexer.streams.candles('ETH-USD', resolution='1MIN')
  async for candle in stream:
    await stream.unsubscribe()
  balances = await client.chain.bank.all_balances('dydx1...')
  block = await client.chain.comet.block()
  result = await client.node.place_order(market, order={
    'side': 'BUY',
    'size': '0.0001',
    'price': '50000',
    'flags': 'LONG_TERM'
  })

Why Typed dYdX?

  • 🎯 Precise Types: Typed endpoint inputs and responses.
  • ✅ Runtime Validation: Validated responses by default.
  • âš¡ Async First: Indexer HTTP, WebSocket streams, Cosmos gRPC, Comet RPC, and signed node transactions.
  • 📚 Full dYdX Surface: Market data, account history, chain state, blocks, transactions, and order placement.

Installation

pip install typed-dydx

How To

Reference