PHP Classes

Livescore PHP Service: Retrieve live results of football games

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 62 All time: 10,456 This week: 43Up
Version License PHP version Categories
livescore-service 1.0.0The PHP License5PHP 5, Games, Web services
Description 

Author

This package can retrieve live results of football games.

It can send HTTP requests to the api-football.com API Web servers to retrieve several types of live information about football games.

Currently, it can:

- Get the list of countries that have football leagues that can be accessed

- Get the list of available league seasons

- Get the details about the teams, like name, statistics, seasons, and countries

- Get the list of venues

- Get the standings of a league or a team

- Get the league round

- Get the list of team players

- Get the list of coaches

- Get the list of player seasons

- Get the list of player transfers

- Get game predictions and odds

- Etc...

Innovation Award
PHP Programming Innovation award nominee
March 2023
Number 8
Football (or soccer like what it is called in some countries) is a very popular sport worldwide.

Where there are championship games, many people want to know everything about the games, teams, players, scores, etc...

api-football.com provides an API that can return all that kind of information. This package provides a PHP client to retrieve that football game's data from that API.

Manuel Lemos
Picture of Hicri
  Performance   Level  
Name: Hicri <contact>
Classes: 26 packages by
Country: Turkey Turkey
Age: 30
All time rank: 291048 in Turkey Turkey
Week rank: 44 Up1 in Turkey Turkey Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Documentation

slvler - Live Score Service

tests Latest Stable Version Latest Unstable Version License

Live Score Client for api-football.com

Welcome to Api-Football! You can use our API to access all API endpoints, which can get information about Football Leagues & Cups.

Installation

To install this package tou can use composer:

    composer require slvler/livescore-service

Usage

  • First, you should extract the config/livescore.php file to the config folder.
    php artisan vendor:publish --tag=livescore

  • API key to be obtained from api-football.com address should be declared. This is your private API key, specific to this API.
    'livescore' => [
        'base_url' => 'v3.football.api-sports.io',
        'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    ],

Basic usage

Example

use slvler\LiveScoreService\LiveScoreClient;

$client = new LiveScoreClient();

Available methods

General

Status

Get the list status

$data = $client->general()->getStatus();

Countries

Countries

Get the list of available countries for the leagues endpoint.

$data = $client->countries()->getAll();

The name and code fields can be used in other endpoints as filters.

$data = $client->countries()->getAll(['code' => 'FR']);

Leagues

Countries

Get the list of available leagues and cups. This endpoint also returns the coverage of each competition, which makes it possible to know what is available for that league or cup.

 $variable =  $client->leagues()->getLeagues(['season' => '2018', 'id' => '33']);

Seasons

All seasons are only 4-digit keys, so for a league whose season is 2018-2019 like the English Premier League (EPL), the 2018-2019 season in the API will be 2018.

 $variable =  $client->leagues()->getLeaguesSeasons();

Teams

Teams Information

Get the list of available teams. The team id are unique in the API and teams keep it among all the leagues/cups in which they participate.

 $variable =  $client->team()->getTeamsInformation(['name' => 'manchester united']);

Teams Statistics

The team id are unique in the API and teams keep it among all the leagues/cups in which they participate.

 $variable =  $client->team()->getTeamsStatistics(['league' => '39', 'team' => '33', 'season' => '2019']);

Teams Seasons

Get the list of seasons available for a team.

 $variable = $client->team()->getTeamsSeasons(['team' => '33']);

Teams Countries

Get the list of countries available for the teams endpoint.

 $variable = $client->team()->getTeamCountries();

Venues

Venues

Get the list of available venues. The venue id are unique in the API.

 $variable =  $client->venues()->getVenues(['name' => 'Old Trafford']);

Standings

Standings

Get the standings for a league or a team. Return a table of one or more rankings according to the league / cup.

 $variable =  $client->standings()->getStandings([ 'league' => '39', 'season' => '2019']);

Fixtures

Rounds

Get the rounds for a league or a cup. The round can be used in endpoint fixtures as filters

 $variable =  $client->fixtures()->getRounds(['league' => '39', 'season' => 2019]);

Fixtures

For all requests to fixtures you can add the query parameter timezone to your request in order to retrieve the list of matches in the time zone of your choice like ?Europe/London?

 $variable = $client->fixtures()->getFixtures(['id' => '215662']);

Head To Head

Get heads to heads between two teams.

 $variable = $client->fixtures()->getHeadToHead(['h2h' => '33-34']);

Statistics

Get the statistics for one fixture.

 $variable = $client->fixtures()->getStatistics(['fixture' => '215662']);

Events

Get the events from a fixture.

 $variable = $client->fixtures()->getEvents(['fixture' => '215662']);

Lineups

Get the lineups for a fixture. Lineups are available between 20 and 40 minutes before the fixture when the competition covers this feature. You can check this with the endpoint leagues and the coverage field.

 $variable = $client->fixtures()->getLineups(['fixture' => '592872']);

Players statistics

Get the players statistics from one fixture.

 $variable = $client->fixtures()->getPlayersStatistics(['fixture' => '169080']);

Injuries

Injuries

Get the list of players not participating in the fixtures for various reasons such as suspended, injured for example

 $variable = $client->injuries()->getInjuries(['league' => '2', 'season' => '2020']);

Predictions

Predictions

Get predictions about a fixture. The predictions are made using several algorithms including the poisson distribution, comparison of team statistics, last matches, players etc?

 $variable = $client->predictions()->getPredictions(['fixture' => '198772']);

Coachs

Coachs

Get all the information about the coachs and their careers.

 $variable = $client->coachs()->getCoachs(['id' => '1']);

Players

Seasons

Get all available seasons for players statistics.

 $variable = $client->players()->getSeasons(['player' => '276']);

Players

Get players statistics.

 $variable = $client->players()->getPlayers(['id' => '19088', 'season' => '2018']);

Squads

Return the current squad of a team when the team parameter is used. When the player parameter is used the endpoint returns the set of teams associated with the player.

 $variable = $client->players()->getSquads(['team' => '33']);

Top Scorers

Get the 20 best players for a league or cup.

 $variable = $client->players()->getTopScorers(['season' => '2018', 'league' => '61']);

Top Assists

Get the 20 best players assists for a league or cup.

 $variable = $client->players()->getTopAssists(['season' => '2020', 'league' => '61']);

Top Yellow Cards

Get the 20 players with the most yellow cards for a league or cup.

 $variable = $client->players()->getTopYellowCards(['season' => '2020', 'league' => '61']);

Top Red Cards

Get the 20 players with the most red cards for a league or cup.

 $variable =  $client->players()->getTopRedCards(['season' => '2020', 'league' => '61']);

Transfers

Transfers

Get all available transfers for players and teams

 $variable = $client->transfer()->getTransfer(['player' => '35845']);

Trophies

Transfers

Get all available trophies for a player or a coach.

 $variable = $client->trophies()->getTrophies(['player' => '35845']);

Sidelined

Sidelined

Get all available sidelined for a player or a coach.

 $variable = $client->sidelined()->getSidelined(['player' => '276']);

Odds

Odds / Live/operation/get-odds-live)

