PearPear
API Integration

Websocket

Subscribe to real-time prices, funding, fills, positions, and trigger events over the V3 gateway WebSocket.

The V3 gateway exposes a real-time WebSocket at:

wss://pro-gateway.pearprotocol.io/ws

It is a raw JSON-over-WebSocket protocol (not Socket.IO). Send JSON text frames; binary frames are rejected.

Control messages (client → server)

MethodShapePurpose
auth{ "method": "auth", "params": { "accessToken": "<token>" } }Authenticate the connection (required for private channels).
subscribe{ "method": "subscribe", "channel": "<channel>", "params": { … } }Subscribe to a channel.
unsubscribe{ "method": "unsubscribe", "channel": "<channel>" }Unsubscribe.
ping{ "method": "ping" }Keep-alive; the server replies pong.

Each message may carry an id, echoed back on the matching ack.

Channels

Public (no auth):

ChannelParamsStreams
prices{ connectors?, instrumentIds? }Mid / mark price updates.
funding{ connectors?, instrumentIds? }Funding-rate updates.
trades{ connectors?, instrumentIds? }Public trade prints.

Private (require auth):

ChannelParamsStreams
user_events{ topics? } (defaults to all)Your execution, position, schedule, ladder, trigger, rebalance, and notification events.
trigger_events{ connectors?, accountIds? }Trigger lifecycle for your accounts.

For private channels, either send an auth message after connecting, or pass the access token on the handshake. Browsers can't set WebSocket headers, so use ?token=<access-token> on the URL.

Server → client frames

FrameMeaning
welcome{ connectionId, heartbeatIntervalMs, resubscribeRequired: true }, sent on connect and every reconnect. Replay your subscriptions whenever you receive it.
ackConfirms a control message (matched by id).
event{ channel, topic, data }, the actual payload.
pongReply to ping.
error{ code, message }.

Event topics

user_events emits these topics (subscribe to a subset with params.topics):

  • Executions, execution.completed, execution.failed
  • Positions, position.created, position.updated, position.closed
  • Schedules (TWAP), schedule.created, schedule.completed, schedule.cancelled
  • Ladders, ladder.created, ladder.updated, ladder.cancelled
  • Triggers, trigger.created, trigger.triggered, trigger.cancelled, trigger.converted
  • Rebalance, rebalance.created, rebalance.updated, rebalance.executed, rebalance.paused, rebalance.cancelled
  • Notifications, notification.created

Public channels emit price.updated, funding.updated, trade.executed, and trigger.triggered.public.

Example

{ "method": "auth", "params": { "accessToken": "ACCESS_TOKEN" } }
{
  "method": "subscribe",
  "channel": "user_events",
  "params": {
    "topics": ["execution.completed", "execution.failed", "position.created", "position.updated", "position.closed"]
  }
}

Limits

  • Max frame 64 KB, max buffered 512 KB
  • 25 connections per IP
  • 120 control messages per minute (exceeding this closes the socket with code 1008)
  • 100 subscription keys per connection

On this page