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.
Get all - View Sportmonks Docs
$response = FootballApi::livescores()->all();
Get all inplay - View Sportmonks Docs
$response = FootballApi::livescores()->inplay();
Get latest - View Sportmonks Docs
$response = FootballApi::livescores()->latest();
Get all - View Sportmonks Docs
$response = FootballApi::fixtures()->all();
Get by Id - View Sportmonks Docs
$response = FootballApi::fixtures()->getById($fixtureId);
Get by multiple ids - View Sportmonks Docs
$response = FootballApi::fixtures()->getByMultipleIds([$fixtureId1,$fixtureIds2,...]);
Get by date - View Sportmonks Docs
$response = FootballApi::fixtures()->getByDate($date);
Get by date range - View Sportmonks Docs
$response = FootballApi::fixtures()->getByDateRange($dateFrom, $dateTo);
Get by date range for team - View Sportmonks Docs
$response = FootballApi::fixtures()->getByDateRangeForTeam($dateFrom, $dateTo, $teamId);
Get by head to head - View Sportmonks Docs
$response = FootballApi::fixtures()->getHeadToHead($teamId1, $teamId2);
Get upcoming by market id - View Sportmonks Docs
$response = FootballApi::fixtures()->getUpcommingByMarketId($marketId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::fixtures()->search($searchQuery);
Get last updated - View Sportmonks Docs
$response = FootballApi::fixtures()->getLastUpdated();
Get all states - View Sportmonks Docs
$response = FootballApi::states()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::states()->getById();
Get all - View Sportmonks Docs
$response = FootballApi::leagues()->all();
Get by Id - View Sportmonks Docs
$response = FootballApi::leagues()->getById($leagueId);
Get by live - View Sportmonks Docs
$response = FootballApi::leagues()->live();
Get by fixture date - View Sportmonks Docs
$response = FootballApi::leagues()->getByFixtureDate($date);
Get by country id- View Sportmonks Docs
$response = FootballApi::leagues()->getByCountryId($countryId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::leagues()->search($searchQuery);
Get all by team id - View Sportmonks Docs
$response = FootballApi::leagues()->getAllByTeamId($teamId);
Get current by team id - View Sportmonks Docs
$response = FootballApi::leagues()->getCurrentByTeamId($teamId);
Get all - View Sportmonks Docs
$response = FootballApi::season()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::season()->getById($seasonId);
Get by team id - View Sportmonks Docs
$response = FootballApi::season()->getByTeamId($teamId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::season()->search($searchQuery);
Get by season id - View Sportmonks Docs
$response = FootballApi::schedules()->bySeasonId($seasonId);
Get by season id - View Sportmonks Docs
$response = FootballApi::schedules()->byTeamId($teamId);
Get by season id and team id - View Sportmonks Docs
$response = FootballApi::schedules()->bySeasonAndTeamId($seasonId, $teamId);
Get all - View Sportmonks Docs
$response = FootballApi::stages()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::stages()->getById($stageId);
Get by season id - View Sportmonks Docs
$response = FootballApi::stages()->getBySeasonId($seasonId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::stages()->search($searchQuery);
Get all - View Sportmonks Docs
$response = FootballApi::rounds()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::rounds()->getById($roundId);
Get by season id - View Sportmonks Docs
$response = FootballApi::rounds()->getBySeasonId($seasonId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::rounds()->search($searchQuery);
Get all - View Sportmonks Docs
$response = FootballApi::standings()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::standings()->getBySeasonId($seasonId);
Get by round id - View Sportmonks Docs
$response = FootballApi::standings()->getByRoundId($roundId);
Get corrections by season id - View Sportmonks Docs
$response = FootballApi::standings()->getCorrectionsBySeasonId($seasonId);
Get live standings by league id - View Sportmonks Docs
$response = FootballApi::standings()->getLiveByLeagueId($leagueId);
Get all by season id - View Sportmonks Docs
$response = FootballApi::topscorers()->getBySeasonId($seasonId);
Get all by stage id - View Sportmonks Docs
$response = FootballApi::topscorers()->getByStageId($stageId);
Get all - View Sportmonks Docs
$response = FootballApi::teams()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::teams()->getById($teamId);
Get by country id - View Sportmonks Docs
$response = FootballApi::teams()->getByCountryId($countryId);
Get by season id - View Sportmonks Docs
$response = FootballApi::teams()->getBySeasonId($seasonId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::teams()->search($searchQuery);
Get by team id - View Sportmonks Docs
$response = FootballApi::teamSquads()->getByTeamId($teamId);
Get by team id and season id - View Sportmonks Docs
$response = FootballApi::teamSquads()->getByTeamAndSeasonId($teamId,$seasonId);
Get all - View Sportmonks Docs
$response = FootballApi::players()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::players()->getById($playerId);
Get by country id - View Sportmonks Docs
$response = FootballApi::players()->getByCountryId($countryId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::players()->search($searchQuery);
Get last updated - View Sportmonks Docs
$response = FootballApi::players()->getLastUpdated();
Get all - View Sportmonks Docs
$response = FootballApi::coaches()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::coaches()->getById($coachId);
Get by country id - View Sportmonks Docs
$response = FootballApi::coaches()->getByCountryId($countryId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::coaches()->search($searchQuery);
Get last updated - View Sportmonks Docs
$response = FootballApi::coaches()->getLastUpdated();
Get all - View Sportmonks Docs
$response = FootballApi::referees()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::referees()->getById($refereeId);
Get by country id - View Sportmonks Docs
$response = FootballApi::referees()->getByCountryId($countryId);
Get by season id - View Sportmonks Docs
$response = FootballApi::referees()->getBySeasonId($countryId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::referees()->search($searchQuery);
Get all - View Sportmonks Docs
$response = FootballApi::transfers()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::transfers()->getById($transferId);
Get latest - View Sportmonks Docs
$response = FootballApi::transfers()->latest();
Get between date range - View Sportmonks Docs
$response = FootballApi::transfers()->getByDateRange($dateFrom,$dateTo);
Get by team id - View Sportmonks Docs
$response = FootballApi::transfers()->getByTeamId($teamId);
Get by player id - View Sportmonks Docs
$response = FootballApi::transfers()->getByPlayerId($playerId);
Get all - View Sportmonks Docs
$response = FootballApi::venues()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::venues()->getById($venueId);
Get by season id - View Sportmonks Docs
$response = FootballApi::venues()->getBySeasonId($seasonId);
Get by search by name - View Sportmonks Docs
$response = FootballApi::venues()->search($searchQuery);
Get all - View Sportmonks Docs
$response = FootballApi::tvStations()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::tvStations()->getById($stationId);
Get by fixture id - View Sportmonks Docs
$response = FootballApi::tvStations()->getByFixtureId($fixtureId);
Get predictability - View Sportmonks Docs
$response = FootballApi::predictions()->probabilities();
Get predictability by league id - View Sportmonks Docs
$response = FootballApi::predictions()->getPredictabilityByLeagueId($leagueId);
Get predictability by fixture id - View Sportmonks Docs
$response = FootballApi::tvStations()->getPredictabilityByFixtureId($fixtureId);
Get value bets - View Sportmonks Docs
$response = FootballApi::tvStations()->valueBets();
Get all - View Sportmonks Docs
$response = FootballApi::preMatchOdds()->all();
Get by fixture id - View Sportmonks Docs
$response = FootballApi::preMatchOdds()->getByFixtureId($fixtureId);
Get by fixture id and bookmaker id - View Sportmonks Docs
$response = FootballApi::preMatchOdds()->getByFixtureAndBookmakerId($fixtureId,$bookmakerId);
Get by fixture id and market id - View Sportmonks Docs
$response = FootballApi::preMatchOdds()->getByFixtureAndMarketId($fixtureId,$marketId);
Get last updated - View Sportmonks Docs
$response = FootballApi::preMatchOdds()->getLastUpdated();
Get all - View Sportmonks Docs
$response = FootballApi::inplayOdds()->all();
Get by fixture id - View Sportmonks Docs
$response = FootballApi::inplayOdds()->getByFixtureId($fixtureId);
Get by fixture id and bookmaker id - View Sportmonks Docs
$response = FootballApi::inplayOdds()->getByFixtureAndBookmakerId($fixtureId,$bookmakerId);
Get by fixture id and market id - View Sportmonks Docs
$response = FootballApi::inplayOdds()->getByFixtureAndMarketId($fixtureId,$marketId);
Get last updated - View Sportmonks Docs
$response = FootballApi::inplayOdds()->getLastUpdated();
Get all - View Sportmonks Docs
$response = FootballApi::markets()->all();
Get by market id - View Sportmonks Docs
$response = FootballApi::markets()->getById($marketId);
Get by search - View Sportmonks Docs
$response = FootballApi::markets()->search($searchQuery);
Get all - View Sportmonks Docs
$response = FootballApi::bookmakers()->all();
Get by bookmaker id - View Sportmonks Docs
$response = FootballApi::bookmakers()->getById($bookmakerId);
Get by search - View Sportmonks Docs
$response = FootballApi::bookmakers()->search($searchQuery);
Get by market id - View Sportmonks Docs
$response = FootballApi::bookmakers()->getByFixtureId($fixtureId);
Get pre-match news - View Sportmonks Docs
$response = FootballApi::preMatchNews()->all();
Get by season id - View Sportmonks Docs
$response = FootballApi::preMatchNews()->getBySeasonId($seasonId);
Get pre-match news for upcoming fixtures - View Sportmonks Docs
$response = FootballApi::preMatchNews()->upcomingFixtures();
Get all rivales - View Sportmonks Docs
$response = FootballApi::rivals()->all();
Get by team id - View Sportmonks Docs
$response = FootballApi::rivals()->getByTeamId($teamId);
Get all commentaries - View Sportmonks Docs
$response = FootballApi::commentaries()->all();
Get by team id - View Sportmonks Docs
$response = FootballApi::commentaries()->getByFixtureId($fixtureId);
Core contains all endpoints that are used in all sports.
Get all continents - View Sportmonks Docs
$response = FootballApi::continents()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::continents()->getById();
Get all countries - View Sportmonks Docs
$response = FootballApi::countries()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::countries()->getById();
Get by search - View Sportmonks Docs
$response = FootballApi::countries()->search($searchQuery);
Get all regions - View Sportmonks Docs
$response = FootballApi::regions()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::regions()->getById();
Get by search - View Sportmonks Docs
$response = FootballApi::regions()->search($searchQuery);
Get all cities - View Sportmonks Docs
$response = FootballApi::cities()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::cities()->getById();
Get by search - View Sportmonks Docs
$response = FootballApi::cities()->search($searchQuery);
Get all types - View Sportmonks Docs
$response = FootballApi::types()->all();
Get by id - View Sportmonks Docs
$response = FootballApi::types()->getById();
Get by Entity - View Sportmonks Docs
$response = FootballApi::types()->getByEntity();
Get all entity - View Sportmonks Docs
$response = FootballApi::filters()->entity();
Retrieve information about your subscription.
Get my enrichments - View Sportmonks Docs
$response = FootballApi::my()->enrichments();
Get my resources - View Sportmonks Docs
$response = FootballApi::my()->resources();
Get my leagues - View Sportmonks Docs
$response = FootballApi::my()->leagues();