PHPackages                             nkl-kst/the-sports-db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. nkl-kst/the-sports-db

ActiveLibrary[API Development](/categories/api)

nkl-kst/the-sports-db
=====================

PHP library to get sports data from TheSportsDB (https://www.thesportsdb.com)

1.5.19(2mo ago)271.2k4[1 issues](https://github.com/nkl-kst/the-sports-db/issues)MITPHPPHP ^7.4 || ^8.0CI passing

Since Dec 30Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/nkl-kst/the-sports-db)[ Packagist](https://packagist.org/packages/nkl-kst/the-sports-db)[ Docs](https://www.github.com/nkl-kst/the-sports-db)[ RSS](/packages/nkl-kst-the-sports-db/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (56)Used By (0)

TheSportsDB PHP library
=======================

[](#thesportsdb-php-library)

[![Build](https://github.com/nkl-kst/the-sports-db/workflows/Build/badge.svg)](https://github.com/nkl-kst/the-sports-db/actions)[![Packagist Version](https://camo.githubusercontent.com/a48e91bce83c0bf3aea7e9e43fa07247fbae8d05aa1b7aa07d4246818bb62712/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6b6c2d6b73742f7468652d73706f7274732d6462)](https://packagist.org/packages/nkl-kst/the-sports-db)[![Coverage Status](https://camo.githubusercontent.com/368afaeb1b1daf71634b898f217f4cfaa91a606d5f33e81b9d44e2a5433d83a2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e6b6c2d6b73742f7468652d73706f7274732d64622f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/nkl-kst/the-sports-db?branch=main)[![PHPStan Level](https://camo.githubusercontent.com/83dd3d35cebed0eab9ee97ff1a5849c1344cda6a8ee9cac2cda20f5aa55b67bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/nkl-kst/the-sports-db/actions)[![GitHub](https://camo.githubusercontent.com/eb6377b3c0b833931ebc2340c3f42e1c6596001f362c6a4e2dec651e1ce4f02e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e6b6c2d6b73742f7468652d73706f7274732d6462)](https://github.com/nkl-kst/the-sports-db/blob/main/LICENSE.md)

An easy-to-use PHP library to get data from .

Features
--------

[](#features)

- Get data for lists, livescores, lookups, schedules, searches or video highlights
- Get results in serialized classes
- Use your own API key
- Throttle long-running scripts
- Use PSR-4 autoloading
- Supports PHP 7.4+

This library uses [Semantic Versioning](https://semver.org).

Installation
------------

[](#installation)

Install this PHP library with [Composer](https://getcomposer.org).

```
> composer require nkl-kst/the-sports-db
```

Usage
-----

[](#usage)

### Get data

[](#get-data)

Get sports data from TheSportsDB.

```
// You need to load the Composer autoload file somewhere in your code before
require_once 'vendor/autoload.php';

use NklKst\TheSportsDb\Client\ClientFactory;

// Create a client
$client = ClientFactory::create();

// Get soccer livescores
$livescores = $client->livescore()->now('Soccer');
echo $livescores[0]->strProgress;

// Get video highlights
$highlights = $client->highlight()->latest();
echo $highlights[0]->strVideo;

// Get next events for Liverpool FC
$events = $client->schedule()->teamNext(133602);
echo $events[0]->strEvent;
```

See [integration tests](https://github.com/nkl-kst/the-sports-db/tree/main/test/integration) for examples of all [documented API calls](https://www.thesportsdb.com/api.php).

### Use your API key

[](#use-your-api-key)

Use your own Patreon API key.

```
use NklKst\TheSportsDb\Client\ClientFactory;

// Set an API key
$client = ClientFactory::create();
$client->configure()->setKey('YOUR_API_KEY');
```

### Throttle requests

[](#throttle-requests)

You are advised to do no more than 100 requests per minute to TheSportsDB API (the hard limit is two requests per second). If you have long-running scripts to gather many data, please consider to use the built-in rate limiter.

```
use NklKst\TheSportsDb\Client\ClientFactory;

// Use the default rate limit of 100 requests per minute
$client = ClientFactory::create();
$client->configure()->setRateLimiter();

// Do your requests as usual

// You can unset the rate limiter later
$client->configure()->unsetRateLimiter();
```

As this library uses the [Symfony Rate Limiter Component](https://github.com/symfony/rate-limiter), it's possible to use a custom rate limit mechanism. Please consult the Symfony [documentation](https://symfony.com/doc/current/rate_limiter.html) for more information.

Known issues
------------

[](#known-issues)

- Livescores for v1 are not supported.
- If you are getting an exception like `JSON property "foo" in class "Bar" must not be NULL`, then there is an entity attribute which should be nullable. Please open a new issue in this case.

Feedback
--------

[](#feedback)

If you have any problems or questions, feel free to open an issue or a pull request.

Developer notes
---------------

[](#developer-notes)

Run tests and code checks.

```
# Unit tests
> composer test-unit

# Integration tests (API calls, Patreon key required)
> PATREON_KEY= composer test-integration
# On Windows use 'set PATREON_KEY=' before running the tests

# Analyze code (static analysis)
> composer analyze-code

# Check code (coding standards)
> composer check-code
```

License: MIT
------------

[](#license-mit)

See [LICENSE](LICENSE.md).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance86

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 99.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~13 days

Total

55

Last Release

68d ago

Major Versions

0.1.2 → 1.0.02021-05-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e3a292d8e5416d2a2be1294755c21a5e6db5a20cdf7474b6d2a02893b16e207?d=identicon)[nkl-kst](/maintainers/nkl-kst)

---

Top Contributors

[![nkl-kst](https://avatars.githubusercontent.com/u/24235974?v=4)](https://github.com/nkl-kst "nkl-kst (326 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![shutupflanders](https://avatars.githubusercontent.com/u/3372012?v=4)](https://github.com/shutupflanders "shutupflanders (1 commits)")[![simoheinonen](https://avatars.githubusercontent.com/u/3840367?v=4)](https://github.com/simoheinonen "simoheinonen (1 commits)")

---

Tags

libraryphpthesportsdbphplibraryTheSportsDB

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nkl-kst-the-sports-db/health.svg)

```
[![Health](https://phpackages.com/badges/nkl-kst-the-sports-db/health.svg)](https://phpackages.com/packages/nkl-kst-the-sports-db)
```

###  Alternatives

[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[getjump/vk

Library for work with API Vk.com

20048.5k](/packages/getjump-vk)[telegram-bot-php/core

A PHP library that makes using Telegram Bot API much easier.

60293.1k](/packages/telegram-bot-php-core)[maxbeckers/amazon-alexa-php

Php library for amazon echo (alexa) skill development.

11554.0k2](/packages/maxbeckers-amazon-alexa-php)[fabian-beiner/todoist-php-api-library

A PHP client library that provides a native interface to the official Todoist REST API.

4810.8k](/packages/fabian-beiner-todoist-php-api-library)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
