Connect & Authenticate
Connection URL
Section titled “Connection URL”wss://ws.darkfibre.dev/v1?apiKey=api_your_key_here- Use the same API key as the REST API
- Connection rejected with 401 if invalid
Basic Connection
Section titled “Basic Connection”npm install wsimport WebSocket from 'ws';
const ws = new WebSocket( 'wss://ws.darkfibre.dev/v1?apiKey=api_your_key_here');
ws.onopen = () => { // Ready to subscribe};
ws.onmessage = (event) => { const message = JSON.parse(event.data.toString()); console.log(message);};
ws.onerror = (error) => { console.error('WebSocket error:', error);};pip install websocket-clientimport websocket
def on_message(ws, message): print(message)
ws = websocket.WebSocketApp( "wss://ws.darkfibre.dev/v1?apiKey=api_your_key_here", on_message=on_message)
ws.run_forever()npm install -g wscatwscat -c wss://ws.darkfibre.dev/v1?apiKey=api_your_key_hereConnection Established
Section titled “Connection Established”On connect, the server sends:
{ "type": "connectionEstablished", "connectionId": "conn_...", "message": "Connected to Darkfibre real-time DEX trades feed"}You won’t receive transactions until you subscribe.
Rate Limiting
Section titled “Rate Limiting”- Limit: 5 messages per second per connection (to server)
- Warnings: 3 warnings before disconnection