Skip to content

Add tennis (ATP/WTA) support via a Live Tennis API provider - #231

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

Add tennis (ATP/WTA) support via a Live Tennis API provider#231
bensynapse wants to merge 1 commit into
dathbe:developmentfrom
bensynapse:add-tennis-livetennisapi-provider

Conversation

@bensynapse

Copy link
Copy Markdown

Follows up on #230. Adds tennis (ATP/WTA) as a league, built exactly as we discussed and PR'd against development.

Disclosure: I run the Live Tennis API, so this is vendor-authored — judge accordingly. We also ship a dedicated module, MMM-LiveTennis; this provider is for people who'd rather see tennis inside one unified MMM-MyScoreboard than run a second module. No conflict from our side.

What's here

  • providers/LiveTennisAPI.js — new provider implementing the same getScores(payload, gameDate, callback) contract as PWHL.js: its own POLL_FREQUENCY, self-starting poll, and normalization to the module's game object. Registered in node_helper.js.
  • League codes ATP, WTA, and TENNIS (all tours) added to supportedLeagues in MMM-MyScoreboard.js.
  • No schema change. The teams array is reused for player surnames (teams: ['Alcaraz', 'Djokovic']), matched case-insensitively against both players. Omit it for the full slate.
  • Zero renderer changes. Sets won go into the two score slots; the status line carries the set-by-set games (6-4 3-6 2-1), current game points (40-30, or TB 5-3 in a tiebreak), and a BP marker on break point; a marks the server.
  • README — a Tennis (ATP / WTA / TENNIS) section documents setup, the surname convention, and the API caveats.

API and the honest limits (documented in the README)

  • Data is the Live Tennis API free tier: GET /matches?status=live and ?status=upcoming, keyed with X-API-Key. One shared 15-minute poll spends two calls per refresh regardless of how many tennis leagues you follow (one cache feeds them all) — ~96 calls/day, inside the free 100/day (also 30/min).
  • That is fine for a mirror, not for sustained fast polling (which needs a paid tier), and the free tier serves live + upcoming only — completed/final results are a paid History surface, so the tennis rows show today's in-progress and scheduled matches. This is all stated plainly next to the free-key signup, as you asked.

Config example

{
  module: 'MMM-MyScoreboard',
  position: 'top_left',
  config: {
    liveTennisApiKey: 'YOUR_FREE_KEY',
    sports: [
      { league: 'ATP', teams: ['Alcaraz', 'Djokovic'] },
      { league: 'WTA', teams: ['Gauff', 'Swiatek'] },
    ],
  },
},

Checks

  • npm run lint — clean.
  • npm run test:unit — 129 pass, including a new tests/unit/providers/LiveTennisAPI.test.js (18 subtests: fetch/combine, tour & surname filtering, set/tiebreak/break-point formatting, error handling).
  • I didn't run the Playwright e2e suite since it needs the MagicMirror bootstrap + a live key; happy to if you'd like.

Nothing touches the other sports' code paths. Happy to adjust naming, the serving/BP presentation, or anything else to fit your conventions. I can send you a free key to test against a live slate — just say where.

Adds a new `providers/LiveTennisAPI.js` implementing the existing
`getScores(payload, gameDate, callback)` provider contract (same shape as
PWHL.js), registered in node_helper.js, with `ATP`, `WTA` and `TENNIS`
league codes wired into MMM-MyScoreboard.js. The `teams` array is reused
for player surnames, so no schema change is needed.

Scores map to the module's existing game object: sets won go in the two
score slots, the status line carries the set-by-set games, current game
points (including tiebreaks) and a break-point marker, and a dot marks the
server — no renderer changes.

Data comes from the Live Tennis API's FREE tier (live + upcoming matches;
one shared 15-minute poll, two calls per refresh). The README documents the
provider, the free-tier limits (30/min, 100/day) next to the key-signup
link, and that completed results are a paid surface.

Disclosure: I run the Live Tennis API, so this is vendor-authored — judge
accordingly. We also ship a dedicated MMM-LiveTennis module; this reaches
users who want tennis inside one unified scoreboard instead of a second
module. Unit tests added under tests/unit/providers/.

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