Skip to main content

Executor availability WebSocket

A public WebSocket that keeps you up to date on which executors are rentable now. Use it instead of polling GET /executors. No API key needed.

wss://lium.io/api/executors/ws

The server sends JSON frames. Clients send nothing.

Send a User-Agent header

Requests without one get 403. Browsers, curl, Python websockets and Go gorilla/websocket set it for you. Others need it added:

ClientAdd the header
websocatwebsocat -t -H='User-Agent: my-app/1.0' -B 2000000 wss://lium.io/api/executors/ws
Node wsnew WebSocket(url, { headers: { 'User-Agent': 'my-app/1.0' } })
Rust tungsteniteGive connect a request from http::Request::builder().header("User-Agent", "my-app/1.0")

Keep a local executor map​

The first frame is always a full snapshot. Replace your state with it, then apply each upsert or delete by executor_id.

const executors = new Map<string, ExecutorAvailability>()
const socket = new WebSocket('wss://lium.io/api/executors/ws')

socket.onmessage = ({ data }) => {
const frame = JSON.parse(data)

switch (frame.type) {
case 'snapshot':
executors.clear()
for (const executor of frame.executors) executors.set(executor.id, executor)
break
case 'upsert':
executors.set(frame.executor_id, frame.executor)
break
case 'delete':
executors.delete(frame.executor_id)
break
case 'heartbeat':
break
}
}

Frames​

FieldMeaning
typesnapshot, upsert, delete or heartbeat
schema_versionProtocol version, now 1
seqSequence number within this connection
tsServer time, Unix seconds

Snapshot​

{
"type": "snapshot",
"schema_version": 1,
"seq": 42,
"ts": 1787572800.5,
"executors": [
{
"id": "ad83de56-8a04-4ab1-ac5a-4ab007b4e2b3",
"machine_name": "NVIDIA H200",
"price_per_gpu": 2.5,
"gpu_count": 8,
"available_gpu_count": 8,
"uptime_in_minutes": 4815,
"specs": { "gpu": { "count": 8, "details": [] } }
}
]
}

Upsert and delete​

upsert adds or replaces an executor. delete removes it.

{
"type": "upsert",
"schema_version": 1,
"seq": 43,
"ts": 1787572801.0,
"executor_id": "ad83de56-8a04-4ab1-ac5a-4ab007b4e2b3",
"executor": { "id": "ad83de56-8a04-4ab1-ac5a-4ab007b4e2b3", "available_gpu_count": 4 }
}
{
"type": "delete",
"schema_version": 1,
"seq": 44,
"ts": 1787572802.0,
"executor_id": "ad83de56-8a04-4ab1-ac5a-4ab007b4e2b3"
}

heartbeat only confirms the connection is alive.

Fetch a snapshot without a socket​

A plain GET on the same URL returns one snapshot and closes. The data is at most about 30 seconds old.

curl -fsS https://lium.io/api/executors/ws | jq '.executors | length'

Limit: 60 requests per minute per IP.

Reconnects​

On every reconnect, wait for the next snapshot and start from it. If the server closes with code 1013, retry with exponential backoff.