[LiveTennisApiBridge] add - #5090
Open
bensynapse wants to merge 1 commit into
Open
bensynapse wants to merge 1 commit into
bensynapse wants to merge 1 commit into
Conversation
Tennis scores from the Live Tennis API for ATP, WTA, Challenger and ITF: live matches, today's schedule, today's finished matches and upcoming fixtures, one item per match. The bridge needs an api key, read from the [LiveTennisApiBridge] section of config.ini.php and sent as a header rather than in the query string. With no key it reports a configuration error naming the section and the key. CACHE_TIMEOUT is 900 so that a feed costs at most 96 requests a day, inside the vendor's 100 a day free tier.
Contributor
|
@bensynapse |
Author
|
Thanks for porting the bridge and adding documentation. I found it in |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclosure: I work on the Live Tennis API, the vendor this bridge reads. It is a paid API with a free tier (no card). If a bridge for a service the author is involved with is unwelcome, say so and I will close this. AI tooling was used while writing it; I understand the code and have run the checks below myself.
What it adds
A bridge over the Live Tennis API's public v1 endpoints, one item per match:
GET /matches?status=liveGET /matches?status=upcoming&from=<today>&to=<today>GET /matches?status=completed&from=<today>&to=<today>GET /fixturesFilters: tour (ATP / WTA / Challenger / ITF / Juniors / all), draw (singles / doubles / both), an optional player-name substring, and a limit. Tour and draw are lists because the API's own enums bound them. The player name is free text and is matched locally on the two player names, because the API's player filter takes numeric player ids and resolving a name would cost a second request out of a 100-a-day budget.
Item titles carry the players, the games in each set and the status, for example "Jannik Sinner v Carlos Alcaraz 6-4 3-6 4-4 (live) — Wimbledon". The content adds tournament and round, surface, draw, format, sets, games per set, the game in progress, who is serving, whether the receiver is a point from the break, and both players with country and ranking where known. A retirement reads "(Carlos Alcaraz retired)". A match every source lost before a result reads "(closed unfinished, result unresolved)" and asserts no winner.
Why
No bridge in the tree publishes live match state or scores for any sport. The closest are
ABolaBridge, a sports newspaper's news feed, andSleeperFantasyFootballBridge, fantasy-league alerts. Both are article or alert feeds rather than live sport.Cache timeout
CACHE_TIMEOUTis 900, so fifteen minutes. One feed fetch costs exactly one API request and the free tier allows 100 a day, so a feed served through this cache costs at most 96 a day however often a reader polls it. The framework enforces that, not the bridge. Each distinct set of feed parameters is cached separately, which the docs page spells out.No key configured
The key is read from
[LiveTennisApiBridge] api_keyinconfig.ini.php, or the matching environment variable, and never from a feed parameter, since feed URLs get shared and logged.config.default.ini.phpgains that one section with an empty default. With no key the bridge raises a configuration error naming the section and the key; nothing else inconfig.default.ini.phpis touched and no other bridge changes behaviour. The key is sent as anX-API-Keyheader, never in the query string, so it stays out of access logs, the HTTP cache key and exception messages. A 401, a 403 where the plan does not include the endpoint, a 429, a 400 and a non-JSON body each produce a named bridge error rather than a PHP warning or a stack trace.Also adds
docs/10_Bridge_Specific/LiveTennisApiBridge.md, matching the pages the other configured bridges have.Verification
Run in a
php:8.3-clicontainer with the repo mounted:composer install, thencomposer test: 3349 tests, 34957 assertions, 2 skipped. Baseline without this change is 3343 / 34856 / 2, so the six new tests are theBridgeImplementationTestcases for this bridge and both skips are pre-existing.composer lint: clean, 624 files.testVersion 7.4-): clean, 636 files..phpfiles./healthanswers 200 without a key.Match/Score/Fixtureschemas, including a thirteen-case break-point truth table (advantage receiver, receiver at 40 against 0, 15 and 30, deuce, advantage server, tiebreak, null server, null points) and rows carrying nothing but an id. Items were then pushed throughFeedItem. No warnings undererror_reporting=E_ALL.Not verified: a live 200 payload, since the key lives on the vendor side rather than on my build machine. The 403, 429 and 400 paths are code paths I did not trigger against production.
One practical note:
prtesterwill show this bridge's configuration error unless a key is present in the environment it runs in, so a red result there is not necessarily a defect. I am happy to send a maintainer a key privately if you want the rendered feed in CI or for review.