SportsDbClient

class SportsDbClient(val config: SportsDbConfig = SportsDbConfig())

The TheSportsDB client.

val client = SportsDbClient()                         // free key 123, v1 only
val premium = SportsDbClient { apiKey = "..." } // v1 and v2

val arsenal = client.v1.lookup.team(133604)
val today = premium.v2.tv.country("Canada")

One client is safe to share across coroutines and threads; its rate limiter and cache are shared by all calls made through it. Create one per API key and reuse it.

Constructors

Link copied to clipboard
constructor(config: SportsDbConfig = SportsDbConfig())

Properties

Link copied to clipboard
Link copied to clipboard

Common tasks in one call, using v2 or v1 depending on the key.

Link copied to clipboard
val v1: V1Api

The v1 API (free and premium keys).

Link copied to clipboard
val v2: V2Api

The v2 API (premium keys only).

Functions

Link copied to clipboard
suspend fun isPremiumKey(): Boolean

Whether SportsDbConfig.apiKey is a premium key: v2 accepts it. Makes one call (v2 lookup/league/4328) unless the key is the free key.