Package-level declarations

The clients (SportsDbClient, SportsDbFutures), their configuration, the v1 and v2 endpoint groups, Helpers for common tasks (v2 or v1 depending on the key), and the exceptions.

Types

Link copied to clipboard
class ApiMessageException(message: String, val apiMessage: String) : SportsDbException

The API answered with a {"Message": ...} body this library does not recognise.

Link copied to clipboard
class Helpers

Common tasks in one call. Each helper picks the best endpoint for your key: v2 with a premium key, v1 with the free key 123 (and then the free key's small result limits apply, as noted on each method). Any key other than 123 that the API accepts is a paid key, so no extra call is made to find out.

Link copied to clipboard
class HttpStatusException(message: String, val status: Int, val bodySnippet: String) : SportsDbException

Any other non-2xx HTTP response. bodySnippet is the start of the response body.

Link copied to clipboard

The API rejected the key (HTTP 400 Invalid Premium API key). Only 123 and paid keys work.

Link copied to clipboard

The request failed before an HTTP response arrived (DNS, connection, timeout...).

Link copied to clipboard

A v2 endpoint was called with the free key. v2 accepts premium keys only.

Link copied to clipboard
class RateLimitException(message: String, val retryAfter: Duration?) : SportsDbException

The rate limit was exceeded (HTTP 429) and retries were used up or disabled. retryAfter is how long the server asked to wait, when it said.

Link copied to clipboard

One finished API call.

Link copied to clipboard
fun interface RequestListener

Receives one RequestEvent per API call, after it finishes. Set it with SportsDbConfig.requestListener. It runs on the calling coroutine, so keep it quick. Exceptions it throws are ignored, so a broken listener can't break API calls.

Link copied to clipboard
class ResponseParseException(message: String, cause: Throwable? = null) : SportsDbException

The response body could not be understood as a TheSportsDB envelope.

Link copied to clipboard
class SportsDbClient(val config: SportsDbConfig = SportsDbConfig())

The TheSportsDB client.

Link copied to clipboard

Client settings. Build with SportsDbClient's DSL:

Link copied to clipboard

Base class for every error this library throws.

Link copied to clipboard
class SportsDbFutures(val client: SportsDbClient, scope: CoroutineScope) : AutoCloseable

A Java-friendly wrapper: every SportsDbClient method, returning a CompletableFuture.

Link copied to clipboard
class V1Api

The v1 API: https://www.thesportsdb.com/api/v1/json/{key}/{endpoint}.php.

Link copied to clipboard
class V2Api

The v2 API: https://www.thesportsdb.com/api/v2/json/{group}/{name}/{param}, with the key in the X-API-KEY header. Premium keys only: with the free key every call throws PremiumRequiredException without touching the network.

Functions

Link copied to clipboard

Builds a client: SportsDbClient { apiKey = "..."; cache = InMemoryResponseCache() }.