From 8b79a4dccd9953a5f1b427c5a3120420ef4a2acd Mon Sep 17 00:00:00 2001
From: bensynapse <118375461+bensynapse@users.noreply.github.com>
Date: Wed, 25 Nov 2026 06:49:08 +0200
Subject: [PATCH] Add a version compatibility matrix to the client libraries
page
The page now maps every official library to its current release, the public
API version it targets and its minimum runtime.
The public API version is read from the default base URL each library ships.
The build check compares it with the version the spec serves. A contents list
at the top links every section, including the new one.
The page now reports the later read date as its last modified date, so the
sitemap and the article data stay honest about the change.
New tests cover the matrix and the drift checks.
---
docs/client-libraries.html | 41 ++++++-
docs/llms.txt | 2 +-
docs/sitemap.xml | 2 +-
scripts/build_reference.py | 130 ++++++++++++++++++++-
scripts/test_build_reference.py | 194 ++++++++++++++++++++++++++++++++
5 files changed, 363 insertions(+), 6 deletions(-)
create mode 100644 scripts/test_build_reference.py
diff --git a/docs/client-libraries.html b/docs/client-libraries.html
index 8c168db..5c56fa4 100644
--- a/docs/client-libraries.html
+++ b/docs/client-libraries.html
@@ -15,7 +15,7 @@
@@ -217,6 +217,18 @@
Live Tennis API client libraries
+
Which client library should I use?
Pick the row for your language. Every package calls the same REST API with the same key.
The version is the newest release on the registry named under each install command.
@@ -240,6 +252,33 @@
Which client library should I use?
Every package is MIT licensed. Plugins for apps and automation platforms are not in this table.
They live in the GitHub organisation.
+
Which API version and runtime does each library target?
+
This matrix pins every official library to one row. Each row names the current release, the
+public API version the library calls, and the lowest language or runtime version it supports.
+
Each official library with its current release, the public API version it targets and its minimum runtime
Library
Current release
Public API version
Minimum runtime
Python client
1.8.0
v1
Python 3.9
+
JavaScript and TypeScript client
1.10.3
v1
Node 18
+
Go client
1.3.0
v1
Go 1.25
+
PHP client
1.2.0
v1
PHP 8.1
+
.NET client
1.2.1
v1
.NET Standard 2.0 or .NET 8
+
Dart and Flutter client
1.2.1
v1
Dart 3.5
+
Swift client
1.2.1
v1
Swift 5.9
+
R client
0.2.1
v1
R 4.1
+
MCP server
1.6.5
v1
Node 20
+
Vercel AI SDK tools
1.3.0
v1
Node 22
+
Export command
0.1.0
v1
Python 3.9
+
Laravel package
1.1.0
v1
PHP 8.2
+
Haystack integration
0.2.0
v1
Python 3.10
+
LangChain integration
0.2.0
v1
Python 3.10
+
LlamaIndex tools
0.1.0
v1
Python 3.10
+
+
Every library here targets the same public API version, so moving between libraries needs no
+change of API version. The build check compares each stated version with the version the spec serves
+and fails if they differ.
+
The current release and minimum runtime were read from each library's registry, or its Git tags
+where it has none, on . The public API
+version is the one in each library's default base URL, or in the client it wraps, read from source
+on .
+
Which libraries support REST, the live stream, file export and MCP?
Every library reads the REST API. Two open the live stream, one writes files and one is an MCP server.
Which parts of the API each library covers
Library
REST
Live stream
File export
MCP
Python client
Yes
Yes
No
No
diff --git a/docs/llms.txt b/docs/llms.txt
index 10447ad..67331cc 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -256,7 +256,7 @@ backtest.
- Haystack integration: `pip install livetennisapi-haystack`, package https://pypi.org/project/livetennisapi-haystack/, source https://github.com/livetennisapi/livetennisapi-haystack
- LangChain integration: `pip install -U langchain-livetennis`, package https://pypi.org/project/langchain-livetennis/, source https://github.com/livetennisapi/langchain-livetennis
- LlamaIndex tools: `pip install llama-index-tools-livetennisapi`, package https://pypi.org/project/llama-index-tools-livetennisapi/, source https://github.com/livetennisapi/llama-index-tools-livetennisapi
-- Every library with its latest version, minimum runtime and endpoint coverage: https://docs.livetennisapi.com/client-libraries.html
+- Every library with its current release, the public API version it targets, its minimum runtime and endpoint coverage: https://docs.livetennisapi.com/client-libraries.html
## Affiliate programme
- https://affiliates.livetennisapi.com/program — 51% recurring commission for the lifetime
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index b925e09..3f73719 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -14,7 +14,7 @@
https://docs.livetennisapi.com/ai-sdk.html2026-10-22weekly0.8https://docs.livetennisapi.com/errors-and-rate-limits.html2026-11-09weekly0.8https://docs.livetennisapi.com/export-formats.html2026-11-11weekly0.8
- https://docs.livetennisapi.com/client-libraries.html2026-11-19weekly0.8
+ https://docs.livetennisapi.com/client-libraries.html2026-11-25weekly0.8https://docs.livetennisapi.com/sportsml.html2026-11-15weekly0.8https://docs.livetennisapi.com/changelog.html2026-11-21weekly0.6
diff --git a/scripts/build_reference.py b/scripts/build_reference.py
index 0aad291..2bb523f 100644
--- a/scripts/build_reference.py
+++ b/scripts/build_reference.py
@@ -1392,7 +1392,7 @@ def build_llms_txt(spec: dict[str, Any]) -> str:
" fixtures, players, player, rankings and tournaments. Reads the key from LIVETENNISAPI_KEY.",
*[f"- {c['name']}: `{c['install']}`, package {c['registry_url']}, source {c['repo']}"
for c in CLIENTS if c["key"] in CLIENTS_LLMS_EXTRA],
- f"- Every library with its latest version, minimum runtime and endpoint coverage: {DOCS_URL}/client-libraries.html",
+ f"- Every library with its current release, the public API version it targets, its minimum runtime and endpoint coverage: {DOCS_URL}/client-libraries.html",
"",
"## Affiliate programme",
"- https://affiliates.livetennisapi.com/program — 51% recurring commission for the lifetime",
@@ -3420,6 +3420,32 @@ def _export_body(spec: dict[str, Any]) -> str:
# Every listed package states the MIT licence on its registry or, for Swift, in its LICENSE file.
CLIENTS_LICENCE = "MIT"
+# The public API version each library targets, for the version compatibility matrix. The value is
+# the path segment after /api/public/ in the default base URL the library ships. It was read from
+# each library's own source on API_VERSION_CHECKED, one source per key:
+# python src/livetennisapi/_base.py DEFAULT_BASE_URL
+# js src/client.ts DEFAULT_BASE_URL
+# go README.md quick start WithBaseURL(...)
+# php src/LiveTennisApi.php DEFAULT_BASE_URL
+# dotnet src/LiveTennisApi/LiveTennisApiClientOptions.cs DefaultBaseUrl
+# dart lib/src/client.dart defaultBaseUrl
+# swift Sources/LiveTennisApi/LiveTennisApiClient.swift defaultBaseURL
+# r R/client.R lta_base_url()
+# langchain langchain_livetennis/_client.py the shipped base URL
+# llamaindex llama_index/tools/livetennisapi/base.py the shipped base URL
+# laravel config/livetennis.php the shipped base URL
+# The remaining packages call the API through a language client and so target that client's version:
+# mcp and ai through the JavaScript client, export and haystack through the Python client.
+# A value is "not stated" when a library's source names no base URL. None do today. The build check
+# in _clients_drift compares every value here with the version the spec serves, so a row cannot
+# quietly target a version the API no longer publishes.
+API_VERSION_CHECKED = "2026-11-25"
+CLIENT_API_VERSION: dict[str, str] = {
+ "python": "v1", "js": "v1", "go": "v1", "php": "v1", "dotnet": "v1", "dart": "v1",
+ "swift": "v1", "r": "v1", "mcp": "v1", "ai": "v1", "export": "v1", "laravel": "v1",
+ "haystack": "v1", "langchain": "v1", "llamaindex": "v1",
+}
+
# The eight language clients, in the column order of the endpoint table.
CLIENT_LANGUAGES = ["python", "js", "go", "php", "dotnet", "dart", "swift", "r"]
CLIENT_SHORT = {"python": "Python", "js": 'JS', "go": "Go", "php": "PHP", "dotnet": ".NET",
@@ -3642,6 +3668,37 @@ def _samples_match_clients_page() -> list[str]:
return problems
+def _spec_api_version(spec: dict[str, Any]) -> str:
+ """The public API version the spec serves, read from the last path segment of its server URL.
+
+ The server is ``https://api.livetennisapi.com/api/public/v1``, so this returns ``v1``. The
+ compatibility matrix compares every library's targeted version against this, so the version is
+ never typed twice: it is read from the spec that the SDKs are generated from.
+ """
+ # Read every server the spec declares, not only the top-level list: OpenAPI lets a path item
+ # or an operation override the server, and a staged v2 override there must not hide behind the
+ # top-level v1. Collect them all and require one version, so the matrix cannot drift from any
+ # server the API actually publishes.
+ def server_urls(node: Any) -> list[str]:
+ if not isinstance(node, dict):
+ return []
+ return [s["url"] for s in (node.get("servers") or []) if isinstance(s, dict) and "url" in s]
+
+ urls = server_urls(spec)
+ for path_item in (spec.get("paths") or {}).values():
+ urls += server_urls(path_item)
+ if isinstance(path_item, dict):
+ for operation in path_item.values():
+ urls += server_urls(operation)
+ if not urls:
+ raise SystemExit("the spec declares no server, so the public API version is unknown")
+ versions = {url.rstrip("/").rsplit("/", 1)[-1] for url in urls}
+ if len(versions) != 1:
+ raise SystemExit("the spec serves more than one public API version: "
+ + ", ".join(sorted(versions)))
+ return versions.pop()
+
+
def _clients_drift(spec: dict[str, Any]) -> None:
"""Fail the build when the page names an operation the spec no longer has, or a row is malformed."""
problems = []
@@ -3679,6 +3736,23 @@ def _clients_drift(spec: dict[str, Any]) -> None:
problems.append("the Swift install line does not name the Swift row's version")
if "get" not in spec["paths"].get("/ws-token", {}):
problems.append("the page explains Token only with GET /ws-token, which the spec does not define")
+ # The version compatibility matrix. Its release-line cell is each row's own version, the same
+ # field the install matrix shows, so the two tables cannot name different versions for a
+ # library. For the eight language clients that version is also pinned against
+ # code-samples/sdk-methods.yaml by _samples_match_clients_page. Its API-version cell must match
+ # the version the spec serves, so the matrix cannot keep naming v1 after the API moves on.
+ spec_api_version = _spec_api_version(spec)
+ for key in keys:
+ if key not in CLIENT_API_VERSION:
+ problems.append(f"the compatibility matrix has no public API version for the row {key!r}")
+ for key in CLIENT_API_VERSION:
+ if key not in by_key:
+ problems.append(f"CLIENT_API_VERSION names {key!r}, which is not a library row")
+ for key, api_version in CLIENT_API_VERSION.items():
+ if api_version != "not stated" and api_version != spec_api_version:
+ problems.append(
+ f"the compatibility matrix says {key} targets API {api_version}, "
+ f"but the spec serves {spec_api_version}")
if problems:
raise SystemExit("client-libraries.html disagrees with the spec or itself:\n " + "\n ".join(problems))
@@ -3718,6 +3792,26 @@ def install_cell(c: dict[str, Any]) -> str:
"" + rows + "
",
"Client libraries",
)
+ # The version compatibility matrix: one row per library, its current release, the public API
+ # version it targets and its minimum runtime. The API-version cell is read from CLIENT_API_VERSION
+ # and shown as "Not stated" where a library's source names no base URL (none do today).
+ def api_version_cell(key: str) -> str:
+ value = CLIENT_API_VERSION.get(key, "not stated")
+ return "Not stated" if value == "not stated" else value
+
+ compat_rows = "".join(
+ f'
{E(c["name"])}
'
+ f'
{E(c["version"])}
{E(api_version_cell(c["key"]))}
'
+ f'
{E(c["runtime"])}
\n'
+ for c in CLIENTS
+ )
+ compat = scrollx(
+ f"
{vh_caption('Each official library with its current release, the public API version it targets and its minimum runtime')}"
+ '
Library
Current release
'
+ '
Public API version
Minimum runtime
'
+ "
" + compat_rows + "
",
+ "Version compatibility",
+ )
cover_rows = "".join(
f'
\n" if key in CLIENT_QUICKSTART_AFTER else "")
for key, heading, install, snippet, note in CLIENT_QUICKSTARTS
)
- return f"""
Which client library should I use?
+ body = f"""
Which client library should I use?
Pick the row for your language. Every package calls the same REST API with the same key.
The version is the newest release on the registry named under each install command.
These client libraries are the official SDKs for the API.
Every package is MIT licensed. Plugins for apps and automation platforms are not in this table.
They live in the GitHub organisation.
+
Which API version and runtime does each library target?
+
This matrix pins every official library to one row. Each row names the current release, the
+public API version the library calls, and the lowest language or runtime version it supports.
+{compat}
+
Every library here targets the same public API version, so moving between libraries needs no
+change of API version. The build check compares each stated version with the version the spec serves
+and fails if they differ.
+
The current release and minimum runtime were read from each library's registry, or its Git tags
+where it has none, on . The public API
+version is the one in each library's default base URL, or in the client it wraps, read from source
+on .
+
Which libraries support REST, the live stream, file export and MCP?
Every library reads the REST API. Two open the live stream, one writes files and one is an MCP server.
{coverage}
@@ -3807,6 +3913,21 @@ def install_cell(c: dict[str, Any]) -> str:
for spreadsheets, with no package to install
"""
+ # The contents list is generated from the section headings, so a new section appears in it
+ # without a second edit and the list can never name a section the page does not have.
+ headings = re.findall(r'
(.*?)
', body)
+ # Guard: every section heading must reach the list. A heading written with another attribute
+ # before id, or wrapped across lines, would slip past the strict pattern and vanish from the
+ # nav. Count every ]", body)):
+ raise SystemExit("the client libraries contents list missed a section heading: "
+ "every
must open with its id attribute on one line")
+ items = "".join(f'
\n' for sid, text in headings)
+ contents = ('\n")
+ return contents + body
# ----------------------------------------------------------------- SportsML mapping -------------
@@ -4290,7 +4411,10 @@ def _sportsml_body(spec: dict[str, Any]) -> str:
"Coverage read from the source of each published version."
),
"body": _clients_body,
- "date": CLIENTS_CHECKED,
+ # dateModified and the sitemap lastmod track the page's newest content check. The version
+ # compatibility matrix was read on API_VERSION_CHECKED, later than CLIENTS_CHECKED, so the
+ # page changed that day. The registry read date stays CLIENTS_CHECKED in the meta and prose.
+ "date": max(CLIENTS_CHECKED, API_VERSION_CHECKED),
"about": [
{"@type": "SoftwareSourceCode", "name": f'Live Tennis API {c["name"]}',
"alternateName": c["package"], "url": c["registry_url"], "version": c["version"],
diff --git a/scripts/test_build_reference.py b/scripts/test_build_reference.py
new file mode 100644
index 0000000..69d612b
--- /dev/null
+++ b/scripts/test_build_reference.py
@@ -0,0 +1,194 @@
+"""Tests for the client libraries version compatibility matrix.
+
+Run: python -m unittest scripts/test_build_reference.py
+
+The first group checks the committed client-libraries.html: the compatibility section and its
+anchor exist, the contents list links it, and every library row names its current release, the
+public API version it targets and its minimum runtime. The release line is each library's own
+version, and the API version is the one the spec serves, so the second group breaks copies of
+those inputs and checks that the build refuses each one. The real files are never written.
+"""
+
+from __future__ import annotations
+
+import copy
+import re
+import sys
+import unittest
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import build_reference as br # noqa: E402
+
+PAGE = br.DOCS / "client-libraries.html"
+
+
+def a_different_version(version: str) -> str:
+ """A public API version that is not the current one, for the drift tests.
+
+ Derived from the current version so these tests still exercise a real mismatch after a future
+ migration (v1 to v2 and so on), rather than hard-coding the next version.
+ """
+ match = re.fullmatch(r"v(\d+)", version)
+ return f"v{int(match.group(1)) + 1}" if match else version + "x"
+
+
+def compat_table(html: str) -> str:
+ """The rendered compatibility table block."""
+ match = re.search(r'aria-label="Version compatibility".*?', html, re.S)
+ assert match, "the compatibility table is not on the page"
+ return match.group(0)
+
+
+def compat_rows(html: str) -> list[list[str]]:
+ rows = []
+ for row in re.findall(r"