On this page
API reference
Live book stream
Connect to the book’s WebSocket and use snapshots to recover after disconnects.
GET /v1/collections/:chainId/:collection/ws#
Upgrade to a WebSocket for the collection book. Open one connection and process messages in arrival order.
Path and query parameters#
| Name | Type | Required | Meaning | Default | Limits |
|---|---|---|---|---|---|
chainId |
integer | Yes | NFT chain ID. | — | 1 for this API. |
collection |
address | Yes | Selected Ethereum ERC-721 contract. | — | 20 bytes, 0x prefix. |
view |
string | No | Use catalogue for catalogue invalidations. |
Book stream. | Other values open the book stream. |
Response fields#
| Field | Type | Meaning |
|---|---|---|
snapshot.depth |
object | A full current book, using the depth model. The stream does not add the HTTP depth route’s image URLs. |
delta.seq, bookTs, sentAt |
integers | Sequence and event times in Unix milliseconds. The source time may be the book time. |
delta.events |
array | order.upsert carries a public order summary. order.remove carries id, reason and sourceTs. Reasons include cancelled, filled, expired and invalid. |
delta.healthOrderIds |
array, optional | Orders whose public health state changed. |
delta.depth |
object | Current depth after the batch. An empty event array can still carry changed depth. |
catalogue.version |
string | Opaque catalogue version. On change, fetch the catalogue again. |
Cache. HTTP 101 upgrades have no cache directive.
Limit. No route-specific connection or replay limit.
Errors#
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request |
A path, query or body field failed validation. |
| 404 | not_found |
The collection, feed or venue is unavailable on this site. |
| 426 | invalid_request |
Use a WebSocket upgrade request. |
Example request#
curl --http1.1 -i -N --max-time 5 \
-H 'Connection: Upgrade' -H 'Upgrade: websocket' \
-H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==' \
'https://marketplace.example/v1/collections/1/0x4a8b01e437c65fa8612e8b699266c0e0a98ff65c/ws'Example response#
{
"type": "snapshot",
"depth": {
"chainId": 1,
"collection": "0x4a8b01e437c65fa8612e8b699266c0e0a98ff65c",
"seq": 5,
"asOf": 1796385137466,
"feeBps": 50,
"asks": [
{
"priceKind": "estimate",
"venueVersion": "v2",
"quoteAsOf": 1796384877183,
"quoteBlock": 26556586,
"poolId": "v2-174",
"id": "nftx:v2-174:ask",
"source": "nftx",
"tokenId": null,
"priceWei": "835537869790280",
"feeWei": "0",
"takerWei": "835537869790280",
"currency": "ETH",
"expiresAt": 1796385295
},
…
],
"bids": [
{
"priceKind": "estimate",
"venueVersion": "v2",
"quoteAsOf": 1796385115934,
"id": "nftx:v2:bid",
"source": "nftx",
"tokenId": null,
"priceWei": "760340024594830",
"feeWei": "0",
"takerWei": "760340024594830",
"currency": "ETH",
"expiresAt": 1796385205
},
…
],
"listed": 2,
"observedInventory": {
"tokens": 363,
"asOf": 1796385115272
},
"nativeOrderHealth": {
"asOf": 1796385115270,
"coverage": {
"asks": {
"total": 0,
"checked": 0
},
"bids": {
"total": 0,
"checked": 0
}
},
"validUntil": 1796385295270,
"asks": "empty",
"bids": "empty"
},
"best": {
"ask": {
"priceKind": "estimate",
"venueVersion": "v2",
"quoteAsOf": 1796384877183,
"quoteBlock": 26556586,
"poolId": "v2-174",
"id": "nftx:v2-174:ask",
"source": "nftx",
"tokenId": null,
"priceWei": "835537869790280",
"feeWei": "0",
"takerWei": "835537869790280",
"currency": "ETH",
"expiresAt": 1796385295
},
"bid": {
"priceKind": "estimate",
"venueVersion": "v2",
"quoteAsOf": 1796385115934,
"id": "nftx:v2:bid",
"source": "nftx",
"tokenId": null,
"priceWei": "760340024594830",
"feeWei": "0",
"takerWei": "760340024594830",
"currency": "ETH",
"expiresAt": 1796385205
},
"collectionBid": {
"priceKind": "estimate",
"venueVersion": "v2",
"quoteAsOf": 1796385115934,
"id": "nftx:v2:bid",
"source": "nftx",
"tokenId": null,
"priceWei": "760340024594830",
"feeWei": "0",
"takerWei": "760340024594830",
"currency": "ETH",
"expiresAt": 1796385205
},
"openSeaCollectionBid": null
},
"sellSources": [
{
"venue": "nftx-v2",
"status": "ok",
"asOf": 1796385116419
},
…
],
"counts": {
"native": {
"asks": 0,
"bids": 0
},
"opensea": {
"asks": 0,
"bids": 0
},
"nftx": {
"asks": 2,
"bids": 2
},
"punks": {
"asks": 0,
"bids": 0
}
}
}
}A successful upgrade returns HTTP 101. Curl shows the handshake and raw frames. Use a WebSocket client to decode them. snapshot and catalogue are sent immediately after their corresponding upgrades. The server can send a replacement snapshot on a live connection. Use the full depth on each book message. The server omits signed marketplace order payloads from events.
Reconnection and replay#
Reconnect for a new snapshot. The route has no replay cursor, history of missed frames, or client subscription messages. seq helps you track the book state. When disconnected, keep previously displayed prices marked stale until the new snapshot arrives. Select ?view=catalogue on a separate socket if you also need catalogue notifications.
const socket = new WebSocket("wss://marketplace.example/v1/collections/1/0x4a8b01e437c65fa8612e8b699266c0e0a98ff65c/ws");
socket.addEventListener("message", (event) => {
const message = JSON.parse(event.data);
if (message.type === "snapshot" || message.type === "delta") {
renderDepth(message.depth);
}
});Catalogue message#
{"type":"catalogue","version":"1796385115682"}Delta message#
Not verified. This example is written from the response's schema and was not produced by a running site.
{
"type": "delta",
"seq": 1,
"bookTs": 1796384939000,
"sentAt": 1796384939000,
"events": [],
"depth": {
"chainId": 1,
"collection": "0x4a8b01e437c65fa8612e8b699266c0e0a98ff65c",
"seq": 1,
…
}
}