Skip to main content

Integration package connecting the Live Tennis API and LangChain

Project description

langchain-livetennis

Official LangChain integration for the Live Tennis API.

Give an agent real-time tennis: live scores, match detail, player profiles and upcoming fixtures for ATP, WTA, Challenger, ITF and junior Grand Slam draws.

PyPI - Version License

Installation

pip install -U langchain-livetennis

Credentials

Get a free key (1,000 requests/day) at https://livetennisapi.com/subscribe/free, then:

export LIVETENNISAPI_KEY="your-key"

A request without a key is answered with HTTP 401 {"error": "unauthorized"}.

Quickstart

from langchain_livetennis import LiveTennisToolkit

toolkit = LiveTennisToolkit()
tools = toolkit.get_tools()

matches = tools[0].invoke({"status": "live", "tour": "atp", "limit": 5})
print(matches)

Or use a single tool on its own:

from langchain_livetennis import LiveTennisScoreTool

LiveTennisScoreTool().invoke({"match_id": 18953})

In an agent

from langchain.agents import create_agent
from langchain_livetennis import LiveTennisToolkit

agent = create_agent(model="claude-sonnet-4-6", tools=LiveTennisToolkit().get_tools())

agent.invoke(
    {"messages": [{"role": "user", "content": "Who is leading the live ATP matches right now?"}]}
)

Tools

Tool Endpoint What it returns
live_tennis_matches GET /matches Matches by status (live, upcoming, completed), optionally one tour, with the latest score
live_tennis_match GET /matches/{id} One match in full: players, tournament, surface, round, status, score
live_tennis_match_score GET /matches/{id}/score Just the score — sets, games, points, server, tiebreak flag
live_tennis_player_search GET /players Players matching a name, ranked players first
live_tennis_player GET /players/{id} One player's bio, ranking and cached statistics
live_tennis_fixtures GET /fixtures Upcoming scheduled fixtures, earliest first

Every tool returns the API's JSON payload as a string, so nothing is lost on the way to the model.

tour accepts atp, wta, challenger, itf or juniors. Each value covers that tour's singles and doubles draws, and juniors covers the boys' and girls' Grand Slam draws. An unrecognised value is a 400 rather than a silent pass-through, so a caller never receives a tour it did not ask for.

Plans

status="live", status="upcoming" and every other tool here work on the FREE key. status="completed" is part of the paid History product and needs BASIC or above — a free key gets HTTP 403, surfaced as LiveTennisUpgradeRequired.

Errors

Exception When
LiveTennisAuthError 401 — key missing, unknown, or disabled
LiveTennisUpgradeRequired 403 — valid key, plan too low
LiveTennisNotFound 404 — no such match or player, or no data yet
LiveTennisBadRequest 400 — a query parameter was rejected
LiveTennisRateLimited 429 — carries .retry_after in seconds
LiveTennisServerError 5xx, or the API was never reached

All inherit from LiveTennisAPIError. Inside a tool call they are re-raised as LangChain's ToolException, so an agent can be configured to recover:

from langchain_livetennis import LiveTennisMatchesTool

tool = LiveTennisMatchesTool(handle_tool_error=True)

Requests retry automatically on 429 and 5xx only, honouring Retry-After with exponential backoff and jitter. A 401 or 403 is never retried — a bad key or an unentitled plan cannot start working, and retrying only burns the rate limit.

Configuration

from langchain_livetennis import LiveTennisClient, LiveTennisToolkit

toolkit = LiveTennisToolkit(api_key="...")

# Or share a fully configured client across every tool:
client = LiveTennisClient(api_key="...", timeout=10.0, max_retries=3)
toolkit = LiveTennisToolkit(client=client)

Development

uv sync --all-groups
uv run pytest tests/unit_tests
uv run ruff check .
uv run ruff format --check .
uv run mypy langchain_livetennis

The unit suite runs entirely against an in-process fake API (tests/mock_api.py) — no key and no network access required. The integration tests under tests/integration_tests/ skip themselves unless LIVETENNISAPI_KEY is set.

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_livetennis-0.1.0.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_livetennis-0.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_livetennis-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_livetennis-0.1.0.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for langchain_livetennis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e3b4145481f84ec38e79efad27b3cb88ce0c57f18ca5461162911341240faf7
MD5 cc08baa657e5beb3400842ed1395c08a
BLAKE2b-256 8a4b13aab0d6a2b930944a61199395beb5e021c7e893ef8f81f9833de17b9047

See more details on using hashes here.

File details

Details for the file langchain_livetennis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_livetennis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e6ef71b660aae0211f95cc53792d7d73e2bd6d476f61418fcfed3d09d5cb791
MD5 98bbd656af2bcbffb9ef932e7d972dba
BLAKE2b-256 cdd401f83e6211424be8ce6c0d8a312002136e170c12c7836900f42200ca5b64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page