Skip to content

Add ATP/WTA tennis provider (Live Tennis API) — issue #230 - #232

Open
bensynapse wants to merge 1 commit into
dathbe:developmentfrom
bensynapse:tennis-provider
Open

Add ATP/WTA tennis provider (Live Tennis API) — issue #230#232
bensynapse wants to merge 1 commit into
dathbe:developmentfrom
bensynapse:tennis-provider

Conversation

@bensynapse

Copy link
Copy Markdown

Implements the tennis provider proposed in #230, targeting development as requested.

Disclosure: this provider is contributed by the Live Tennis API team (we run https://livetennisapi.com) — vendor-authored, so please judge it on the merits. The README section says the same up front.

What this adds

  • providers/LiveTennisAPI.js — a new provider following the existing CPL.js / PWHL.js conventions: a singleton shared-cache poller (POLL_FREQUENCY, startDataPoll, getData) that normalizes each match into the module's existing game object (hTeam/vTeam/hTeamLong/vTeamLong/hScore/vScore/status/gameMode) and returns via the same getScores(payload, gameDate, callback) contract as PWHL (callback(games, sortIdx, noGamesToday)).
  • node_helper.js — registers the provider (one line, alongside CPL/PWHL).
  • MMM-MyScoreboard.js — adds ATP and WTA to the league map. Nothing else changes; no other sport or provider is modified.
  • README.md — adds ATP/WTA to the leagues list and a "Tennis (ATP / WTA)" section covering config, the API key, and the rate limits.
  • package.json — adds Tennis/ATP/WTA keywords.
  • Unit teststests/unit/providers/LiveTennisAPI.test.js (12 tests).

Design (per the two questions in #230)

  1. Config shape — tennis is player-based, so the existing teams array holds player surnames (teams: ["Alcaraz", "Gauff"]). No schema change. Omit teams to show the whole tour slate.
  2. Rendering — the zero-renderer-change option: the home/visitor score slots show sets won; the set-by-set games (e.g. 6-4 3-6 2-1), current points and the serving player go in the existing status line. Players map to the home/visitor slots and the leagues set homeTeamFirst, so it renders "Player 1 vs Player 2".

API key & rate limits (documented in the README)

  • The key is read server-side only from the LIVETENNIS_API_KEY environment variable and is never sent to the browser.
  • Free tier is 30 requests/minute and 100 requests/day. The provider keeps one shared cache, so call volume does not grow with the number of tennis leagues or the module refresh rate. Each refresh spends 3 requests per tour (live + upcoming + completed); the default 15-minute cadence is ~288/day for one tour, which exceeds the free 100/day cap — so a free key is best for testing/light use and continuous operation needs a paid tier. LIVETENNIS_POLL_INTERVAL (minutes) lets a free key stay inside the cap (e.g. 45 min ≈ 96/day for one tour). A free key: https://livetennisapi.com/subscribe/free
  • If the key is missing or throttled, tennis just shows no games and the rest of the scoreboard is unaffected.

Checks

  • eslint clean across the whole repo (matches the module's @stylistic config).
  • Unit tests: 125 pass / 0 fail (12 new). node --check passes on all touched JS.
  • I could not run test:e2e here (it downloads a MagicMirror bootstrap + Chromium); happy to iterate if CI surfaces anything.

I don't follow racquet sports either, so I've kept this self-contained and additive — glad to adjust naming (e.g. a combined TENNIS league) or rendering to your preference.

Adds a new providers/LiveTennisAPI.js following the existing CPL/PWHL
provider conventions: a shared-cache poller that normalizes matches into
the module's game object (hTeam/vTeam/hScore/vScore/status/gameMode) and
serves every configured tennis league from one cache. Registers the
provider in node_helper.js and adds ATP and WTA to the league map in
MMM-MyScoreboard.js. No other sport/provider is touched.

Tennis is player-based, so the existing `teams` array holds player
surnames. The big score is sets won; the status line carries the
set-by-set games, current points and the serving player, so no renderer
changes are needed.

The API key is read server-side only from LIVETENNIS_API_KEY and never
sent to the browser. README documents setup and the free tier's
100 requests/day cap, including how to stay inside it via
LIVETENNIS_POLL_INTERVAL.

Adds unit tests for normalization, sets-won logic, polling and filtering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant