API and external control: REST and WebSocket
Control LemonScore through the REST and WebSocket API: enable the API, create API keys and connect your own integrations such as venue control systems.
The API lets other programs control the scoreboard: a venue control system, your own control panel or a script. It offers REST endpoints and a WebSocket connection (Socket.io) on port 4001, protected by API keys.
Available with LemonScore Enterprise. The Stream Deck does not need the API.
Enable the API and create a key
- Open Settings › Connectivity.
- On the API card, switch on Enable API.
- Under Create API Key, enter a name, for example the name of the integration.
- Click Generate.
- In the dialog, click Copy and store the key in your integration.
LemonScore shows the full key only in this dialog. Afterwards you only see its first characters. If the key gets lost, create a new one.
Active API Keys lists every key with its name and creation date. Revoke blocks a key at once. Every integration that uses it stops working.
Connect to the API
- Address:
http://<IP address of the LemonScore computer>:4001/api/v1 - Authentication: send the key in the header
X-API-Key: lsk_…orAuthorization: Bearer lsk_… - Test without a key:
GET /api/v1/healthanswers with"status": "ok"and the LemonScore version - Documentation: while the API is enabled,
http://<IP address>:4001/api/v1/docslists every endpoint in the browser
Count a goal for the home team:
curl -X POST http://192.168.1.42:4001/api/v1/match/score/increment \
-H "X-API-Key: lsk_…" \
-H "Content-Type: application/json" \
-d '{"team": "team1"}'Start the match clock:
curl -X POST http://192.168.1.42:4001/api/v1/clock/start -H "X-API-Key: lsk_…"Switch the blackout on:
curl -X PUT http://192.168.1.42:4001/api/v1/blackout \
-H "X-API-Key: lsk_…" \
-H "Content-Type: application/json" \
-d '{"enabled": true}'Changes made over REST only answer {"success": true}. You receive the new state over the WebSocket connection.
What the API controls
The endpoints are grouped by area, each under /api/v1/…:
- Match and match clock:
match,clock(score, match clock, stoppage time, timer) - Animations:
animations, including your own animations from the active animation set (GET /api/v1/animations/custom) - Penalty shootout:
penalties - Lineup:
lineupwith show, hide, next, previous, overview, pause, resume, zoom onto a player, jump to a slide and choosing the team. See Lineup. - Playlists:
playlistswith play, pause, resume and stop, plusGET /api/v1/playlists/statefor the current state - Ads banner and blackout:
banner,blackout - Teams and players:
teams - Music, media and LED:
music,media,coex - Shortcuts:
shortcutsto run them, plusGET /api/v1/shortcuts/state(which shortcuts can run right now and which toggle buttons are on) andGET /api/v1/shortcuts/log(the last 20 runs)
/api/v1/docs lists every endpoint with all parameters.
Live data over WebSocket
For displays that need every change at once, connect with Socket.io to the same address and pass the key when connecting:
const socket = io("http://192.168.1.42:4001", { auth: { apiKey: "lsk_…" } });
socket.on("match:state", (state) => console.log(state));After connecting, LemonScore sends the current state of every area, then every change, for example match:state, clock:state or blackout:state.
Good to know
- The API is reachable from the whole local network while Enable API is on. When it is off, port 4001 is closed unless a Stream Deck is paired.
- Each IP address may send 1000 requests per minute. Above that the API answers
429. - Create a separate key for each integration. That way you can revoke one access without affecting the others.
- If you move to a plan without the API, the keys stay listed so you can revoke them.
- The remote control on port 4000 answers
GET /api/identifywithout a key, with the venue name and version. The mobile app uses it to find LemonScore on the network. This is not part of the Enterprise API. - For questions about an integration, use the contact form.