PHP code example of andreskrip / sstats-api-client
1. Go to this page and download the library: Download andreskrip/sstats-api-client 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/ */
use Andreskrip\SstatsApiClient\SstatsClient;
class FootballController extends Controller
{
public function __construct(private SstatsClient $sstats) {}
public function index()
{
return $this->sstats->games()->list(['Today' => true, 'Limit' => 20]);
}
}
use Andreskrip\SstatsApiClient\Exceptions\SstatsApiException;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\RequestException;
try {
$glicko = Sstats::games()->glicko(12345);
} catch (SstatsApiException $e) {
// e.g. "Not enough history for Glicko analytics"
} catch (RequestException|ConnectionException $e) {
// HTTP or network failure
}
// Authenticated user info
Sstats::account()->info();
// List games with filters
Sstats::games()->list([
'Today' => true,
'Live' => true,
'LeagueId' => 1,
'Limit' => 50,
'Offset' => 0,
// From, To, Date, Status, HomeTeam, AwayTeam, Team,
// BothTeams, Ended, Upcoming, Year, SeasonUid, Order, TimeZone
]);
// Get game by ID
Sstats::games()->find(12345);
// Glicko-2 rating for a game
Sstats::games()->glicko(12345);
// Advanced query (POST) — SQL-like condition string
Sstats::games()->query([
'condition' => 'LeagueId = 41 AND Year = 2023',
'fields' => ['Id', 'HomeTeamName', 'AwayTeamName', 'Date'],
'format' => 'json',
'timezone' => 3,
'order' => 'Date',
'offset' => 0,
'limit' => 100,
]);
// Season standings table
Sstats::games()->seasonTable([
'league' => 1,
'year' => 2024,
'limit' => 20,
'format' => 'json',
'fields' => 'team,points,wins',
'orderField' => 'points',
]);
// Last N games stats for both teams in a fixture
Sstats::games()->lastGamesStats(gameId: 12345, params: [
'limit' => 10,
'sameLeague' => true,
'homeAway' => true,
]);
// Text summary of recent results
Sstats::games()->textSummary(id: 12345, params: [
'limit' => 5,
'sameLeague' => true,
'homeAway' => true,
]);
// Bookmaker profit stats for a game
Sstats::games()->profits(gameId: 12345, params: [
'bookieId' => 1,
'thisLeague' => true,
'homeAway' => true,
'limit' => 20,
]);
// Team injury report for a game
Sstats::games()->injuries(12345);
// All leagues
Sstats::leagues()->all();
// List bookmakers
Sstats::odds()->bookmakers();
// Pre-match odds for a game
Sstats::odds()->forGame(gameId: 12345, params: [
'bookmakerId' => 1,
'opening' => false,
]);
// Live odds for a game
Sstats::odds()->liveForGame(12345);
// Live odds changes — only updated values since last poll
Sstats::odds()->liveChangesUpdatesOnly(12345);
// Full live odds change history
Sstats::odds()->liveChanges(gameId: 12345, params: [
'markets' => '1x2,ou',
'outcomes' => 'home,draw',
]);
// Available pre-match market types
Sstats::odds()->prematchMarkets();
// Available live market types
Sstats::odds()->liveMarkets();
// Search players by name
Sstats::players()->find('Messi');
// Get player by ID
Sstats::players()->show(42);
// List players with filters
Sstats::players()->list([
'teamId' => 5,
'offset' => 0,
'limit' => 50,
]);
// Player match events (goals, cards, assists)
Sstats::players()->events(id: 42, params: [
'
// List teams
Sstats::teams()->list([
'Name' => 'Arsenal',
'Country' => 'England',
'Offset' => 0,
'Limit' => 20,
]);
// Get team by ID
Sstats::teams()->find(7);
// League standings for a season
Sstats::seasons()->standings([
'leagueId' => 1,
'year' => 2024,
]);
// List matches
Sstats::ls()->list([
'Live' => true,
'Upcoming' => true,
'LeagueId' => 1,
'Limit' => 50,
]);
// Teams
Sstats::ls()->teams(['name' => 'Chelsea']);
// Leagues
Sstats::ls()->leagues(['name' => 'Premier']);
// Seasons for a league
Sstats::ls()->seasons(['leagueId' => 1]);
// Detailed game info (string ID from Ls/List response)
Sstats::ls()->gameInfo('E9CvZaQE');
// Countries
Sstats::pari()->countries();
// Leagues
Sstats::pari()->leagues(['countryId' => 1, 'limit' => 50]);
// Single league
Sstats::pari()->league(10);
// Matches
Sstats::pari()->matches([
'leagueId' => 1,
'live' => true,
'— same eventId
Sstats::pari()->events(777);
// Teams
Sstats::pari()->teams(['countryId' => 1]);
// Market types
Sstats::pari()->oddsMarketTypes();
// Event types
Sstats::pari()->eventTypes();