PHP code example of voroxi / footballdata

1. Go to this page and download the library: Download voroxi/footballdata library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voroxi / footballdata example snippets




ootballdata\Client;
use Footballdata\FootballDataException;

$client = new Client('YOUR_API_KEY');

try {
    // Today's fixtures
    $fixtures = $client->fixtures->today(['limit' => 10]);

    // A league table
    $standings = $client->leagues->standings(1625);

    // Rate-limit / plan info from the last response
    echo $client->lastMeta['requests_remaining'] ?? 'n/a', " requests left\n";
} catch (FootballDataException $e) {
    echo "[{$e->getStatus()}] {$e->getErrorCode()}: {$e->getMessage()}\n";
}

$client = new Client('YOUR_API_KEY', [
    'baseUrl' => 'https://footballdata.io/api/v1', // default
    'timeout' => 30,                               // seconds, default 30
]);

$meta = $client->lastMeta;      // or $client->getLastMeta()
echo $meta['plan'], ' ', $meta['requests_remaining'];

$client->meta->status();     // GET /meta/status
$client->meta->coverage();   // GET /meta/coverage

$client->account->usage();   // GET /account/usage

$client->fixtures->today(['league_id' => 1625, 'status' => 'NS']); // GET /fixtures/today
$client->fixtures->todayPredictions();                              // GET /fixtures/today/predictions
$client->fixtures->live();                                          // GET /fixtures/live
$client->fixtures->upcoming(['page' => 1, 'limit' => 20]);          // GET /fixtures/upcoming
$client->fixtures->results(['page' => 1]);                          // GET /fixtures/results

$client->leagues->list(['country' => 'England', 'search' => 'premier']); // GET /leagues
$client->leagues->standings(1625);   // GET /leagues/{id}/standings
$client->leagues->matches(1625);     // GET /leagues/{id}/matches
$client->leagues->teams(1625);       // GET /leagues/{id}/teams
$client->leagues->seasons(1625);     // GET /leagues/{id}/seasons
$client->leagues->stats(1625);       // GET /leagues/{id}/stats
$client->leagues->btts(1625);        // GET /leagues/{id}/btts
$client->leagues->corners(1625);     // GET /leagues/{id}/corners

$client->matches->list(['page' => 1, 'limit' => 50]); // GET /matches
$client->matches->get(9876543);           // GET /matches/{id}
$client->matches->stats(9876543);         // GET /matches/{id}/stats
$client->matches->events(9876543);        // GET /matches/{id}/events
$client->matches->odds(9876543);          // GET /matches/{id}/odds
$client->matches->predictions(9876543);   // GET /matches/{id}/predictions
$client->matches->probabilities(9876543); // GET /matches/{id}/probabilities
$client->matches->btts(9876543);          // GET /matches/{id}/btts
$client->matches->corners(9876543);       // GET /matches/{id}/corners
$client->matches->byDate('2026-05-10');   // GET /matches/date/{date}

$client->teams->list(['search' => 'arsenal']); // GET /teams
$client->teams->get(59);            // GET /teams/{id}
$client->teams->matches(59);        // GET /teams/{id}/matches
$client->teams->players(59);        // GET /teams/{id}/players
$client->teams->stats(59);          // GET /teams/{id}/stats
$client->teams->h2h(59, 66);        // GET /teams/{id}/h2h/{opponentId}

$client->players->list(['search' => 'saka']); // GET /players
$client->players->get(12345);   // GET /players/{id}
$client->players->stats(12345); // GET /players/{id}/stats

$client->seasons->list();          // GET /seasons
$client->seasons->matches(2024);   // GET /seasons/{id}/matches
$client->seasons->standings(2024); // GET /seasons/{id}/standings
$client->seasons->teams(2024);     // GET /seasons/{id}/teams

$client->countries->list();               // GET /countries
$client->countries->leagues('England');   // GET /countries/{country}/leagues

$client->fifaRankings->list();              // GET /fifa-rankings
$client->fifaRankings->current();           // GET /fifa-rankings/current
$client->fifaRankings->periods();           // GET /fifa-rankings/periods
$client->fifaRankings->history('Brazil');   // GET /fifa-rankings/{country}/history

$client->search('arsenal'); // GET /search?q=arsenal

use Footballdata\FootballDataException;

try {
    $data = $client->matches->predictions(9876543);
} catch (FootballDataException $e) {
    $e->getStatus();     // HTTP status: 401, 403, 404, 429, ...
    $e->getErrorCode();  // machine-readable code from the API
    $e->getMessage();    // human-readable message
    $e->getDetails();    // raw details array (may be null)

    // On a 403 plan-gate, the API