WebSocket / STOMP guide
The cse.lk Next.js app opens a STOMP session (via SockJS / @stomp/stompjs) against:
https://www.cse.lk/api/ws
Topics (subscribe)
User-queue mirrors: /user/topic/<same>.
Request destinations (send)
After connect, the UI sends empty/trigger frames to:
/app/request-aspi/app/request-snp/app/request-status/app/request-summary/app/request-today-sharePrice/app/request-top-gainers/app/request-top-looses/app/request-most-active-trades/app/request-daytrade
Notes
- Raw
curlWebSocket upgrade may301; follow the same SockJS negotiate path the browser uses. - For alerting / polite bots, prefer HTTP
POST /tradeSummaryon an interval. - Use WS for live dashboards that already mirror the official site behavior.
- Re-verify topics by searching cse.lk JS chunks for
subscribe("/topic/.
Minimal JS sketch (illustrative)
// Illustrative only — match current @stomp/stompjs + SockJS versions yourself.
import { Client } from "@stomp/stompjs";
import SockJS from "sockjs-client";
const client = new Client({
webSocketFactory: () => new SockJS("https://www.cse.lk/api/ws"),
onConnect: () => {
client.subscribe("/topic/status", (msg) => console.log(JSON.parse(msg.body)));
client.publish({ destination: "/app/request-status", body: "" });
},
});
client.activate();