This package is a wrapper for Sportmonks Soccer API for Laravel 7/8/9.
This is a fork of kirill-latish/laravel-sportmonks-soccer with added support for Larvel 7+.
Install the package via Composer:
composer require kfoobar/laravel-sportmonks-soccer
Add your API token to your .env
file:
SPORTMONKS_API_TOKEN=
For more settings, you can publish the config file:
$ php artisan vendor:publish --provider="Sportmonks\SoccerAPI\SoccerAPIServiceProvider"
Example when using the facade:
use SoccerAPI;
...
$response = SoccerAPI::leagues()->all();
$response = SoccerAPI::fixtures()->byId($id);
If you need to include other relations (check the official documentation for which relations can be included):
$response = SoccerAPI::seasons()->setInclude(['league', 'fixtures'])->all();
The default behaviour is to return an object containing a data
array:
$response = SoccerAPI::fixtures()->byId($id);
var_dump($response->data);
{
"data": [
{
"id": null,
"league_id": null,
"scores": {
"localteam_score": 0,
"visitorteam_score": 0
}
}
]
}
If you want to directly retrieve the properties inside data
, set skip_data
to true
in your config file.
$response = SoccerAPI::fixtures()->byId($id);
var_dump($response);
{
"id": null,
"league_id": null,
"scores": {
"localteam_score": 0,
"visitorteam_score": 0
}
}
Please refer to the official documentation as to which API calls can be made.
Thank you for considering contributing!