API DocsCricket Live Overlay System v1.0.0

REST API documentation

Base URL: http://localhost:3000/api. All paths below are relative to that base. Responses are JSON unless the endpoint states otherwise.

The shared browser helper window.CricketCommon.api(path, options) automatically prefixes /api, sends JSON bodies, and attaches the Bearer token from local storage.

Try it

Runs real browser requests with CricketCommon.api using your current session token. Every "Try it" button below sends its result here.

Response
Select an endpoint and run the request.

Authentication

Send the token as Authorization: Bearer <token>. Roles: admin for administration, admin or scorer for scoring actions. Seeded accounts are admin / admin123 and scorer / scorer123.

curl -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123"}'
Response 200
{
  "token": "jwt-token-returned-by-login",
  "user": { "id": "u_admin", "username": "admin", "role": "admin" }
}

The response token value shown here is representative. Copy the real token from your own login response.

POST/api/auth/login

Verify credentials. Sets an http-only cookie and returns a bearer token. Public endpoint.

Request body
{ "username": "admin", "password": "admin123" }
Response 200
{ "token": "jwt-string", "user": { "username": "admin", "role": "admin" } }

Response 401: { "error": "Invalid username or password" }

GET/api/auth/me

Return the user attached to the current token or cookie. When authentication is disabled, returns a local admin user.

Response 200
{ "user": { "id": "u_admin", "username": "admin", "role": "admin" } }

System

GET/api/health

Liveness probe. No authentication required.

curl
curl http://localhost:3000/api/health
Response 200
{ "ok": true, "time": "2026-11-28T10:15:30.000Z" }
GET/api/config

Feature flags and server version. No authentication required.

curl
curl http://localhost:3000/api/config
Response 200
{
  "authEnabled": true,
  "publicScorer": false,
  "defaultLanguage": "en",
  "version": "1.0.0",
  "integrations": { "cricketApi": false, "obs": true, "youtube": false }
}

Teams

GET/api/teams

List all teams ordered by name. Public read-only endpoint.

curl
curl http://localhost:3000/api/teams
Response 200
[
  {
    "id": "team_mumbai",
    "name": "Mumbai Titans",
    "short_name": "MT",
    "logo_url": "/assets/team-red.svg",
    "color": "#ef4444",
    "created_at": "2026-01-01T00:00:00.000Z"
  }
]
POST/api/teamsadmin

Create a team. Supply an id to use a custom identifier.

curl
curl -X POST http://localhost:3000/api/teams \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Chennai Chargers","shortName":"CC","logoUrl":"/assets/team-blue.svg","color":"#2563eb"}'
Response 201
{ "id": "generated-uuid" }

Response 400 when name or shortName is missing.

PUT/api/teams/:idadmin

Update a team. Omitted fields keep their stored values.

Request body
{ "name": "Mumbai Titans", "shortName": "MT", "logoUrl": "/assets/team-red.svg", "color": "#ef4444" }
Response 200
{ "ok": true }

Response 404: { "error": "Team not found" }

Players

GET/api/players?teamId=team_mumbai

List players, optionally filtered by team. Public read-only endpoint.

curl
curl "http://localhost:3000/api/players?teamId=team_mumbai"
Response 200
[
  {
    "id": "p_m01",
    "team_id": "team_mumbai",
    "name": "Rohan Sharma",
    "photo_url": "/assets/player.svg",
    "role": "batsman",
    "batting_style": "Right-hand bat",
    "bowling_style": "Right-arm offbreak",
    "jersey_no": 1,
    "is_substitute": 0
  }
]
POST/api/playersadmin

Create a player. name and teamId are required.

Request body
{
  "name": "New Player",
  "teamId": "team_mumbai",
  "photoUrl": "/assets/player.svg",
  "role": "all-rounder",
  "battingStyle": "Right-hand bat",
  "bowlingStyle": "Right-arm medium",
  "jerseyNo": 14,
  "isSubstitute": false
}
Response 201
{ "id": "generated-uuid" }
PUT/api/players/:idadmin

Update player identity, photo, styles, jersey number and substitute status.

Request body
{ "name": "Renamed Player", "role": "bowler", "bowlingStyle": "Right-arm fast", "jerseyNo": 9, "isSubstitute": true }
Response 200
{ "ok": true }
DELETE/api/players/:idadmin

Delete a player. Response 404 when the player does not exist.

curl
curl -X DELETE http://localhost:3000/api/players/PLAYER_ID \
  -H "Authorization: Bearer TOKEN"
Response 200
{ "ok": true }

Series

GET/api/series

List series ordered by creation time.

Response 200
[{ "id": "series_demo", "name": "Demo T20 Series", "season": "2026", "created_at": "2026-01-01T00:00:00.000Z" }]
POST/api/seriesadmin

Create a series. Only name is required.

