WebSocket
Overview
The djctl WebSocket API provides a simple mechanism for providing real-time track transition updates to connected clients.
Connection details
The WebSocket service is available at the following location:
ws://127.0.0.1:9090/ws
Once connected, the service will push JSON events to the client.
Event data
As a new track transitions into “featured” state, a JSON formatted message is sent to all WebSocket clients. The following is an example message:
{"artist":"Fred Falke","title":"So Good","art":"iVBORw0...[REDUCED]","spotify_code":"iVBORaa...[REDUCED]","duration":235,"timestamp_epoch":1644597809584,"timestamp":"2022-02-11T08:43:29.58463-08:00","elapsed":"00:01:05"}
Attribute dictionary
The following table enumerates attributes found in the event JSON.
Attribute | Type | Description |
---|---|---|
title | string | Track title |
artist | string | Track artist |
genre | string | Track genre |
art | string | Base64 encoded PNG (RGB, 256x256) |
spotify_code | string | Base64 encoded PNG |
duration | integer | Total track duration in seconds |
timestamp | string | Timestamp in format 2022-02-11T08:24:47.162918-08:00 |
timestamp_epoch | integer | Unix time; the number of seconds elapsed since January 1, 1970 UTC |
elapsed | string | Elapsed time since the first track triggered in format hh:mm:ss |