# Typed dYdX

> A fully typed, validated async client for the dYdX Indexer, Chain (Cosmos gRPC +
> CometBFT), and Node APIs.

```python
from typed_dydx import Dydx

async with Dydx.testnet(public=True) as client:
  market = await client.indexer.data.get_market('BTC-USD')
  candles = await client.indexer.streams.candles('ETH-USD', resolution='1MIN')
  async for candle in candles:
    print(candle)
    break
  await candles.unsubscribe()
  balances = await client.chain.bank.all_balances('dydx1...', resolve_denom=False)
  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 inputs and responses across the Indexer, Chain, and Node surfaces.
- **✅ Runtime Validation**: Indexer and Comet responses validated by default.
- **⚡ Async First**: Indexer HTTP and WebSocket streams, Cosmos gRPC queries, and signed node transactions.
- **📚 Full Surface**: `client.indexer`, `client.chain`, and `client.node` cover market data, account history, chain state, and order placement.

## Installation

```bash
pip install typed-dydx
```

## How To

- [Place & Manage Orders](/typed/dydx/how-to/place-and-manage-orders)
- [Fetch Market Data](/typed/dydx/how-to/fetch-market-data)
- [Manage Account Data](/typed/dydx/how-to/manage-account-data)
- [Query Chain State](/typed/dydx/how-to/query-chain-state)
- [Inspect Blocks & Transactions](/typed/dydx/how-to/inspect-blocks-and-transactions)
- [Listen To Streams](/typed/dydx/how-to/listen-to-streams)
- [Paginate Through Results](/typed/dydx/how-to/paginate-through-results)

## Reference

- [Wallet Setup](/typed/dydx/authenticated-setup)
- [Async Usage](/typed/dydx/reference/async-usage)
- [Error Handling](/typed/dydx/reference/error-handling)
- [Environment Variables](/typed/dydx/reference/env-vars)
- [Timestamps](/typed/dydx/reference/timestamps)

## Design Philosophy

Typed dYdX follows the principles outlined in [this blog post](https://tribulnation.com/blog/clients).

*Details matter. Developer experience matters.*