Request body
{ "name": "Regional T20 Cup", "season": "2026" }
Response 201
{ "id": "generated-uuid" }

Matches

GET/api/matches?status=live

List matches. The status filter is optional: setup, live, innings_break, or complete.

Response 200
[
  {
    "id": "demo_completed",
    "title": "Demo: Mumbai Titans vs Kathmandu Kings",
    "team_a_id": "team_mumbai",
    "team_b_id": "team_kathmandu",
    "overs": 20,
    "status": "complete",
    "phase": "complete",
    "result_text": "Mumbai Titans won by 12 runs",
    "venue": "Demo Stadium"
  }
]
GET/api/matches/:id

Full live state: match metadata, current innings, batters, bowler, squads, events and chase information.

Response 200
{
  "match": { "id": "demo_completed", "status": "complete", "teamA": { "short_name": "MT" }, "teamB": { "short_name": "KK" } },
  "innings": { "inningsNo": 2, "runs": 156, "wickets": 4, "balls": 120, "overs": "20.0" },
  "allInnings": [],
  "chase": { "target": 169, "runsNeeded": 0, "statusText": "Mumbai Titans won by 12 runs" },
  "squads": {},
  "events": []
}
GET/api/matches/:id/state

Same live state with an extra external field containing the latest imported score.

Response 200 shape
{ "match": {}, "innings": {}, "external": { "ok": false } }
GET/api/matches/:id/scorecard

All innings with batters, bowlers, extras and partnerships.

Response 200 shape
{
  "match": { "id": "demo_completed", "title": "Demo match" },
  "innings": [{ "inningsNo": 1, "runs": 168, "wickets": 5, "batters": [], "bowlers": [], "partnerships": [] }],
  "events": []
}
POST/api/matchesadmin, scorer

Create a match with squad defaults taken from the team player lists.

Request body
{
  "title": "Mumbai vs Kathmandu T20 2",
  "teamAId": "team_mumbai",
  "teamBId": "team_kathmandu",
  "overs": 20,
  "seriesId": "series_demo",
  "venue": "Main Ground",
  "tossWinnerId": "team_mumbai",
  "tossChoice": "bat",
  "battingFirstId": "team_mumbai"
}
Response 201
{ "id": "generated-uuid", "status": "setup", "overs": 20 }
DELETE/api/matches/:idadmin

Delete a match and its innings, balls and squad rows. Response 200: { "ok": true }.

Scoring actions

All scoring actions accept the admin or scorer role and broadcast state changes to Socket.IO subscribers.

POST/api/matches/:id/startadmin, scorer

Start a setup match. Opening batters and bowler are optional; defaults come from the playing XI.

Request body
{ "strikerId": "p_m01", "nonStrikerId": "p_m02", "bowlerId": "p_k08" }
Response 200
{ "match": { "status": "live", "phase": "first" }, "innings": { "runs": 0, "wickets": 0 } }
POST/api/matches/:id/balladmin, scorer

Record a delivery. Supports runs, wickets and every extra type.

Request body
{
  "bowlerId": "p_k08",
  "runs": 4,
  "extras": { "type": "wide", "runs": 1 },
  "wicket": true,
  "wicketType": "caught",
  "dismissedBatsmanId": "p_m01",
  "newBatsmanId": "p_m03",
  "fielderId": "p_k01"
}
Response 200 shape
{ "ballId": "uuid", "events": [{ "type": "four", "label": "FOUR" }], "inningsBreak": false }

A simple dot ball body: { "bowlerId": "p_k08", "runs": 0 }

POST/api/matches/:id/undoadmin, scorer

Undo the most recent delivery. Response 200 contains the updated scoring result and live state.

curl
curl -X POST http://localhost:3000/api/matches/demo_completed/undo \
  -H "Authorization: Bearer TOKEN"
POST/api/matches/:id/swapadmin, scorer

Swap striker and non-striker. Response 200 is the updated live state.

POST/api/matches/:id/bowleradmin, scorer

Set the current bowler for the next over.

Request body
{ "bowlerId": "p_k09" }
Response 200
{ "match": { "id": "demo_completed" }, "bowler": { "name": "Kiran Limbu" } }
POST/api/matches/:id/next-inningsadmin, scorer

Start the second innings during an innings break.

Request body
{ "strikerId": "p_k01", "nonStrikerId": "p_k02", "bowlerId": "p_m08" }
POST/api/matches/:id/super-overadmin, scorer

Create a super over for a tied match. Response 200 is the updated live state with a super-over innings.

POST/api/matches/:id/finishadmin, scorer

Mark a match complete and store the result and Man of the Match.

Request body
{ "resultText": "Mumbai Titans won by 12 runs", "motmPlayerId": "p_m01" }
Response 200
{ "match": { "status": "complete", "resultText": "Mumbai Titans won by 12 runs" } }
POST/api/matches/:id/motmadmin, scorer

