PHP library to get sports data from TheSportsDB (https://www.thesportsdb.com)
An easy-to-use PHP library to get data from https://www.thesportsdb.com.
- Get data for lists, livescores, lookups, schedules, searches or video highlights
- Get results in serialized classes
- Use your own API key
- Use PSR-4 autoloading
- Supports PHP 7.4+
This library uses Semantic Versioning.
Install this PHP library with Composer.
> composer require nkl-kst/the-sports-db
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->strProgress; // Get video highlights $highlights = $client->highlight()->latest(); echo $highlights->strVideo; // Get next events for Liverpool FC $events = $client->schedule()->teamNext(133602); echo $events->strEvent;
Use your own Patreon API key.
use NklKst\TheSportsDb\Client\ClientFactory; // Set an API key $client = ClientFactory::create(); $client->configure()->setKey('YOUR_API_KEY');
- 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.
If you have any problems or questions, feel free to open an issue or a pull request.
Run tests and code checks.
# Unit tests > composer run-script test-unit # Integration tests (API calls, Patreon key required) > PATREON_KEY=<YOUR_PATREON_KEY> composer run-script test-integration # On Windows use 'set PATREON_KEY=<YOUR_PATERON_KEY>' before running the tests # Analyze code (static analysis) > composer run-script analyze-code # Check code (coding standards) > composer run-script check-code