fpicosm / sportmonks-football-api
A Laravel/Lumen wrapper for Sportmonks Football Api
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- laravel/laravel: ^11.0
- phpunit/phpunit: ^11.1
README
Installation
Require the package via composer:
composer require fpicosm/sportmonks-football-api
Configuration
Update your .env
file adding:
SPORTMONKS_TOKEN=#YOUR_API_TOKEN#
SPORTMONKS_TIMEZONE=#YOUR_TIMEZONE#
SPORTMONKS_TIMEZONE
is optional. If not included, it is used the APP_TIMEZONE
value.
Using Laravel
-
Register the ServiceProvider in
config/app.php
, inside theproviders
section:Sportmonks\FootballApi\FootballApiServiceProvider::class,
-
Publish the config file
php artisan vendor:publish --provider="Sportmonks\FootballApi\FootballApiServiceProvider"
Using Lumen
-
Create the folder
config
at the root of the project (if not exists). -
Create the file
config/football-api.php
and paste:<?php if (!function_exists('config_path')) { function config_path($path = '') { return app()->basePath() . '/config' . ($path ? "/$path" : $path); } } return [ 'token' => env('SPORTMONKS_TOKEN'), 'timezone' => env('SPORTMONKS_TIMEZONE') ?: env('APP_TIMEZONE'), ];
-
Add the config file in
bootstrap/app.php
, inside theRegister Config Files
section:$app->configure('football-api');
-
Add the ServiceProvider in
bootstrap/app.php
, inside theRegister Service Providers
section:$app->register(Sportmonks\FootballApi\FootballApiServiceProvider::class);
-
Uncomment the line
$app->withFacades();
inbootstrap/app.php
Usage
Where needed, add the dependency:
use Sportmonks\FootballApi\FootballApi;
Then, you can call to:
FootballApi::endpoint()->method($params):
Select option
To select only specific fields, you can pass an array, or a comma separated string. Examples:
FootballApi::countries()->select('name,official_name')->all(); FootballApi::countries()->select(['name', 'official_name'])->all();
Include option
To include relations, you can pass an array, or a semicolon separated string. Examples:
FootballApi::countries()->include('leagues;continent')->all(); FootballApi::countries()->include(['leagues', 'continent'])->all();
You can combine both include and select options. Example:
FootballApi::continents()->include('countries:name,official_name')->select('name')->all();
Pagination
To set the page number, use the page
method:
FootballApi::countries()->page(2)->all();
To set the page size, use the perPage
method:
FootballApi::countries()->perPage(150)->all();
The page size must be between 10
and 150
(default value is 100
).
Endpoints
Bookmakers
Get all bookmakers
FootballApi::bookmakers()->all();
Get all premium bookmakers
FootballApi::bookmakers()->premium();
Get bookmaker by id
FootballApi::bookmakers()->find($bookmakerId);
Search bookmakers by name
FootballApi::bookmakers()->search($name);
Get bookmakers by fixture id
FootballApi::bookmakers()->byFixture($fixtureId);
Get pre-match odds by fixture id and bookmaker id
FootballApi::bookmakers($bookmakerId)->preMatchOddsByFixture($fixtureId);
Get inplay odds by fixture id and bookmaker id
FootballApi::bookmakers($bookmakerId)->inplayOddsByFixture($fixtureId);
Get premium odds by fixture id and bookmaker id
FootballApi::bookmakers($marketId)->premiumOddsByFixture($fixtureId);
Cities
Get all cities
FootballApi::cities()->all();
Get city by id
FootballApi::cities()->find($cityId);
Search cities by name
FootballApi::cities()->search($name);
Coaches
Get all coaches
FootballApi::coaches()->all();
Get coach by id
FootballApi::coaches()->find($coachId);
Get coaches by country id
FootballApi::coaches()->byCountry($countryId);
Search coaches by name
FootballApi::coaches()->search($name);
Get last updated coaches
FootballApi::coaches()->lastUpdated();
Get coach statistics by season id
FootballApi::coaches()->statisticsBySeason($seasonId);
Commentaries
Get all commentaries
FootballApi::commentaries()->all();
Get commentaries by fixture id
FootballApi::commentaries()->byFixture($fixtureId);
Continents
Get all continents
FootballApi::continents()->all();
Get continent by id
FootballApi::continents()->find($continentId);
Countries
Get all countries
FootballApi::countries()->all();
Get country by id
FootballApi::countries()->find($countryId);
Search countries by name
FootballApi::countries()->search($name);
Get leagues by country id
FootballApi::countries($countryId)->leagues();
Get players by country id
FootballApi::countries($countryId)->players();
Get teams by country id
FootballApi::countries($countryId)->teams();
Get coaches by country id
FootballApi::countries($countryId)->coaches();
Get referees by country id
FootballApi::countries($countryId)->referees();
Enrichments
Get all enrichments
FootballApi::enrichments()->all();
Expected
Get expected by team
FootballApi::expected()->byTeam();
Get expected by player
FootballApi::expected()->byPlayer();
Filters
Get all filters
FootballApi::filters()->all();
Fixtures
Get all fixtures
FootballApi::fixtures()->all();
Get fixture by id
FootballApi::fixtures()->find($fixtureId);
Get fixtures by multiple ids
FootballApi::fixtures()->multiples([1, 2, 3, 4, 5]); // or FootballApi::fixtures()->multiples('1,2,3,4,5');
Get fixtures by date
FootballApi::fixtures()->byDate($date);
Get fixtures by date range
FootballApi::fixtures()->byDateRange($from, $to);
Get fixtures by date range for team
FootballApi::fixtures()->byDateRangeForTeam($from, $to, $teamId);
Get fixtures by head-to-head
FootballApi::fixtures()->headToHead($firstTeamId, $secondTeamId);
Search fixtures by name
FootballApi::fixtures()->search($teamName);
Get upcoming fixtures by market id
FootballApi::fixtures()->upcomingByMarket($marketId);
Get upcoming fixtures by tv-station id
FootballApi::fixtures()->upcomingByTvStation($tvStationId);
Get past fixtures by tv-station id
FootballApi::fixtures()->pastByTvStation($tvStationId);
Get last updated fixtures
FootballApi::fixtures()->lastUpdated();
Get tv stations by fixture id
FootballApi::fixtures($fixtureId)->tvStations();
Get predictions by fixture id
FootballApi::fixtures($fixtureId)->predictions();
Get bookmakers by fixture id
FootballApi::fixtures($fixtureId)->bookmakers();
Get commentaries by fixture id
FootballApi::fixtures($fixtureId)->commentaries();
Get value bets by fixture id
FootballApi::fixtures($fixtureId)->valueBets();
Get pre-match odds by fixture id
FootballApi::fixtures($fixtureId)->preMatchOdds();
Get pre-match odds by fixture id and bookmaker id
FootballApi::fixtures($fixtureId)->preMatchOddsByBookmaker($bookmakerId);
Get pre-match odds by fixture id and market id
FootballApi::fixtures($fixtureId)->preMatchOddsByMarket($marketId);
Get inplay odds by fixture id
FootballApi::fixtures($fixtureId)->inplayOdds();
Get inplay odds by fixture id and bookmaker id
FootballApi::fixtures($fixtureId)->inplayOddsByBookmaker($bookmakerId);
Get inplay odds by fixture id and market id
FootballApi::fixtures($fixtureId)->inplayOddsByMarket($marketId);
Get premium odds by fixture id
FootballApi::fixtures($fixtureId)->premiumOdds();
Get premium odds by fixture id and bookmaker id
FootballApi::fixtures($fixtureId)->premiumOddsByBookmaker($bookmakerId);
Get premium odds by fixture id and market id
FootballApi::fixtures($fixtureId)->premiumOddsByMarket($marketId);
Leagues
Get all leagues
FootballApi::leagues()->all();
Get league by id
FootballApi::leagues()->find($leagueId);
Get all live leagues
FootballApi::leagues()->live();
Get leagues by fixture date
FootballApi::leagues()->byFixtureDate($date);
Get leagues by country id
FootballApi::leagues()->byCountry($countryId);
Search leagues by name
FootballApi::leagues()->search($name);
Get all leagues by team id
FootballApi::leagues()->allByTeam($teamId);
Get current leagues by team id
FootballApi::leagues()->currentByTeam($teamId);
Get live standings by league id
FootballApi::leagues($leagueId)->liveStandings();
Get predictions by league id
FootballApi::leagues($leagueId)->predictions();
Livescores
Get inplay livescores
FootballApi::livescores()->inplay();
Get all livescores
FootballApi::livescores()->all();
Get last updated livescores
FootballApi::livescores()->lastUpdated();
Markets
Get all markets
FootballApi::markets()->all();
Get all premium markets
FootballApi::markets()->premium();
Get market by id
FootballApi::markets()->find($marketId);
Search markets by name
FootballApi::markets()->search($name);
Get pre-match odds by fixture id and market id
FootballApi::markets($marketId)->preMatchOddsByFixture($fixtureId);
Get inplay odds by fixture id and market id
FootballApi::markets($marketId)->inplayOddsByFixture($fixtureId);
Get premium odds by fixture id and market id
FootballApi::markets($marketId)->premiumOddsByFixture($fixtureId);
News
Get all pre-match news
FootballApi::news()->all();
Get pre-match news by season id
FootballApi::news()->bySeason($seasonId);
Get pre-match news for upcoming fixtures
FootballApi::news()->upcoming();
Odds Inplay
Get all inplay odds
FootballApi::oddsInplay()->all();
Get inplay odds by fixture id
FootballApi::oddsInplay()->byFixture($fixtureId);
Get inplay odds by fixture id and bookmaker id
FootballApi::oddsInplay()->byFixtureAndBookmaker($fixtureId, $bookmakerId);
Get inplay odds by fixture id and market id
FootballApi::oddsInplay()->byFixtureAndMarket($fixtureId, $marketId);
Get last updated inplay odds
FootballApi::oddsInplay()->lastUpdated();
Odds Pre-match
Get all pre-match odds
FootballApi::oddsPreMatch()->all();
Get pre-match odds by fixture id
FootballApi::oddsPreMatch()->byFixture($fixtureId);
Get pre-match odds by fixture id and bookmaker id
FootballApi::oddsPreMatch()->byFixtureAndBookmaker($fixtureId, $bookmakerId);
Get pre-match odds by fixture id and market id
FootballApi::oddsPreMatch()->byFixtureAndMarket($fixtureId, $marketId);
Get last updated pre-match odds
FootballApi::oddsPreMatch()->lastUpdated();
Odds Premium
Get all premium odds
FootballApi::oddsPremium()->all();
Get premium odds by fixture id
FootballApi::oddsPremium()->byFixture($fixtureId);
Get premium odds by fixture id and bookmaker id
FootballApi::oddsPremium()->byFixtureAndBookmaker($fixtureId, $bookmakerId);
Get premium odds by fixture id and market id
FootballApi::oddsPremium()->byFixtureAndMarket($fixtureId, $marketId);
Get updated premium odds between time ranges
FootballApi::oddsPremium()->updatedBetween($from, $to);
Get historical premium odds between time ranges
FootballApi::oddsPremium()->historicalBetween($from, $to);
Get all historical premium odds
FootballApi::oddsPremium()->historical();
Players
Get all players
FootballApi::players()->all();
Get player by id
FootballApi::players()->find($playerId);
Get players by country id
FootballApi::players()->byCountry($countryId);
Search players by name
FootballApi::players()->search($name);
Get last updated players
FootballApi::players()->lastUpdated();
Get transfers by player id
FootballApi::players($playerId)->transfers();
Get player statistics by season id
FootballApi::players()->statisticsBySeason($seasonId);
Predictions
Get all probabilities
FootballApi::predictions()->probabilities();
Get predictability by league id
FootballApi::predictions()->byLeague($leagueId);
Get probabilities by fixture id
FootballApi::predictions()->byFixture($fixtureId);
Get all value bets
FootballApi::predictions()->valueBets();
Get value bets by fixture id
FootballApi::predictions()->valueBetsByFixture($fixtureId);
Referees
Get all referees
FootballApi::referees()->all();
Get referee by id
FootballApi::referees()->find($refereeId);
Get referees by country id
FootballApi::referees()->byCountry($countryId);
Search referees by name
FootballApi::referees()->search($name);
Search referees by season id
FootballApi::referees()->bySeason($seasonId);
Get referee statistics by season id
FootballApi::referees()->statisticsBySeason($seasonId);
Regions
Get all regions
FootballApi::regions()->all();
Get region by id
FootballApi::regions()->find($regionId);
Search regions by name
FootballApi::regions()->search($name);
Resources
Get all resources
FootballApi::resources()->all();
Rivals
Get all rivals
FootballApi::rivals()->all();
Get rivals by team id
FootballApi::rivals()->byTeam($teamId);
Rounds
Get all rounds
FootballApi::rounds()->all();
Get round by id
FootballApi::rounds()->find($roundId);
Get rounds by season id
FootballApi::rounds()->bySeason($seasonId);
Search rounds by name
FootballApi::rounds()->search($name);
Get standings by round id
FootballApi::rounds($roundId)->standings();
Get statistics by round id
FootballApi::rounds($roundId)->statistics();
Schedules
Get schedules by season id
FootballApi::schedules()->bySeason($seasonId);
Get schedules by team id
FootballApi::schedules()->byTeam($teamId);
Get schedules by season id and team id
FootballApi::schedules()->bySeasonAndTeam($seasonId, $teamId);
Seasons
Get all seasons
FootballApi::seasons()->all();
Get season by id
FootballApi::seasons()->find($seasonId);
Get seasons by team id
FootballApi::seasons()->byTeam($teamId);
Search seasons by name
FootballApi::seasons()->search($year);
Get schedules by season id
FootballApi::seasons($seasonId)->schedules();
Get schedules by season id and team id
FootballApi::seasons($seasonId)->schedulesByTeam($teamId);
Get stages by season id
FootballApi::seasons($seasonId)->stages();
Get rounds by season id
FootballApi::seasons($seasonId)->rounds();
Get standings by season id
FootballApi::seasons($seasonId)->standings();
Get standings correction by season id
FootballApi::seasons($seasonId)->standingsCorrection();
Get topscorers by season id
FootballApi::seasons($seasonId)->topscorers();
Get teams by season id
FootballApi::seasons($seasonId)->teams();
Get squads by season id and team id
FootballApi::seasons($seasonId)->squadsByTeam($teamId);
Get venues by season id
FootballApi::seasons($seasonId)->venues();
Get news by season id
FootballApi::seasons($seasonId)->news();
Get referees by season id
FootballApi::seasons($seasonId)->referees();
Get player statistics by season id
FootballApi::seasons($seasonId)->playerStatistics();
Get team statistics by season id
FootballApi::seasons($seasonId)->teamStatistics();
Get coach statistics by season id
FootballApi::seasons($seasonId)->coachStatistics();
Get referee statistics by season id
FootballApi::seasons($seasonId)->refereeStatistics();
Squads
Get current domestic squads by team id
FootballApi::squads()->byTeam($teamId);
Get all squads by team id based on current seasons
FootballApi::squads()->extendedByTeam($teamId);
Get squads by team id and season id
FootballApi::squads()->byTeamAndSeason($teamId, $seasonId);
Stages
Get all stages
FootballApi::stages()->all();
Get stage by id
FootballApi::stages()->find($stageId);
Get stages by season id
FootballApi::stages()->bySeason($seasonId);
Search stages by name
FootballApi::stages()->search($name);
Get topscorers by stage id
FootballApi::stages($stageId)->topscorers();
Get statistics by stage id
FootballApi::stages($stageId)->statistics();
Standings
Get all standings
FootballApi::standings()->all();
Get standings by season id
FootballApi::standings()->bySeason($seasonId);
Get standings correction by season id
FootballApi::standings()->correctionBySeason($seasonId);
Get standings by round id
FootballApi::standings()->byRound($roundId);
Get live standings by league id
FootballApi::standings()->liveByLeague($leagueId);
States
Get all states
FootballApi::states()->all();
Get state by id
FootballApi::states()->find($stateId);
Statistics
Get player statistics by season id
FootballApi::statistics()->playersBySeason($seasonId);
Get team statistics by season id
FootballApi::statistics()->teamsBySeason($seasonId);
Get coach statistics by season id
FootballApi::statistics()->coachesBySeason($seasonId);
Get referee statistics by season id
FootballApi::statistics()->refereesBySeason($seasonId);
Get statistics by stage id
FootballApi::statistics()->byStage($stageId);
Get statistics by round id
FootballApi::statistics()->byRound($roundId);
Teams
Get all teams
FootballApi::teams()->all();
Get team by id
FootballApi::teams()->find($teamId);
Get teams by country id
FootballApi::teams()->byCountry($countryId);
Get teams by season id
FootballApi::teams()->bySeason($seasonId);
Search teams by name
FootballApi::teams()->search($name);
Get fixtures by date range for team
FootballApi::teams($teamId)->fixturesByDateRange($from, $to);
Get fixtures by head-to-head for team
FootballApi::teams($teamId)->headToHead($opponentId);
Get all leagues by team id
FootballApi::teams($teamId)->allLeagues();
Get current leagues by team id
FootballApi::teams($teamId)->currentLeagues();
Get schedules by team id
FootballApi::teams($teamId)->schedules();
Get schedules by team id and season id
FootballApi::teams($teamId)->schedulesBySeason($seasonId);
Get seasons by team id
FootballApi::teams($teamId)->seasons();
Get current domestic squads by team id
FootballApi::teams($teamId)->squads();
Get current extended squads by team id
FootballApi::teams($teamId)->extendedSquads();
Get squads by team id and season id
FootballApi::teams($teamId)->squadsBySeason($seasonId);
Get transfers by team id
FootballApi::teams($teamId)->transfers();
Get rivals by team id
FootballApi::teams($teamId)->rivals();
Get team statistics by season id
FootballApi::teams()->statisticsBySeason($seasonId);
Topscorers
Get topscorers by season id
FootballApi::topscorers()->bySeason($seasonId);
Get topscorers by stage id
FootballApi::topscorers()->byStage($stageId);
Transfers
Get all transfers
FootballApi::transfers()->all();
Get transfer by id
FootballApi::transfers()->find($transferId);
Get last transfers
FootballApi::transfers()->latest();
Get transfers between two dates
FootballApi::transfers()->byDateRange($from, $to);
Get transfers by team id
FootballApi::transfers()->byTeam($teamId);
Get transfers by player id
FootballApi::transfers()->byPlayer($playerId);
TvStations
Get all tv stations
FootballApi::tvStations()->all();
Get tv station by id
FootballApi::tvStations()->find($tvStationId);
Get tv stations by fixture id
FootballApi::tvStations()->byFixture($fixtureId);
Get upcoming fixtures by tv-station id
FootballApi::tvStations($tvStationId)->upcomingFixtures();
Get past fixtures by tv-station id
FootballApi::tvStations($tvStationId)->pastFixtures();
Types
Get all types
FootballApi::types()->all();
Get type by id
FootballApi::types()->find($typeId);
Get type by entity
FootballApi::types()->byEntities();
Venues
Get all venues
FootballApi::venues()->all();
Get venue by id
FootballApi::venues()->find($venueId);
Get venues by season id
FootballApi::venues()->bySeason($seasonId);
Search venues by name
FootballApi::venues()->search($name);