Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pacifica-fi/docs-migrate/llms.txt

Use this file to discover all available pages before exploring further.

Pacifica exposes a single universal WebSocket endpoint that handles both data subscriptions and authenticated trading operations. Once a connection is established, you interact with it entirely through JSON messages — subscribing to channels, sending heartbeats, and (when required) submitting signed trading requests. There are no separate endpoints per data type; one connection gives you access to everything.

Connection URLs

NetworkURL
Mainnetwss://ws.pacifica.fi/ws
Testnetwss://test-ws.pacifica.fi/ws

Subscribing and Unsubscribing

All data streams are opt-in. Send a subscribe message to begin receiving events on a channel, and an unsubscribe message to stop. Subscribe
{
    "method": "subscribe",
    "params": { ... }
}
Unsubscribe
{
    "method": "unsubscribe",
    "params": { ... }
}
The params object varies by channel. Each subscription channel is documented in detail on the Subscriptions page.

Heartbeat and Connection Lifetime

A connection is automatically closed if no message has been sent in the past 60 seconds, or when the connection has been alive for 24 hours. To keep a connection open during quiet periods, send a ping message:
{
    "method": "ping"
}
An active connection responds immediately with:
{
    "channel": "pong"
}
Send a ping at least once every 60 seconds if you are not otherwise sending messages.

Two Types of Operations

The WebSocket API supports two categories of operation:
  • Subscriptions — Stream market data (prices, order books, trades, candles) and account data (positions, orders, trades, transfers). Market data channels require no authentication. Account data channels require passing your wallet address in the subscription params.
  • Trading operations — Place, edit, and cancel orders over the WebSocket connection. All trading operations must carry a valid Ed25519 signature on every message.
Trading operations sent over WebSocket use the same Ed25519 signing scheme as REST POST requests. Every trading message must include a signature, timestamp, and account field. See Authentication for full details on how to construct a valid signature.
Refer to the dedicated pages for complete documentation:

Connection Example (Python)

The following example establishes a WebSocket connection, sends a subscribe message for the prices channel, and prints all incoming events. The websockets library is used here, but the message format works with any WebSocket client.
import asyncio
import json
import websockets

async def main():
    uri = "wss://ws.pacifica.fi/ws"

    async with websockets.connect(uri) as ws:
        # Subscribe to the prices channel for all symbols
        await ws.send(json.dumps({
            "method": "subscribe",
            "params": {
                "source": "prices"
            }
        }))

        # Keep reading events until the connection is closed
        async for message in ws:
            event = json.loads(message)
            print(event)

asyncio.run(main())
To keep the connection alive, send a heartbeat in the background whenever the connection is idle:
import asyncio
import json
import websockets

async def heartbeat(ws, interval=30):
    """Send a ping every `interval` seconds to prevent timeout."""
    while True:
        await asyncio.sleep(interval)
        await ws.send(json.dumps({"method": "ping"}))

async def main():
    uri = "wss://ws.pacifica.fi/ws"

    async with websockets.connect(uri) as ws:
        # Start heartbeat task
        asyncio.create_task(heartbeat(ws))

        await ws.send(json.dumps({
            "method": "subscribe",
            "params": {
                "source": "prices"
            }
        }))

        async for message in ws:
            event = json.loads(message)
            print(event)

asyncio.run(main())

Build docs developers (and LLMs) love