Set or change the Man of the Match.

Request body
{ "playerId": "p_m01" }
Response 200
{ "match": { "motmPlayerId": "p_m01" } }

Response 400 when playerId is missing.

POST/api/matches/:id/revise-targetadmin, scorer

Apply a revised target, for example after a rain interruption.

Request body
{ "target": 120 }
Response 200
{ "match": { "revisedTarget": 120, "target": 120 } }

Response 400 when target is not a positive number.

Reports

GET/api/matches/:id/report

Full match report: scorecard, top performers, MVP table, turning point, wagon wheel, over graph, partnerships and key moments with video timestamps.

Response 200 shape
{
  "match": { "id": "demo_completed", "title": "Demo match" },
  "resultText": "Mumbai Titans won by 12 runs",
  "motm": { "player": { "name": "Rohan Sharma" }, "points": 142.5 },
  "topPerformers": { "batting": [], "bowling": [] },
  "keyMoments": [{ "videoTime": "02:00", "description": "FOUR" }],
  "youtube": { "title": "MT vs KK | Result | Cricket Live", "description": "Match description", "timestamps": [] }
}
GET/api/matches/:id/report/pdf

Downloads a binary PDF with Content-Type: application/pdf and an attachment filename.

curl
curl -o report.pdf http://localhost:3000/api/matches/demo_completed/report/pdf
GET/api/matches/:id/report/share.svg

Returns a 1200 by 630 share graphic as image/svg+xml, suitable for social posts and OBS.

curl
curl -o share.svg http://localhost:3000/api/matches/demo_completed/report/share.svg
GET/api/matches/:id/report/youtube

Returns only the YouTube title, description and chapter timestamps.

Response 200
{
  "title": "MT vs KK | Mumbai Titans won by 12 runs | Cricket Live",
  "description": "Match summary and key moments",
  "timestamps": [{ "time": "02:00", "label": "FOUR" }]
}

Career and leaderboards

GET/api/leaderboard/:type?limit=10

type is batsmen, bowlers or mvp. Unknown values fall back to batsmen. Default limit is 10.

Response 200, batsmen
[
  {
    "id": "p_m01", "name": "Rohan Sharma", "teamShort": "MT", "matches": 1,
    "runs": 68, "ballsFaced": 42, "fours": 6, "sixes": 3, "highest": 68,
    "battingAverage": 68, "strikeRate": 161.9, "fifties": 1, "hundreds": 0
  }
]
Response 200, bowlers
[{ "name": "Ishaan Gupta", "wickets": 3, "runsConceded": 28, "ballsBowled": 24, "bestBowling": "3/28", "economy": 7, "fiveWicketHauls": 0 }]
Response 200, mvp
[{ "name": "Rohan Sharma", "runs": 68, "wickets": 0, "catches": 1, "mvpPoints": 142.5 }]
GET/api/players/:id/profile

Player identity, team details, career aggregates and the last twenty batting innings.

Response 200 shape
{
  "player": { "id": "p_m01", "name": "Rohan Sharma", "photoUrl": "/assets/player.svg", "team": { "name": "Mumbai Titans", "shortName": "MT" } },
  "career": { "matches": 1, "runs": 68, "highest": 68, "strikeRate": 161.9 },
  "recentInnings": [{ "matchId": "demo_completed", "runs": 68, "balls": 42, "overs": "7.0" }]
}

Points

GET/api/points/:seriesId

Points table ordered by points then net run rate.

Response 200
[
  {
    "series_id": "series_demo", "team_id": "team_mumbai", "team_name": "Mumbai Titans",
    "played": 1, "won": 1, "lost": 0, "tied": 0, "no_result": 0,
    "points": 2, "net_rr": 0.6
  }
]
POST/api/points/:seriesId/recalculateadmin

Recompute the table from all completed matches in the series.

curl
curl -X POST http://localhost:3000/api/points/series_demo/recalculate \
  -H "Authorization: Bearer TOKEN"
Response 200
{ "ok": true, "teams": 2 }

Theme and language

GET/api/theme

Read the current broadcast theme.

Response 200
{
  "primary": "#7c3aed", "secondary": "#f59e0b", "accent": "#22d3ee",
  "background": "#0b1020", "text": "#ffffff", "font": "Roboto",
  "teamLogos": { "team_mumbai": "/assets/team-red.svg", "team_kathmandu": "/assets/team-blue.svg" },
  "sponsorLogo": "", "sponsorText": "", "showSponsor": true, "compact": false
}
POST/api/themeadmin

Merge fields into the stored theme and broadcast a theme:update socket event.

Request body
{
  "primary": "#6d28d9",
  "font": "Poppins",
  "teamLogos": { "team_mumbai": "/assets/team-red.svg" },
  "showSponsor": true,
  "sponsorText": "Presented by Cricket Live",
  "compact": false
}
Response 200
{ "theme": "complete merged object is returned directly" }

