Advanced plans only. Connect to wss://marilux.dev/stocks. The protocol is identical to Polygon's WebSocket: authenticate first, then subscribe, and messages keep flowing until you unsubscribe or disconnect.
1. On connect you receive:
[{"ev":"status","status":"connected","message":"Connected Successfully"}]
2. Authenticate:
{"action":"auth","params":"mh_live_your_key"}Success returns auth_success. A non-Advanced plan, a disabled or expired key, or too many open connections returns auth_failed with the reason in message. You must authenticate within 10 seconds or the server closes the connection with code 1008; failed authentications are closed too.
[{"ev":"status","status":"auth_success","message":"authenticated"}]
3. Subscribe: params is EVENT.TICKER, comma-separated. T = trades, Q = quotes.
{"action":"subscribe","params":"T.AAPL,Q.AAPL,T.MSFT"}If a subscription would exceed your plan's symbol limit, the extra symbols are rejected (the rest still subscribe) and you receive an error message listing them.
4. Messages arrive as arrays and may contain several events:
[{"ev":"T","sym":"AAPL","x":12,"i":"133121","p":334.8,"s":5,"c":[12,14,37,41],"t":1789775989256756500}]
Limits are counted per symbol: subscribing to both T.AAPL and Q.AAPL counts as one. Wildcard (*) subscriptions aren't supported. Limits: monthly Advanced — 2 connections, 200 symbols; yearly Advanced — 5 connections, 500 symbols; trial — 1 connection, 10 symbols.
Reconnects: if your client reads too slowly and more than 2 MB backs up on our side, the connection closes with code 1013 so it can't affect other customers. Connections also drop during server maintenance. Always reconnect automatically and re-send auth and subscribe.
Unsubscribe with {"action":"unsubscribe","params":"T.AAPL"}. Idle subscriptions cost nothing extra but count toward your symbol limit.
Node.js:
const ws = new WebSocket("wss://marilux.dev/stocks");
ws.onmessage = (event) => {
for (const m of JSON.parse(event.data)) {
if (m.status === "connected") ws.send(JSON.stringify({ action: "auth", params: "mh_live_your_key" }));
if (m.status === "auth_success") ws.send(JSON.stringify({ action: "subscribe", params: "T.AAPL" }));
if (m.ev === "T") console.log("trade:", m.sym, m.p, m.s);
}
};
Python (pip install websockets):
import asyncio, json, websockets
async def main():
async with websockets.connect("wss://marilux.dev/stocks") as ws:
async for raw in ws:
for m in json.loads(raw):
if m.get("status") == "connected":
await ws.send(json.dumps({"action": "auth", "params": "mh_live_your_key"}))
elif m.get("status") == "auth_success":
await ws.send(json.dumps({"action": "subscribe", "params": "T.AAPL"}))
elif m.get("ev") == "T":
print("trade:", m["sym"], m["p"], m["s"])
asyncio.run(main())