Skip to main content
QFEX provides 2 endpoints for websocket: MDS requires an API key to connect.
Trade requires an API key and a connection must authenticate within 1 minute of connecting.

Getting Started

You can connect to our websocket endpoints directly using your preferred language or websocket client library.
import websocket
import json

def on_message(ws, message):
    data = json.loads(message)
    print("Received:", data)

ws = websocket.WebSocketApp(
    "wss://mds.qfex.com",
    on_message=on_message
)

ws.run_forever()
import WebSocket from "ws";

const ws = new WebSocket("wss://mds.qfex.com");

ws.on("open", () => {
  console.log("Connected");
  // Example: subscribe to trades
  ws.send(JSON.stringify({
    type: "subscribe",
    channel: "trades",
    symbol: "AAPL-USD"
  }));
});

ws.on("message", (message) => {
  console.log("Received:", message.toString());
});
package main

import (
  "fmt"
  "log"
  "github.com/gorilla/websocket"
)

func main() {
  c, _, err := websocket.DefaultDialer.Dial("wss://mds.qfex.com", nil)
  if err != nil {
    log.Fatal("dial:", err)
  }
  defer c.Close()

  // Example: subscribe to order book
  sub := map[string]interface{}{
    "type": "subscribe",
    "channel": "book",
    "symbol": "AAPL-USD",
  }
  c.WriteJSON(sub)

  for {
    _, message, err := c.ReadMessage()
    if err != nil {
      log.Println("read:", err)
      return
    }
    fmt.Printf("recv: %s\n", message)
  }
}

Authentication

All websocket connections to trade.qfex.com and mds.qfex.com require an API Key.
You must include it as a query parameter:
wss://trade.qfex.com?api_key=YOUR_API_KEY
wss://mds.qfex.com?api_key=YOUR_API_KEY
trade.qfex.com requires authentication within 1 minute of connecting.
I