The endpoint returns the merged theme object itself, not a wrapper.

GET/api/language

Read the broadcast language.

Response 200
{ "language": "en" }
POST/api/languageadmin, scorer

Set the language to en, hi or ne and broadcast it to overlays.

Request body
{ "language": "hi" }
Response 200
{ "language": "hi" }

Export and backup

GET/api/export/jsonadmin

Download a full database backup as pretty-printed JSON with Content-Type: application/json.

curl
curl -o backup.json http://localhost:3000/api/export/json \
  -H "Authorization: Bearer TOKEN"
Response 200 shape
{ "teams": [], "players": [], "series": [], "matches": [], "innings": [], "balls": [] }
GET/api/export/csv?table=matchesadmin

Export one table as CSV. Valid tables include matches, teams, players, series, innings, balls and points_table. Unknown tables fall back to matches.

curl
curl -o matches.csv "http://localhost:3000/api/export/csv?table=matches" \
  -H "Authorization: Bearer TOKEN"
POST/api/admin/backupadmin

Write JSON and CSV backup files on the server disk and return their paths.

curl
curl -X POST http://localhost:3000/api/admin/backup \
  -H "Authorization: Bearer TOKEN"
Response 200 shape
{ "json": "backups/backup.json", "csv": ["backups/matches.csv"] }

External score and integrations

GET/api/external/score

Read the most recently synchronized third-party score.

Response 200 shape
{ "ok": false, "reason": "sync disabled or failed" }
POST/api/integrations/syncadmin

Poll the configured cricket API and broadcast an external:score event when data arrives.

Response 200 shape
{ "ok": true, "teams": { "name": "Team A", "score": "145/4" } }
POST/api/integrations/controladmin, scorer

Show or hide all overlays, or one named overlay, by broadcasting overlay:control.

Request body
{ "visible": false, "overlay": "scorebar" }
Response 200
{ "ok": true, "visible": false, "overlay": "scorebar" }

Use { "visible": true, "overlay": null } to show every overlay.

Socket.IO events

Connect with the client at /api/server/socket.io/socket.io.js. The shared helper CricketCommon.connectSocket(handlers) opens the connection, joins the overlay room, requests the theme and subscribes to a match.

DirectionEventPayloadPurpose
client to serverjoin:overlaysnoneJoin the broadcast room
client to serversubscribe:matchmatch idReceive that match's score updates
client to serverunsubscribe:matchmatch idStop receiving that match's updates
client to serverrequest:statematch idAsk for the current live state
client to serverrequest:themenoneAsk for the current theme
server to clientsubscribed{ matchId }Confirms a match subscription
server to clientscore:updatelive stateNew score, innings and chase data
server to clientoverlay:event{ type, label, playerId }Boundary, wicket, milestone and result animations
server to clienttheme:updatetheme objectColors, font, logos and sponsor settings
server to clientoverlay:control{ visible, overlay }Show or hide overlay panels
server to clientexternal:scoreexternal scoreThird-party score update
server to clientscene:changescene stateProduction scene switching
Browser client example
const socket = io({ transports: ['websocket', 'polling'] });
socket.on('connect', () => {
  socket.emit('join:overlays');
  socket.emit('subscribe:match', 'demo_completed');
  socket.emit('request:theme');
});
socket.on('score:update', (state) => console.log(state.innings.runs, state.innings.wickets));
socket.on('theme:update', (theme) => CricketCommon.applyTheme(theme));

OBS browser source setup

Every overlay page is a transparent, 1920 by 1080 browser source. Overlays are public and read-only: they only consume REST data and socket events, and they never require a login token.

  1. In OBS Studio, add a Browser source.
  2. Paste a local URL such as http://localhost:3000/overlay/scorebar?match=demo_completed.
  3. Set width to 1920 and height to 1080.
  4. Enable Shutdown source when not visible only if you want to stop socket traffic while the scene is hidden.
  5. Repeat for each overlay you want in the scene, then use the admin Settings tab to show or hide them live.
Available overlay URLs
http://localhost:3000/overlay/scorebar?match=demo_completed
http://localhost:3000/overlay/summary?match=demo_completed
http://localhost:3000/overlay/batsman?match=demo_completed
http://localhost:3000/overlay/lastballs?match=demo_completed
http://localhost:3000/overlay/boundary?match=demo_completed
http://localhost:3000/overlay/target?match=demo_completed
http://localhost:3000/overlay/toss?match=demo_completed
http://localhost:3000/overlay/result?match=demo_completed
http://localhost:3000/overlay/player/p_m01?id=p_m01&match=demo_completed

Use the admin dashboard's Copy buttons to generate each URL with the currently selected match id.