livetennisapi library

A Dart client for the Live Tennis API.

Real-time tennis scores, players, rankings, match-winner market prices and model win-probability for ATP, WTA, Challenger and ITF — over REST.

import 'package:livetennisapi/livetennisapi.dart';

Future<void> main() async {
  final client = LiveTennisApi(apiKey: 'twjp_…');
  try {
    final page = await client.listMatches(status: MatchStatus.live);
    for (final match in page.data) {
      print('${match.tournament}: '
          '${match.p1?.name} vs ${match.p2?.name}');
    }
  } finally {
    client.close();
  }
}

The package depends only on package:http and has no Flutter dependency, so it runs unchanged in pure Dart, Flutter, and on the web.

Classes

Analysis
Model analysis for a match. ULTRA tier only; either half may be null.
DataCompleteness
How much biographical detail is known for a player.
Fixture
A scheduled fixture. Players are names only — not yet resolved to ids.
ListMeta
Pagination envelope returned alongside list responses.
LiveTennisApi
A read-only client for the Live Tennis API.
Market
A match-winner market. PRO tier and above.
Match
A match.
MatchEvent
A match event. PRO tier and above.
Page<T>
A single page of a list endpoint: its data and the meta envelope.
Player
A player, or a doubles team.
Price
One price tick. side is 1 for player 1's outcome, 2 for player 2's.
Score
A match score at a point in time.

Enums

AuthHeader
Which header carries the API key.
MatchStatus
The lifecycle status filter accepted by LiveTennisApi.listMatches.
Tour
The tour filter accepted by LiveTennisApi.listMatches and LiveTennisApi.listFixtures.

Constants

defaultBaseUrl → const String
The default API base URL.
packageVersion → const String
The package version, sent in the User-Agent header.

Functions

exceptionForStatus(int statusCode, String message, {String? code, Object? body, Map<String, String> headers = const {}, String? url, String? requiredTier, num? retryAfter}) → LiveTennisApiException
Builds the exception subtype that matches an HTTP statusCode.

Exceptions / Errors

BadRequestException
400 — a query parameter was malformed (for example an unknown tour).
LiveTennisApiException
Base class for every error raised by this library.
NotFoundException
404 — no such resource, or no data for it yet.
RateLimitedException
429 — the tier's rate-limit window was exceeded.
ServerException
5xx — the API failed to serve the request.
ServiceUnavailableException
503 — the public surface is disabled or the service is down.
UnauthorizedException
401 — the key is missing, unknown, or disabled.
UpgradeRequiredException
403 — the endpoint exists but your tier does not unlock it.