This API Client supports SportMonks v2.0.
composer require hristonev/sportmonks-client-bundle
// Bootstrap
require 'vendor/autoload.php';
use SportMonks\API\HTTPClient as SportMonksAPI;
use SportMonks\API\Utilities\Auth;
// Default values. Can be initialized without arguments.
$scheme = 'https';
$hostname = 'sportmonks.com';
$subDomain = 'soccer';
$port = 443;
// Auth.
$token = 'open sesame';
$client = new SportMonksAPI();
// or
//$client = new SportMonksAPI($scheme, $hostname, $subDomain, $port);
// Set auth.
$client->setAuth(Auth::BASIC, [
'token' => $token
]);
$data = [];
do{
$data = array_merge($data, $client->countries()->findAll());
}while($client->countries()->nextPage());
print_r($data);
$seasonId = 6361;
$teamId = 85;
$client->squad()->getBySeasonAndTeam(
$seasonId,
$teamId,
[
'query' => [
'include' => 'player,position'
]
]
)
Above example, includes player info and player-position info into collection. Check for more query parameters.
endpoints
Basic methods find({id}), findAll(), nextPage(). nextPage() is used on paginated response.
Include results.
Params from and to are DateTime objects, teamId is integer. TeamId is optional.
Param is DateTime object.
Fixtures does not support findAll method.
Include stats.
Get teams by season.
Teams does not support findAll method.
Array must contain 2 elements(team1_id,team2_id).
There is no additional mthods.
Video haighlights does not support find method. Additional method in fixtures is presented.
Venue does not support findAll method.
Players does not support findAll method.
No other methods