This endpoint returns in-play odds for fixtures in progress.

 $variable = $client->odds()->getOddsLive();

Odds / Live / Bets/operation/get-bets)

Get all available bets for in-play odds.

 $variable = $client->odds()->getOddsLivBets(['id' => "1"]);

Odds/operation/get-odds)

Get odds from fixtures, leagues or date.

 $variable = $client->odds()->getOdds(['date' => "2020-05-15"]);

Mapping/operation/get-odds-mapping)

Get the list of available fixtures id for the endpoint odds.

 $variable =  $client->odds()->getOddsMapping();

Bookmakers/operation/get-bookmakers)

Get all available bookmakers.

 $variable = $client->odds()->getOddsBookmakers();

Bets/operation/get-bets)

Get all available bets for pre-match odds.

 $variable =  $client->odds()->getOddsBets();

Testing

    composer test

Credits

License

The MIT License (MIT). Please see License File for more information.


  Files folder image Files (32)  
File Role Description
Files folder image.github (1 directory)
Files folder imageconfig (1 file)
Files folder imagesrc (2 files, 5 directories)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (32)  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files (32)  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file Tests.yml Data Auxiliary data

  Files folder image Files (32)  /  config  
File Role Description
  Accessible without login Plain text file livescore.php Aux. Auxiliary script

  Files folder image Files (32)  /  src  
File Role Description
Files folder imageApi (17 files)
Files folder imageExceptions (1 file)
Files folder imageFacedes (1 file)
Files folder imageLog (3 files)
Files folder imageMessage (1 file)
  Plain text file LiveScoreClient.php Class Class source
  Plain text file LiveScoreServiceProvider.php Class Class source

  Files folder image Files (32)  /  src  /  Api  
File Role Description
  Plain text file Api.php Class Class source
  Plain text file Coachs.php Class Class source
  Plain text file Countries.php Class Class source
  Plain text file Fixtures.php Class Class source
  Plain text file General.php Class Class source
  Plain text file Injuries.php Class Class source
  Plain text file Leagues.php Class Class source
  Plain text file Odds.php Class Class source
  Plain text file Players.php Class Class source
  Plain text file Predictions.php Class Class source
  Plain text file Setting.php Class Class source
  Plain text file Sidelined.php Class Class source
  Plain text file Standings.php Class Class source
  Plain text file Teams.php Class Class source
  Plain text file Transfers.php Class Class source
  Plain text file Trophies.php Class Class source
  Plain text file Venues.php Class Class source

  Files folder image Files (32)  /  src  /  Exceptions  
File Role Description
  Plain text file TransformResponseException.php Class Class source

  Files folder image Files (32)  /  src  /  Facedes  
File Role Description
  Plain text file LiveScore.php Class Class source

  Files folder image Files (32)  /  src  /  Log  
File Role Description
  Accessible without login Plain text file LiveScore.log Data Auxiliary data
  Accessible without login Plain text file LiveSoccer.log Data Auxiliary data
  Plain text file Record.php Class Class source

  Files folder image Files (32)  /  src  /  Message  
File Role Description
  Plain text file ResponseTransformer.php Class Class source

  Files folder image Files (32)  /  tests  
File Role Description
  Plain text file LiveSoccerClientTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:0
All time:10,456
This week:43Up