Documentation Index
Fetch the complete documentation index at: https://docs.delphimarkets.com/llms.txt
Use this file to discover all available pages before exploring further.
Connection
Connect to the Predict.fun WebSocket endpoint:
wss://api.delphiterminal.co/ws/pfun
No authentication is required for WebSocket connections.
| Property | Value |
|---|
| Protocol | WebSocket (wss://) |
| Keepalive | Ping every 54 seconds |
| Timeout | 60 seconds without pong |
| Max Message Size | 16 KB |
Subscribing to markets
Once connected, send a JSON message to subscribe using market_id:
{
"action": "subscribe",
"market_ids": ["market123", "market456"],
"message_types": ["prices", "orderbook", "trades"]
}
| Field | Type | Required | Description |
|---|
action | string | Yes | subscribe or unsubscribe |
market_ids | array | Yes | Array of Predict.fun market identifiers |
message_types | array | No | ["prices"], ["orderbook"], ["trades"], or any combination. Defaults to prices and orderbook if omitted |
Unsubscribing
{
"action": "unsubscribe",
"market_ids": ["market123"]
}
Message types
Price messages
{
"type": "prices",
"data": {
"exchange": "pfun",
"market_id": "market123",
"price": 0.65,
"yes_bid": 0.64,
"yes_ask": 0.66,
"last_update": "2026-02-06T12:00:00Z"
}
}
Orderbook messages
{
"type": "orderbook",
"data": {
"exchange": "pfun",
"market_id": "market123",
"venue_market_id": "venue123",
"best_yes_price": 65,
"best_yes_size": 100,
"best_no_price": 35,
"best_no_size": 50,
"yes_side": [100, 200, 300],
"no_side": [50, 100, 150],
"server_time": "2026-02-06T12:00:00Z"
}
}
Trade messages
{
"type": "trades",
"data": {
"exchange": "pfun",
"market_id": "market123",
"yes_price": 0.65,
"no_price": 0.35,
"count": 10,
"taker_side": "buy",
"last_update": "2026-02-06T12:00:00Z"
}
}
Full example
const ws = new WebSocket("wss://api.delphiterminal.co/ws/pfun");
ws.onopen = () => {
console.log("Connected to Predict.fun WebSocket");
ws.send(JSON.stringify({
action: "subscribe",
market_ids: ["market123"],
message_types: ["prices", "orderbook", "trades"]
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === "prices") {
console.log("Price update:", data.data);
} else if (data.type === "orderbook") {
console.log("Orderbook update:", data.data);
} else if (data.type === "trades") {
console.log("Trade:", data.data);
}
};
ws.onclose = () => console.log("Disconnected");
ws.onerror = (error) => console.error("WebSocket error:", error);
Important notes
- No authentication required for WebSocket connections
- Use
market_id (Predict.fun market identifier) to subscribe
- Messages are only sent for markets you have explicitly subscribed to
- Multiple markets can be subscribed in a single message
- Trades must be explicitly requested (not included in the default subscription)