thesportsdb-client

Config
in package

FinalYes

Client settings. Pass them to SportsDb's constructor as named arguments.

Table of Contents

Constants

FREE_API_KEY  : mixed = '123'
The documented public key for development and testing.
FREE_API_KEYS  : mixed = ['123', '3']
Keys the API accepts without payment: 123 and the older 3 (same limits; measured 5 Oct 2026).

Properties

$apiKey  : string
$baseUrl  : string
$cache  : ResponseCache|null
$cachePolicy  : CachePolicy
$maxRetries  : int
$rateLimitWait  : float
$requestListener  : Closure|null
$requestsPerMinute  : int|null
$retryBackoff  : float
$retryOnRateLimit  : bool
$timeout  : float
$userAgent  : string

Methods

__construct()  : mixed
effectiveRequestsPerMinute()  : int
isFreeKey()  : bool

Constants

FREE_API_KEY

The documented public key for development and testing.

public mixed FREE_API_KEY = '123'

FREE_API_KEYS

Keys the API accepts without payment: 123 and the older 3 (same limits; measured 5 Oct 2026).

public mixed FREE_API_KEYS = ['123', '3']

Properties

$apiKey read-only

public string $apiKey = self::FREE_API_KEY

$baseUrl read-only

public string $baseUrl = 'https://www.thesportsdb.com'

$maxRetries read-only

public int $maxRetries = 2

$rateLimitWait read-only

public float $rateLimitWait = 60.0

$requestListener read-only

public Closure|null $requestListener = null

$requestsPerMinute read-only

public int|null $requestsPerMinute = null

$retryBackoff read-only

public float $retryBackoff = 0.5

$retryOnRateLimit read-only

public bool $retryOnRateLimit = true

$timeout read-only

public float $timeout = 30.0

$userAgent read-only

public string $userAgent = 'thesportsdb-client-php'

Methods

__construct()

public __construct([string $apiKey = self::FREE_API_KEY ][, int|null $requestsPerMinute = null ][, int $maxRetries = 2 ][, float $retryBackoff = 0.5 ][, bool $retryOnRateLimit = true ][, float $rateLimitWait = 60.0 ][, ResponseCache|null $cache = null ][, CachePolicy|null $cachePolicy = null ][, float $timeout = 30.0 ][, callable(RequestEvent): void|null $requestListener = null ][, string $baseUrl = 'https://www.thesportsdb.com' ][, string $userAgent = 'thesportsdb-client-php' ]) : mixed
Parameters
$apiKey : string = self::FREE_API_KEY
$requestsPerMinute : int|null = null

client-side limit; null = 30 for a free key, 100 otherwise; 0 = off

$maxRetries : int = 2

retries for network errors and HTTP 5xx, with exponential backoff

$retryBackoff : float = 0.5

first backoff in seconds; doubles on every retry

$retryOnRateLimit : bool = true

on HTTP 429, wait (Retry-After, or $rateLimitWait) and retry once

$rateLimitWait : float = 60.0
$cache : ResponseCache|null = null
$cachePolicy : CachePolicy|null = null
$timeout : float = 30.0

seconds before a request gives up (connect and read)

$requestListener : callable(RequestEvent): void|null = null

called once per call; exceptions it throws are ignored

$baseUrl : string = 'https://www.thesportsdb.com'
$userAgent : string = 'thesportsdb-client-php'

effectiveRequestsPerMinute()

public effectiveRequestsPerMinute() : int
Return values
int

isFreeKey()

public isFreeKey() : bool
Return values
bool
On this page

Search results