Skip to content

Repository files navigation

Phizz — Laravel client for the Riot Games API

Latest Version on PackagistGitHub Tests Action StatusGitHub Code Style Action StatusTotal Downloads

A type-safe, auto-generated Laravel client for the Riot Games API. Covers League of Legends, Teamfight Tactics, Legends of Runeterra, Valorant, and Riftbound — generated directly from official OpenAPI schemas with built-in caching, proactive rate limiting, and automatic regional routing.

Requirements

  • PHP >= 8.1
  • Laravel >= 10

Installation

composer require communitydragon/phizz

Publish the config file:

php artisan vendor:publish --tag="phizz-config"

Add your Riot API key to .env:

RIOT_API_KEY=your-api-key-hereRIOT_DEFAULT_PLATFORM=na1

Usage

Access APIs through the Phizz facade. Each game exposes its own client.

usePhizz\Facades\Phizz;
usePhizz\Enums\Platform;
usePhizz\Enums\Regional;
// League of Legends$match = Phizz::lol()->matchV5->getMatch('EUW1_1234567890');
$summoner = Phizz::lol()->summonerV4->getByPuuid($puuid);
$mastery = Phizz::lol()->championMasteryV4->getAllChampionMasteriesByPuuid($puuid);
// Per-call platform override$match = Phizz::lol(Platform::EUW)->matchV5->getMatch('EUW1_1234567890');
// Teamfight Tactics$tftMatch = Phizz::tft()->matchV1->getMatch('EUW1_1234567890');
$tftLeague = Phizz::tft()->leagueV1->getChallengerLeague();
$tftSummoner = Phizz::tft()->summonerV1->getByPuuid($puuid);
// Valorant$valMatch = Phizz::val()->matchV1->getMatch($matchId);
$valLeaderboard = Phizz::val()->rankedV1->getLeaderboard('e7a1');
// Legends of Runeterra$lorMatch = Phizz::lor()->matchV1->getMatch($matchId);
$lorLeaderboard = Phizz::lor()->rankedV1->getLeaderboards();
// Account (cross-game)$account = Phizz::riot()->accountV1->getByRiotId(gameName: 'IAmTheWhite', tagLine: 'EUW');

Bypassing the cache

Every API method accepts a force parameter. When true, the request always hits the network and the cache is skipped entirely — nothing is read from it and nothing is written to it.

// Always fetches fresh data, even when caching is enabled$match = Phizz::lol()->matchV5->getMatch('EUW1_1234567890', force: true);

Caching

Caching is enabled by default and uses your application's default cache store. The TTL applied to each response is resolved in this order:

  1. Per-method override in config/phizz.php under cache.method[]
  2. Global default (cache.default, 60 seconds)

Per-method TTLs are configured using the TTL class, which provides a chained constant syntax:

usePhizz\TTL;
// config/phizz.php'cache' => [
'enabled' => env('RIOT_CACHE_ENABLED', true),
'store' => env('RIOT_CACHE_STORE', null),
'default' => env('RIOT_CACHE_TTL', 60),
'method' => [
TTL::lol::matchV5::getMatch => 86400, // matches — cache for 24 hTTL::lol::matchV5::getTimeline => 86400,
TTL::lol::summonerV4::getByPuuid => 3600, // slow-changing — 1 hTTL::lol::leagueV4::getChallengerLeague => 300, // rankings — 5 minTTL::lol::spectatorV5::getCurrentGameInfoByPuuid => 30, // live game — 30 s
],
],

Sane defaults for all endpoints across every game are shipped in the published config.

Retry strategy

Phizz automatically retries on 429 responses. Two built-in strategies are available:

usePhizz\Retry;
// Exponential backoff: 1 s, 2 s, 4 s, 8 s, ... (default)'retry' => ['strategy' => Retry::exponential()],
// Fixed delay between every attempt'retry' => ['strategy' => Retry::fixed(seconds: 2)],

When a Retry-After header is present in the 429 response, Phizz always respects it over the configured strategy.

Rate limiting

Phizz tracks Riot's X-App-Rate-Limit and X-Method-Rate-Limit response headers and sleeps proactively before sending requests that would otherwise trigger a 429. Rate limit state is stored in the configured cache store and scoped per platform and endpoint.

Platforms & regions

usePhizz\Enums\Platform; // na1, euw1, kr, br1, jp1, ...usePhizz\Enums\Regional; // Americas, Europe, Asia, SEAusePhizz\Enums\ValPlatform; // NA, EU, AP, KR, BR, LatAm, Esports

Endpoints that require a regional host (e.g. match history) automatically convert a Platform to the correct Regional value — Platform::EUW becomes Regional::Europe transparently.

Supported APIs

Cross-game (riot)

APIVersion
AccountV1

League of Legends (lol)

APIVersion
ChallengesV1
Champion MasteryV4
ChampionV3
ClashV1
League EXPV4
LeagueV4
MatchV5
RSO MatchV1
SpectatorV5
StatusV4
SummonerV4
Tournament StubV5
TournamentV5

Teamfight Tactics (tft)

APIVersion
LeagueV1
MatchV1
SpectatorV5
StatusV1
SummonerV1

Valorant (val)

APIVersion
Console MatchV1
Console RankedV1
ContentV1
MatchV1
RankedV1
StatusV1

Legends of Runeterra (lor)

APIVersion
DeckV1
InventoryV1
MatchV1
RankedV1
StatusV1

Riftbound (riftbound)

APIVersion
ContentV1

Configuration reference

// config/phizz.phpreturn [
// Your Riot Games API key'api_key' => env('RIOT_API_KEY', ''),
// Default platform used when none is specified per-call'default_platform' => env('RIOT_DEFAULT_PLATFORM', Platform::NA),
// Maximum seconds to wait for a response before timing out'timeout' => env('RIOT_TIMEOUT', 60),
// Retry strategy on 429 responses'retry' => [
'strategy' => Retry::exponential(),
],
// Response caching'cache' => [
'enabled' => env('RIOT_CACHE_ENABLED', true),
'store' => env('RIOT_CACHE_STORE', null), // null = app default'default' => env('RIOT_CACHE_TTL', 60), // fallback TTL in seconds'method' => [
// Per-endpoint TTL overrides using TTL constantsTTL::lol::matchV5::getMatch => 86400,
// ...
],
],
// Log all requests and responses (useful for debugging)'logging' => [
'enabled' => env('RIOT_LOGGING_ENABLED', false),
],
];

Testing

composer test# run the full test suite
composer test-coverage # run tests with coverage report
composer analyse # run PHPStan static analysis
composer format # run Laravel Pint code formatter

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

About

An auto-generated Laravel library for Riot API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages