DFlowClient
The main client class for interacting with DFlow APIs
DFlowClient
The DFlowClient is the main entry point for interacting with the DFlow API. It provides access to all API modules and manages HTTP connections.
Import
Constructor
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
environment | "development" | "production" | "development" | Environment to use. Development requires no API key. |
api_key | str | None | None | API key for authenticated endpoints (required for production) |
metadata_base_url | str | None | None | Custom metadata API URL (overrides environment) |
trade_base_url | str | None | None | Custom trade API URL (overrides environment) |
ws_url | str | None | None | Custom WebSocket URL (overrides environment) |
Environment Options
| Environment | API Key | Endpoints | Use Case |
|---|---|---|---|
"development" | Not required | dev-*.dflow.net | Testing with real capital against Kalshi |
"production" | Required | *.dflow.net | Production deployments |
API Modules
The client provides access to the following API modules:
| Property | Type | Description |
|---|---|---|
markets | MarketsAPI | Market data and discovery |
events | EventsAPI | Event information |
orderbook | OrderbookAPI | Orderbook data |
trades | TradesAPI | Trade history |
live_data | LiveDataAPI | Live market data |
series | SeriesAPI | Series information |
tags | TagsAPI | Tag management |
sports | SportsAPI | Sports-specific data |
search | SearchAPI | Search functionality |
orders | OrdersAPI | Order management |
swap | SwapAPI | Token swaps |
intent | IntentAPI | Intent-based trading |
prediction_market | PredictionMarketAPI | Prediction market operations |
tokens | TokensAPI | Token information |
venues | VenuesAPI | Venue data |
ws | DFlowWebSocket | WebSocket client |
Examples
Basic Usage (Development)
Production Environment
With API Key
Custom URLs
Context Manager
Methods
set_api_key
Set or update the API key for authenticated requests.
close
Close the HTTP client connections.