PHP Library for Sportmonks Soccer API v3. Developed by Carsten Tetzlaff. This Library is heavily inspired by https://github.com/joesaunderson/sportmonks-soccer.
PHP >= 7.3
composer require tetzilla/sportmonks-football-api
The API Client relies on Environment variables for configuration (setting API token & timezone).
PHP >= 7.3
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://docs.sportmonks.com/football/welcome/authentication
SPORTMONKS_API_TOKEN=_YOUR_API_TOKEN_HERE
# TIMEZONE (Optional)
# https://docs.sportmonks.com/football/tutorials-and-guides/tutorials/introduction/set-your-time-zone
SPORTMONKS_TIMEZONE=Europe/London
use Sportmonks\Football\FootballApi;
...
// Basic API call for all Bookmakers
$response = FootballApi::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 page specified
$response = FootballApi::fixtures()
->setPage(3)
->getByDate('2023-03-19');
Note: The pagination ($response['pagination']
) can be used to loop through pages and build a result set.
// API call for Fixtures with includes
$response = FootballApi::fixtures()
->setInclude(['scores', 'lineups', 'events'])
->getByDate('2023-03-19');
// API call for Fixtures with filters
$response = FootballApi::fixtures()
->setInclude(['events','statistics.type'])
->setFilters(['eventTypes' => [18,14]])
->getByDate('2023-03-19');
// API call for Fixtures with deleted filter
$response = FootballApi::fixtures()
->setFilters(['deleted'])
->all();
// API call for Fixtures with populate (1000 per page)
$response = FootballApi::fixtures()
->setFilters(['populate'])
->all();
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.
$response = FootballApi::livescores()->all();
$response = FootballApi::livescores()->inplay();
$response = FootballApi::livescores()->latest();
$response = FootballApi::fixtures()->all();
$response = FootballApi::fixtures()->getById($fixtureId);
$response = FootballApi::fixtures()->getByMultipleIds([$fixtureId1,$fixtureIds2,...]);
$response = FootballApi::fixtures()->getByDate($date);
$response = FootballApi::fixtures()->getByDateRange($dateFrom, $dateTo);
$response = FootballApi::fixtures()->getByDateRangeForTeam($dateFrom, $dateTo, $teamId);
$response = FootballApi::fixtures()->getHeadToHead($teamId1, $teamId2);
$response = FootballApi::fixtures()->getUpcommingByMarketId($marketId);
$response = FootballApi::fixtures()->search($searchQuery);
$response = FootballApi::fixtures()->getLastUpdated();
$response = FootballApi::states()->all();
$response = FootballApi::states()->getById();
$response = FootballApi::leagues()->all();
$response = FootballApi::leagues()->getById($leagueId);
$response = FootballApi::leagues()->live();
$response = FootballApi::leagues()->getByFixtureDate($date);
$response = FootballApi::leagues()->getByCountryId($countryId);
$response = FootballApi::leagues()->search($searchQuery);
$response = FootballApi::leagues()->getAllByTeamId($teamId);
$response = FootballApi::leagues()->getCurrentByTeamId($teamId);
$response = FootballApi::season()->all();
$response = FootballApi::season()->getById($seasonId);
$response = FootballApi::season()->getByTeamId($teamId);
$response = FootballApi::season()->search($searchQuery);
$response = FootballApi::schedules()->bySeasonId($seasonId);
$response = FootballApi::schedules()->byTeamId($teamId);
$response = FootballApi::schedules()->bySeasonAndTeamId($seasonId, $teamId);
$response = FootballApi::stages()->all();
$response = FootballApi::stages()->getById($stageId);
$response = FootballApi::stages()->getBySeasonId($seasonId);
$response = FootballApi::stages()->search($searchQuery);
$response = FootballApi::rounds()->all();
$response = FootballApi::rounds()->getById($roundId);
$response = FootballApi::rounds()->getBySeasonId($seasonId);
$response = FootballApi::rounds()->search($searchQuery);
$response = FootballApi::standings()->all();
$response = FootballApi::standings()->getBySeasonId($seasonId);
$response = FootballApi::standings()->getByRoundId($roundId);
$response = FootballApi::standings()->getCorrectionsBySeasonId($seasonId);
$response = FootballApi::standings()->getLiveByLeagueId($leagueId);
$response = FootballApi::topscorers()->getBySeasonId($seasonId);
$response = FootballApi::topscorers()->getByStageId($stageId);
$response = FootballApi::teams()->all();
$response = FootballApi::teams()->getById($teamId);
$response = FootballApi::teams()->getByCountryId($countryId);
$response = FootballApi::teams()->getBySeasonId($seasonId);
$response = FootballApi::teams()->search($searchQuery);
$response = FootballApi::teamSquads()->getByTeamId($teamId);
$response = FootballApi::teamSquads()->getByTeamAndSeasonId($teamId,$seasonId);
$response = FootballApi::players()->all();
$response = FootballApi::players()->getById($playerId);
$response = FootballApi::players()->getByCountryId($countryId);
$response = FootballApi::players()->search($searchQuery);
$response = FootballApi::players()->getLastUpdated();
$response = FootballApi::coaches()->all();
$response = FootballApi::coaches()->getById($coachId);
$response = FootballApi::coaches()->getByCountryId($countryId);
$response = FootballApi::coaches()->search($searchQuery);
$response = FootballApi::coaches()->getLastUpdated();
$response = FootballApi::referees()->all();
$response = FootballApi::referees()->getById($refereeId);
$response = FootballApi::referees()->getByCountryId($countryId);
$response = FootballApi::referees()->getBySeasonId($countryId);
$response = FootballApi::referees()->search($searchQuery);
$response = FootballApi::transfers()->all();
$response = FootballApi::transfers()->getById($transferId);
$response = FootballApi::transfers()->latest();
$response = FootballApi::transfers()->getByDateRange($dateFrom,$dateTo);
$response = FootballApi::transfers()->getByTeamId($teamId);
$response = FootballApi::transfers()->getByPlayerId($playerId);
$response = FootballApi::venues()->all();
$response = FootballApi::venues()->getById($venueId);
$response = FootballApi::venues()->getBySeasonId($seasonId);
$response = FootballApi::venues()->search($searchQuery);
$response = FootballApi::tvStations()->all();
$response = FootballApi::tvStations()->getById($stationId);
$response = FootballApi::tvStations()->getByFixtureId($fixtureId);
$response = FootballApi::predictions()->probabilities();
$response = FootballApi::predictions()->getPredictabilityByLeagueId($leagueId);
$response = FootballApi::tvStations()->getPredictabilityByFixtureId($fixtureId);
$response = FootballApi::tvStations()->valueBets();
$response = FootballApi::preMatchOdds()->all();
$response = FootballApi::preMatchOdds()->getByFixtureId($fixtureId);
$response = FootballApi::preMatchOdds()->getByFixtureAndBookmakerId($fixtureId,$bookmakerId);
$response = FootballApi::preMatchOdds()->getByFixtureAndMarketId($fixtureId,$marketId);
$response = FootballApi::preMatchOdds()->getLastUpdated();
$response = FootballApi::inplayOdds()->all();
$response = FootballApi::inplayOdds()->getByFixtureId($fixtureId);
$response = FootballApi::inplayOdds()->getByFixtureAndBookmakerId($fixtureId,$bookmakerId);
$response = FootballApi::inplayOdds()->getByFixtureAndMarketId($fixtureId,$marketId);
$response = FootballApi::inplayOdds()->getLastUpdated();
$response = FootballApi::markets()->all();
$response = FootballApi::markets()->getById($marketId);
$response = FootballApi::markets()->search($searchQuery);
$response = FootballApi::bookmakers()->all();
$response = FootballApi::bookmakers()->getById($bookmakerId);
$response = FootballApi::bookmakers()->search($searchQuery);
$response = FootballApi::bookmakers()->getByFixtureId($fixtureId);
$response = FootballApi::preMatchNews()->all();
$response = FootballApi::preMatchNews()->getBySeasonId($seasonId);
$response = FootballApi::preMatchNews()->upcomingFixtures();
$response = FootballApi::rivals()->all();
$response = FootballApi::rivals()->getByTeamId($teamId);
$response = FootballApi::commentaries()->all();
$response = FootballApi::commentaries()->getByFixtureId($fixtureId);
Core contains all endpoints that are used in all sports.
$response = FootballApi::continents()->all();
$response = FootballApi::continents()->getById();
$response = FootballApi::countries()->all();
$response = FootballApi::countries()->getById();
$response = FootballApi::countries()->search($searchQuery);
$response = FootballApi::regions()->all();
$response = FootballApi::regions()->getById();
$response = FootballApi::regions()->search($searchQuery);
$response = FootballApi::cities()->all();
$response = FootballApi::cities()->getById();
$response = FootballApi::cities()->search($searchQuery);
$response = FootballApi::types()->all();
$response = FootballApi::types()->getById();
$response = FootballApi::types()->getByEntity();
$response = FootballApi::filters()->entity();
Retrieve information about your subscription.
$response = FootballApi::my()->enrichments();
$response = FootballApi::my()->resources();
$response = FootballApi::my()->leagues();