Node.js
import WebSocket from "ws";
// Sign an empty GET /v1 request as the Authentication guide describes.
const headers = sign({ method: "GET", path: "/v1", body: "" });
const ws = new WebSocket("wss://ws.sandbox.services.payward.com/v1", { headers });
ws.on("open", () => ws.send(JSON.stringify({
method: "subscribe",
params: { channel: "ticker", symbol: ["PF_XBTUSD"], asset_type: "perpetual", country: "DE" },
req_id: 1,
})));
ws.on("message", (data) => console.log(JSON.parse(data)));
import asyncio
import json
from websockets.asyncio.client import connect
async def main():
# Sign an empty GET /v1 request as the Authentication guide describes.
headers = sign(method="GET", path="/v1", body="")
async with connect("wss://ws.sandbox.services.payward.com/v1", additional_headers=headers) as ws:
await ws.send(json.dumps({"method": "subscribe", "params": {"channel": "ticker", "symbol": ["PF_XBTUSD"], "asset_type": "perpetual", "country": "DE"}, "req_id": 1}))
async for message in ws:
print(json.loads(message))
asyncio.run(main())
Market data stream
Connection
One connection carries any number of feeds, each one channel of one instrument.
- Sign an empty
GET /v1as the Authentication guide describes. - Answer the server’s pings, sent every 20 seconds.
- Close codes:
1011a feed failed,1001restart or missed pings,1003binary frame. Reconnect and resubscribe; nothing is replayed.
Node.js
import WebSocket from "ws";
// Sign an empty GET /v1 request as the Authentication guide describes.
const headers = sign({ method: "GET", path: "/v1", body: "" });
const ws = new WebSocket("wss://ws.sandbox.services.payward.com/v1", { headers });
ws.on("open", () => ws.send(JSON.stringify({
method: "subscribe",
params: { channel: "ticker", symbol: ["PF_XBTUSD"], asset_type: "perpetual", country: "DE" },
req_id: 1,
})));
ws.on("message", (data) => console.log(JSON.parse(data)));
import asyncio
import json
from websockets.asyncio.client import connect
async def main():
# Sign an empty GET /v1 request as the Authentication guide describes.
headers = sign(method="GET", path="/v1", body="")
async with connect("wss://ws.sandbox.services.payward.com/v1", additional_headers=headers) as ws:
await ws.send(json.dumps({"method": "subscribe", "params": {"channel": "ticker", "symbol": ["PF_XBTUSD"], "asset_type": "perpetual", "country": "DE"}, "req_id": 1}))
async for message in ws:
print(json.loads(message))
asyncio.run(main())
WSS
wss://ws.sandbox.services.payward.com/v1
Authorizations
Response
The connection is upgraded to a WebSocket.