Skip to content

Connect & Authenticate

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
Terminal window
npm install ws
import 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);
};

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.

  • Limit: 5 messages per second per connection (to server)
  • Warnings: 3 warnings before disconnection