Connections to trade.qfex.com require authentication. You must authenticate within 1 minute of connecting or the server will close the connection.

How it works

Connect to the private websocket:
  • URL: wss://trade.qfex.com?api_key=YOUR_API_KEY
Then send an authentication message:
{ "type": "auth", "params": { "api_key": "YOUR_API_KEY" } }

Sample Code

# Python (websocket-client)
# pip install websocket-client
import json
import websocket

def on_open(ws):
    ws.send(json.dumps({ "type": "auth", "params": { "api_key": "YOUR_API_KEY" } }))

def on_message(ws, message):
    print("Message:", message)

def on_error(ws, error):
    print("Error:", error)

def on_close(ws, code, reason):
    print("Closed:", code, reason)

ws = websocket.WebSocketApp(
    "wss://trade.qfex.com?api_key=YOUR_API_KEY",
    on_open=on_open,
    on_message=on_message,
    on_error=on_error,
    on_close=on_close,
)
ws.run_forever()

Example Response

{ "type": "auth", "result": "success" }