PHP Library for Sportmonks Soccer API. Developed by Joe Saunderson.
PHP >= 7.3
composer require joesaunderson/sportmonks-soccer
The API Client relies on Environment variables for configuration (setting API token & timezone).
Install:
composer require symfony/dotenv
Usage:
use Symfony\Component\Dotenv\Dotenv;
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');
An example .env file:
# API TOKEN (Required)
# https://sportmonks.com/settings#/api
SPORTMONKS_API_TOKEN=_YOUR_API_TOKEN_HERE
# TIMEZONE (Optional)
# https://sportmonks.com/docs/football/2.0/getting-started/a/setting-the-timezone/82
SPORTMONKS_TIMEZONE=Europe/London
use Sportmonks\Soccer\SoccerApi;
...
// Basic API call for all Bookmakers
$response = SoccerApi::bookmakers()->getAll();
The Sportmonks API allows for advanced filtering and sorting, as well as adding data via relationships. This client supports the following:
// API call for Fixtures with includes
$response = SoccerApi::fixtures()
->setIncludes(['goals', 'flatOdds:filter(bookmaker_id|2)'])
->getByDate('2019-05-28');
// API call for Fixtures with page specified
$response = SoccerApi::fixtures()
->setPage(3)
->getByDate('2019-05-28');
Note: The pagination meta ($response['meta']['pagination']
) can be used to loop through pages and build a result set.
Certain endpoints allow for data to be passed as URI query parameters, these are shown below & must be added before the ->get..() call.
->setBookmakers([1, 2])
->setFixtures([1, 2])
->setLeagues([1, 2])
->setMarkets([1, 2])
Note: This client will not validate the usage for the correct endpoints and will not throw an error. Refer to the Sportmonks docs to see which endpoints support the above parameters.
Get All - View Sportmonks Docs
$response = SoccerApi::bookmakers()->getAll();
Get By Id - View Sportmonks Docs
$response = SoccerApi::bookmakers()->getById($bookmakerId);
Get By Id - View Sportmonks Docs
$response = SoccerApi::coaches()->getById($coachId);
Get By Fixture Id - View Sportmonks Docs
$response = SoccerApi::commentaries()->getByFixtureId($fixtureId);
Get All - View Sportmonks Docs
$response = SoccerApi::continents()->getAll();
Get By Id - View Sportmonks Docs
$response = SoccerApi::continents()->getById($continentId);
Get All - View Sportmonks Docs
$response = SoccerApi::countries()->getAll();
Get By Id - View Sportmonks Docs
$response = SoccerApi::countries()->getById($countryId);
Get By Id - View Sportmonks Docs
$response = SoccerApi::fixtures()->getById($fixtureId);
Get By Date - View Sportmonks Docs
$response = SoccerApi::fixtures()->getByDate($date);
Get By Date Range - View Sportmonks Docs
$response = SoccerApi::fixtures()->getByDateRange($dateFrom, $dateTo);
Get By Date Range For Team - View Sportmonks Docs
$response = SoccerApi::fixtures()->getByDateRangeForTeam($dateFrom, $dateTo, $teamId);
Get By Multiple Ids - View Sportmonks Docs
$response = SoccerApi::fixtures()->getByMultipleIds([$fixtureId1, $fixtureId2...]);
Get Last Updated - View Sportmonks Docs
$response = SoccerApi::fixtures()->getLastUpdated();
Get By Team Ids - View Sportmonks Docs
$response = SoccerApi::head2head()->getByTeamIds($team1Id, $team2Id);
Get All - View Sportmonks Docs
$response = SoccerApi::leagues()->getAll();
Get By Id - View Sportmonks Docs
$response = SoccerApi::leagues()->getById($legueId);
Get All - View Sportmonks Docs
$response = SoccerApi::liveScores()->getAll();
Get All Inplay - View Sportmonks Docs
$response = SoccerApi::liveScores()->getAllInPlay();
Get All - View Sportmonks Docs
$response = SoccerApi::markets()->getAll();
Get By Id - View Sportmonks Docs
$response = SoccerApi::markets()->getById($marketId);
Get By Fixture & Bookmaker - View Sportmonks Docs
$response = SoccerApi::odds()->getByFixtureAndBookmaker($fixtureId, $bookmakerId);
Get By Fixture & Market - View Sportmonks Docs
$response = SoccerApi::odds()->getByFixtureAndMarket($fixtureId, $marketId);
Get By Fixture Id - View Sportmonks Docs
$response = SoccerApi::odds()->getByFixtureId($fixtureId);
Get Inplay Odds By Fixture Id - View Sportmonks Docs
$response = SoccerApi::odds()->getInPlayByFixtureId($fixtureId);
Get By Id - View Sportmonks Docs
$response = SoccerApi::players()->getById($playerId);
Get Leagues View Sportmonks Docs
$response = SoccerApi::predictions()->getLeagues()
Get Probabilities View Sportmonks Docs
$response = SoccerApi::predictions()->getProbabilities()
Get Probabilities By Fixture Id View Sportmonks Docs
$response = SoccerApi::predictions()->getProbabilitiesByFixtureId($fixtureId)
Get Value Bets View Sportmonks Docs
$response = SoccerApi::predictions()->getValueBets()
Get Value Bets By Fixture Id View Sportmonks Docs
$response = SoccerApi::predictions()->getValueBetsByFixtureId($fixtureId)
Get By Id - View Sportmonks Docs
$response = SoccerApi::rounds()->getById($roundId);
Get By Season Id - View Sportmonks Docs
$response = SoccerApi::rounds()->getBySeasonId($seasonId);
Get All - View Sportmonks Docs
$response = SoccerApi::seasons()->getAll();
Get By Id - View Sportmonks Docs
$response = SoccerApi::seasons()->getById($seasonId);
Get By Id - View Sportmonks Docs
$response = SoccerApi::stages()->getById($stageId);
Get By Season Id - View Sportmonks Docs
$response = SoccerApi::stages()->getBySeasonId($seasonId);
Get By Season Id - View Sportmonks Docs
$response = SoccerApi::standings()->getBySeasonId($seasonId);
Get Live Standings - View Sportmonks Docs
$response = SoccerApi::standings()->getLiveStandingsBySeasonId($seasonId);
Get By Id - View Sportmonks Docs
$response = SoccerApi::teams()->getById($teamId);
Get By Season - View Sportmonks Docs
$response = SoccerApi::teams()->getBySeasonId($seasonId);
Get By Team & Season - View Sportmonks Docs
$response = SoccerApi::teamSquads()->getByTeamAndSeason($teamId, $seasonId);
Get By Season Id - View Sportmonks Docs
$response = SoccerApi::topScorers()->getBySeasonId($seasonId);
Aggregated By Season Id - View Sportmonks Docs
$response = SoccerApi::topScorers()->getAggregatedBySeasonId($seasonId);
Get By Fixture Id - View Sportmonks Docs
$response = SoccerApi::tvStations()->getByFixtureId($fixtureId);
Get By Id - View Sportmonks Docs
$response = SoccerApi::venues()->getById($venueId);
Get By Season Id - View Sportmonks Docs
$response = SoccerApi::venues()->getBySeasonId($seasonId);
Get By Fixture Id - View Sportmonks Docs
$response = SoccerApi::videoHighlights()->getAll();