| Title: | Client for the 'Live Tennis API' |
|---|---|
| Description: | Read live and historical tennis data from the 'Live Tennis API' <https://livetennisapi.com> into R. Covers live scores, fixtures, players, tournaments, rankings, head-to-head records and the 1968 to 2022 results archive, for the ATP, WTA, Challenger and ITF tours. List endpoints return tibbles. |
| Authors: | Synapse Research Ltd [aut, cre], Live Tennis API [cph] |
| Maintainer: | Synapse Research Ltd <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-11-09 06:47:56 UTC |
| Source: | https://github.com/livetennisapi/livetennisapi-r |
api_health() needs no key and says whether the API is up.
api_usage() reports your plan, your limits and what you have used today.
api_health() api_usage(key = NULL)api_health() api_usage(key = NULL)
key |
The API key. Defaults to |
A list.
api_health() if (nzchar(Sys.getenv("LIVETENNISAPI_KEY"))) api_usage()$tierapi_health() if (nzchar(Sys.getenv("LIVETENNISAPI_KEY"))) api_usage()$tier
archive_matches() searches past results. archive_players() returns
player bios. archive_career() sums one player's career over the archive.
These need a paid plan, from Basic up.
archive_matches( tour = NULL, name = NULL, from = NULL, to = NULL, round = NULL, level = NULL, limit = NULL, offset = NULL, ..., key = NULL ) archive_players( name = NULL, tour = NULL, limit = NULL, offset = NULL, ..., key = NULL ) archive_career(name, key = NULL)archive_matches( tour = NULL, name = NULL, from = NULL, to = NULL, round = NULL, level = NULL, limit = NULL, offset = NULL, ..., key = NULL ) archive_players( name = NULL, tour = NULL, limit = NULL, offset = NULL, ..., key = NULL ) archive_career(name, key = NULL)
tour |
|
name |
A player name, or part of one (at least three characters for
|
from, to
|
Play dates, as |
round |
A round code such as |
level |
A level code such as |
limit |
Rows per page. |
offset |
Rows to skip, for paging. |
... |
Other query parameters the endpoint accepts. |
key |
The API key. Defaults to |
archive_matches() and archive_players() return tibbles.
archive_career() returns a list.
archive_matches(tour = "atp", name = "federer", round = "F", level = "G")archive_matches(tour = "atp", name = "federer", round = "F", level = "G")
get_match() returns the full match. match_score() returns only the
current score, which is the fastest read while a match is live.
get_match(match_id, key = NULL) match_score(match_id, ..., key = NULL)get_match(match_id, key = NULL) match_score(match_id, ..., key = NULL)
match_id |
The match id, from |
key |
The API key. Defaults to |
... |
Other query parameters, such as |
A list.
m <- live_matches() if (nrow(m) > 0) match_score(m$id[1])m <- live_matches() if (nrow(m) > 0) match_score(m$id[1])
Every meeting between two players across the results archive and recent matches, with totals and a split by surface.
head_to_head(p1, p2, key = NULL)head_to_head(p1, p2, key = NULL)
p1, p2
|
Player names, or parts of them (at least three characters). |
key |
The API key. Defaults to |
A list with totals, by_surface and meetings.
h2h <- head_to_head("djokovic", "nadal") h2h$totalsh2h <- head_to_head("djokovic", "nadal") h2h$totals
Scheduled matches, earliest first.
list_fixtures( tour = NULL, draw = NULL, limit = NULL, offset = NULL, ..., key = NULL )list_fixtures( tour = NULL, draw = NULL, limit = NULL, offset = NULL, ..., key = NULL )
tour |
One of |
draw |
|
limit |
Rows per page. |
offset |
Rows to skip. To read a whole filtered set, add |
... |
Other query parameters the endpoint accepts. |
key |
The API key. Defaults to |
A tibble, one row per fixture.
list_fixtures(tour = "wta", limit = 20)list_fixtures(tour = "wta", limit = 20)
list_matches() reads matches by lifecycle status. live_matches() is the
same call with status = "live". Live and upcoming matches are on the free
plan. Completed results need a paid plan.
list_matches( status = "live", tour = NULL, draw = NULL, player = NULL, tier = NULL, from = NULL, to = NULL, limit = NULL, offset = NULL, updated_since = NULL, cursor = NULL, ..., key = NULL ) live_matches(tour = NULL, ..., key = NULL)list_matches( status = "live", tour = NULL, draw = NULL, player = NULL, tier = NULL, from = NULL, to = NULL, limit = NULL, offset = NULL, updated_since = NULL, cursor = NULL, ..., key = NULL ) live_matches(tour = NULL, ..., key = NULL)
status |
One of |
tour |
One of |
draw |
|
player |
One or more player ids. A match matches when either side is one of them. |
tier |
One or more tier codes, such as |
from, to
|
Play dates, as |
limit |
Rows per page. |
offset |
Rows to skip. To read a whole filtered set, add |
updated_since |
Read the change feed: rows changed at or after this
time, oldest first. Page it with |
cursor |
|
... |
Other query parameters the endpoint accepts. |
key |
The API key. Defaults to |
A tibble, one row per match. Read its paging details with
lta_meta().
live <- live_matches(tour = "atp") if (nrow(live) > 0) live[, c("id", "tournament", "players.p1.name", "players.p2.name")]live <- live_matches(tour = "atp") if (nrow(live) > 0) live[, c("id", "tournament", "players.p1.name", "players.p2.name")]
list_tournaments() searches the tournament catalogue. get_tournament()
returns one tournament by its stable id.
list_tournaments( search = NULL, tour = NULL, draw = NULL, tier = NULL, limit = NULL, offset = NULL, ..., key = NULL ) get_tournament(tournament_id, key = NULL)list_tournaments( search = NULL, tour = NULL, draw = NULL, tier = NULL, limit = NULL, offset = NULL, ..., key = NULL ) get_tournament(tournament_id, key = NULL)
search |
A name or part of one. Leave it out to list ranked players first. |
tour |
One of |
draw |
|
tier |
One or more tier codes, such as |
limit |
Rows per page. |
offset |
Rows to skip. To read a whole filtered set, add |
... |
Other query parameters the endpoint accepts. |
key |
The API key. Defaults to |
tournament_id |
The tournament id. |
list_tournaments() returns a tibble, get_tournament() a list.
list_tournaments(search = "open", tier = "grand_slam")list_tournaments(search = "open", tier = "grand_slam")
The other functions in this package are thin wrappers around this one. Use it for an endpoint that has no wrapper yet. The full list is in the reference at https://docs.livetennisapi.com/reference.html.
lta_get(path, query = list(), key = NULL, auth = TRUE, simplify = FALSE)lta_get(path, query = list(), key = NULL, auth = TRUE, simplify = FALSE)
path |
The endpoint path, for example |
query |
A named list of query parameters. |
key |
The API key. Defaults to |
auth |
Send the key. Only |
simplify |
Simplify JSON arrays into vectors and data frames. |
Failures raise a condition of class lta_error, with a subclass you can
catch: lta_auth_error (401), lta_plan_error (403: the endpoint needs a
higher plan), lta_rate_limited (429, with lta_abuse_throttled for the
24-hour block), lta_not_found (404), lta_bad_request (400), lta_gone
(410: the record was merged into another, and the body says which),
lta_connection_error (the API could not be reached) or lta_http_error
(anything else, such as a 5xx after the retries). The condition carries
status, code
(the API's machine-readable error), body and retry_after.
A call is tried up to three times, each with a 30-second timeout. Dropped
connections, timeouts, server errors (5xx) and the per-minute 429 are
retried, waiting what Retry-After asks for (at most a minute) or a short
backoff. The daily-quota 429 and abuse_throttled are raised at
once, because neither clears in seconds.
The parsed JSON body as a list.
lta_get("/matches", list(status = "live", tour = "atp"))lta_get("/matches", list(status = "live", tour = "atp"))
The key comes from the LIVETENNISAPI_KEY environment variable. Get a free
key, with no card, at https://livetennisapi.com/subscribe/free.
lta_key()lta_key()
The key as a string, or an error when it is not set.
# TRUE when a key is set. The key itself is never printed. nzchar(lta_key())# TRUE when a key is set. The key itself is never printed. nzchar(lta_key())
Every list function returns a tibble and keeps the response's meta
object as an attribute. lta_meta() reads it back. It holds limit,
offset, count, total (which can be NULL), has_more and, on the
change feed, next_cursor. Subsetting a tibble drops the attribute, so
read it from the result as it came back.
lta_meta(x)lta_meta(x)
x |
A tibble returned by a list function, such as |
A list, or NULL when x carries no paging details.
fx <- list_fixtures(limit = 10) lta_meta(fx)$has_morefx <- list_fixtures(limit = 10) lta_meta(fx)$has_more
With no player, returns the rank-ordered table for one official system.
With player, returns the ranking records those players held at as_of.
Elo ratings (system = "elo" with a tour) come in four ladders:
"overall", "hard", "clay" and "grass". The plan each mode needs is
on the pricing page, https://livetennisapi.com/pricing.
rankings( system = NULL, tour = NULL, surface = NULL, player = NULL, as_of = NULL, limit = NULL, offset = NULL, ..., key = NULL )rankings( system = NULL, tour = NULL, surface = NULL, player = NULL, as_of = NULL, limit = NULL, offset = NULL, ..., key = NULL )
system |
One or more of |
tour |
|
surface |
The Elo ladder. |
player |
One or more player ids. |
as_of |
The date the records must be in force on, as a |
limit |
Rows per page. |
offset |
Rows to skip. To read a whole filtered set, add |
... |
Other query parameters the endpoint accepts. |
key |
The API key. Defaults to |
A tibble, one row per ranking record.
rankings(system = "atp", limit = 100) rankings(system = "elo", tour = "wta", surface = "clay")rankings(system = "atp", limit = 100) rankings(system = "elo", tour = "wta", surface = "clay")
search_players() finds players by name. get_player() returns one
player's profile and ranking. player_stats() returns a player's record,
with filters for dates, surface and level, and needs a paid plan.
search_players(search = NULL, limit = NULL, offset = NULL, ..., key = NULL) get_player(player_id, key = NULL) player_stats( player_id, from = NULL, to = NULL, surface = NULL, level = NULL, last = NULL, ..., key = NULL )search_players(search = NULL, limit = NULL, offset = NULL, ..., key = NULL) get_player(player_id, key = NULL) player_stats( player_id, from = NULL, to = NULL, surface = NULL, level = NULL, last = NULL, ..., key = NULL )
search |
A name or part of one. Leave it out to list ranked players first. |
limit |
Rows per page. |
offset |
Rows to skip. To read a whole filtered set, add |
... |
Other query parameters the endpoint accepts. |
key |
The API key. Defaults to |
player_id |
The player id. |
from, to
|
Play dates, as |
surface |
|
level |
A tour code, as in |
last |
Only the most recent matches, this many. |
search_players() returns a tibble. The others return lists.
p <- search_players("alcaraz") if (nrow(p) > 0) get_player(p$id[1])p <- search_players("alcaraz") if (nrow(p) > 0) get_player(p$id[1])