Drazill logo
Developer Platform

Build with the Drazill API

Access real-time market data, execute trades programmatically, and build powerful applications on top of Canada's leading prediction market.

Quick Start

Get up and running in less than 5 minutes

1

Install the SDK

# TypeScript / JavaScript
npm install @drazill/sdk

# Python
pip install drazill
2

Create 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>"
3

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

GET/api/v1/markets

List 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>"
POST/api/v1/webhooks

Register 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"]}'
GET/api/v1/markets/slug/:slug

Get 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>"
POST/api/v1/orders

Place 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"}'
GET/api/v1/wallet/portfolio

Get your current positions and portfolio summary

curl -X GET "https://api.drazill.com/api/v1/wallet/portfolio" \
  -H "X-API-Key: <DRAZILL_API_KEY>"
WS/ws

WebSocket 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.

orderbook_update
trades:{market_id}

Individual trade executions on a market. Includes price, quantity, and side.

trade
prices:{outcome_id}

Price tick updates from trades and price simulation. Includes previous price and percent change.

price_tick
market:{market_id}

Market-level events such as status changes and resolution.

market_event
user:{user_id}Auth

Private channel for notifications, order fill confirmations, and position updates. Auto-subscribed on connect.

notification / order_fill

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

🐍
Python
Available
📦
JavaScript/TypeScript
Available
🐹
Go
Coming Soon
🦀
Rust
Coming Soon

Rate Limits & Tiers

Tier
Rate Limit
Markets
Support
Free
100/min
10 active
Community
Pro
1,000/min
100 active
Email
Enterprise
Unlimited
Unlimited
Dedicated

Ready to Build?

Sign up, create an API key in your settings, and start building on top of Drazill today.