Skip to main content

WebSockets API

This reference documents the Paxos WebSocket API.

The Market Data Feed streams event-driven updates for the entire order book or for a single market. The Execution Data Feed streams event information for all markets or for a single market.

⚙️ Follow the quickstart for a hands-on introduction.

Market Data Feed

Once a secure (wss://) connection is established, the initial response message shows the state of the order book, including both bids and asks, in the SNAPSHOT. Prices are in descending order for bids and ascending order for asks.

tip

When streaming data for all markets, differentiate the per-market updates using the market field.

Market Data Request

  • Production: wss://ws.paxos.com/marketdata
  • Sandbox: wss://ws.sandbox.paxos.com/marketdata

Market Data Path Parameter

  • Production: wss://ws.paxos.com/marketdata/{market}
  • Sandbox: wss://ws.sandbox.paxos.com/marketdata/{market}
ParameterRequiredDescription
marketNoFilter the data stream for a single market. For example, BTCUSD or another market from available markets.

Market Data Initial Response

ParameterRequiredDescription
typeYesThe initial value of SNAPSHOT shows the state of the order book for both bids and asks. Subsequent messages show all executed trades, and other order book changes, in the UPDATE stream.
marketYesOne of the available markets or a single market if the market path parameter is specified.
bidsYesIncludes bids.price in descending order and bids.amount. Each price-amount pair represents a level of the book.
asksYesIncludes asks.price in ascending order and asks.amount. Each price-amount pair represents a level of the book.
final_snapshotYesDemarcates the end of the initial SNAPSHOT. Initial value always true. Subsequent messages in UPDATE format.

Market Data Update Response

When processing UPDATE messages observe the following rules:

  • If side=BUY and amount=0, remove the existing entry with price price from the bids list.
  • If side=BUY and an entry with price price already exists in the bids list, update the amount for the given entry in the bids list to amount.
  • If side=BUY and no entry with price price exists in the bids list, add an entry with price price and amount amount to bids list.
  • If side=SELL, apply the logic used as for BUY to the asks list.
ParameterRequiredDescription
typeYesValue always UPDATE. Show all executed trades, and other order book changes, in the data stream.
marketYesOne of the available markets or the single market if the market path parameter is specified.
sideYesValue either BUY or SELL. Specifies the activity type.
priceYesThe current price.
amountYesThe current amount.

Market Data Example Response

Request URL: wss://ws.sandbox.paxos.com/marketdata/BTCUSD

{
"type": "SNAPSHOT",
"market": "BTCUSD",
"bids": [
{
"price": "19994.25",
"amount": "0.7755"
},
{
"price": "19993.75",
"amount": "0.83676985"
},
...
],
"asks": [
{
"price": "19994.5",
"amount": "0.97548541"
},
{
"price": "19996",
"amount": "1.135"
},
...
],
"final_snapshot": true
}

{
"type": "UPDATE",
"market": "BTCUSD",
"side": "BUY",
"price": "19958.5",
"amount": "0.62649999"
}

{
"type": "UPDATE",
"market": "BTCUSD",
"side": "SELL",
"price": "20115.25",
"amount": "0"
}
...

Execution Data Feed

Upon secure (wss://) connection, you will start to receive messages for each market execution (based on the use of the market parameter). The first message corresponds to the last execution for the market at the point of the connection. After that, each new message represents a new execution.

If there are no executions for longer periods of time for a particular market upon connection you may not receive any message until a new execution is made.

tip

Upon reconnection you will receive the last execution for the market, in which case clients should handle duplicate messages. You may use a match number as an idempotent field.

Execution Data Request

  • Production: wss://ws.paxos.com/executiondata
  • Sandbox: wss://ws.sandbox.paxos.com/executiondata

Execution Data Path Parameter

  • Production: wss://ws.paxos.com/executiondata/{market}
  • Sandbox: wss://ws.sandbox.paxos.com/executiondata/{market}
ParameterRequiredDescription
marketNoFilter the data stream for a single market. For example, BTCUSD or another market from available markets.

Execution Data Response

ParameterRequiredDescription
marketYesOne of the available markets or the single market if the market path parameter is specified.
priceYesThe execution price.
amountYesThe execution amount.
executed_atYesTimestamp of the execution.
match_numberYesUnique execution number.

Execution Data Example Response

Request URL: wss://ws.sandbox.paxos.com/executiondata/BTCUSD

{
"market": "BTCUSD",
"price": "24228.75",
"amount": "0.00000412",
"executed_at": "2023-03-13T18:46:53.386Z",
"match_number": "6AJVAX7BTCH8"
}
...

✉️ Question? Contact us:
Crypto Brokerage Support | Commodities Settlement Support | Help Desk

📃 Check out our Changelog.