Quick Start
Get up and running in less than 5 minutes
Install the SDK
# TypeScript / JavaScript
npm install @drazill/sdk
# Python
pip install drazillCreate an API key
Generate an API key from your account settings. The key is shown once at creation — store it securely.
# Your key is shown once when created
# Store it as an environment variable
export DRAZILL_API_KEY="<DRAZILL_API_KEY>"Fetch markets and trade
import { Drazill } from '@drazill/sdk';
const client = new Drazill({
apiKey: process.env.DRAZILL_API_KEY,
});
// Get trending markets
const { items: markets } = await client.markets.list({
status: 'ACTIVE',
sort_by: 'total_volume',
limit: 10,
});
// Place a limit order
const order = await client.orders.create({
market_id: markets[0].id,
outcome_id: markets[0].outcomes[0].id,
side: 'BUY',
type: 'LIMIT',
price: 0.65,
quantity: 10,
});
console.log(`Order placed: ${order.id}`);Built for Developers
Everything you need to build powerful prediction market integrations
Low Latency
Sub-50ms response times for real-time trading applications
API Key Auth
Simple API key authentication with scoped permissions and rate limiting
Real-time Data
WebSocket streams for live price updates and orderbook changes
Official SDKs
TypeScript and Python SDKs with full type safety and auto-pagination
Signed Webhooks
Durable event delivery with retry, replay, and sandbox test events
API Endpoints
RESTful API with comprehensive market and trading endpoints
/api/v1/marketsList all active markets with optional filtering
curl -X GET "https://api.drazill.com/api/v1/markets?status=ACTIVE&sort_by=total_volume&limit=10" \
-H "X-API-Key: <DRAZILL_API_KEY>"/api/v1/webhooksRegister a signed webhook endpoint for event delivery
curl -X POST "https://api.drazill.com/api/v1/webhooks" \
-H "X-API-Key: <DRAZILL_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/drazill/webhooks","subscribed_events":["order.filled","trade.executed"]}'/api/v1/markets/slug/:slugGet detailed information about a specific market
curl -X GET "https://api.drazill.com/api/v1/markets/slug/will-bitcoin-reach-100k" \
-H "X-API-Key: <DRAZILL_API_KEY>"/api/v1/ordersPlace a new limit or market order
curl -X POST "https://api.drazill.com/api/v1/orders" \
-H "X-API-Key: <DRAZILL_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"market_id": "...", "outcome_id": "...", "side": "BUY", "type": "LIMIT", "price": "0.65", "quantity": "10"}'/api/v1/wallet/portfolioGet your current positions and portfolio summary
curl -X GET "https://api.drazill.com/api/v1/wallet/portfolio" \
-H "X-API-Key: <DRAZILL_API_KEY>"/wsWebSocket endpoint for real-time streaming (order book, trades, prices, notifications)
wscat -c "wss://api.drazill.com/ws"WebSocket Real-Time API
Sub-second streaming for order books, trades, prices, and notifications
Connecting
Open a WebSocket to /ws. Send an auth message first for authenticated channels; never put tokens in the URL. Anonymous connections can subscribe to all public channels.
import { Drazill } from '@drazill/sdk';
const client = new Drazill({ apiKey: '<DRAZILL_API_KEY>' });
const ws = client.ws();
ws.connect();
// Subscribe to channels with typed callbacks
ws.subscribe('orderbook:OUTCOME_ID', (data) => {
console.log('Order book:', data);
});
ws.subscribe('trades:MARKET_ID', (data) => {
console.log('Trade:', data);
});
// Or use raw WebSocket:
const raw = new WebSocket("wss://api.drazill.com/ws");
raw.onopen = () => raw.send(JSON.stringify({
type: "auth",
api_key: "<DRAZILL_API_KEY>"
}));Channel Reference
Subscribe to channels by sending {"type":"subscribe","channels":[...]}
orderbook:{outcome_id}Live order book depth (bids & asks) for an outcome. Pushes a full snapshot on every change.
trades:{market_id}Individual trade executions on a market. Includes price, quantity, and side.
prices:{outcome_id}Price tick updates from trades and price simulation. Includes previous price and percent change.
market:{market_id}Market-level events such as status changes and resolution.
user:{user_id}AuthPrivate channel for notifications, order fill confirmations, and position updates. Auto-subscribed on connect.
Event Format
All server-pushed events follow a consistent JSON envelope. The server sends periodic ping messages; respond with {"type":"pong"} to keep the connection alive.
// Order book update
{
"type": "orderbook_update",
"channel": "orderbook:abc-123",
"data": {
"outcome_id": "abc-123",
"bids": [{ "price": "0.65", "quantity": "100", "order_count": 3 }],
"asks": [{ "price": "0.67", "quantity": "50", "order_count": 1 }],
"spread": "0.02"
},
"ts": 1709742000.123
}
// Trade execution
{
"type": "trade",
"channel": "trades:def-456",
"data": {
"trade_id": "t-789",
"price": "0.65",
"quantity": "10",
"side": "BUY",
"executed_at": "2025-03-06T12:00:00Z"
},
"ts": 1709742001.456
}
// Notification (private channel)
{
"type": "notification",
"channel": "user:usr-789",
"data": {
"id": "n-001",
"title": "Order Filled",
"message": "Bought 10 shares of Yes at $0.65"
},
"ts": 1709742002.789
}Python SDK Example
from drazill import DrazillClient
import asyncio
client = DrazillClient(api_key="<DRAZILL_API_KEY>")
ws = client.ws()
async def stream():
await ws.connect()
await ws.subscribe("orderbook:OUTCOME_ID")
await ws.subscribe("trades:MARKET_ID")
async for event in ws.listen():
if event["type"] == "orderbook_update":
book = event["data"]
print(f"Best bid: {book['bids'][0]['price']}")
elif event["type"] == "trade":
print(f"Trade: {event['data']['price']}")
asyncio.run(stream())Official SDKs
Use our libraries for your favorite language