PHP code example of callisto / riot-api-wrapper

1. Go to this page and download the library: Download callisto/riot-api-wrapper 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/ */

    

callisto / riot-api-wrapper example snippets


$raw = new \Callisto\RiotApiWrapper\RiotApiWrapper('YOUR_API_KEY');

$summoner = $raw->LOL('EUW1')->Summoner()->byName('NAME');

['BR1','EUN1','EUW1','JP1','KR','LA1','LA2','NA1','OC1','TR1','RU','PH2','SG2','TH2','TW2','VN2']

['AMERICAS','ASIA','EUROPE','SEA']

// Riot/Account

- Riot()->Account(string $region)->byPuuid(string $puuid)
- Riot()->Account(string $region)->byGame(string $game, string $puuid)

// LOL/ChampionMastery

- LOL()->ChampionMastery(string $platform)->bySummoner(string $encryptedSummonerId)
- LOL()->ChampionMastery(string $platform)->byChampion(string $encryptedSummonerId, string $championId)
- LOL()->ChampionMastery(string $platform)->top(string $encryptedSummonerId)
- LOL()->ChampionMastery(string $platform)->scores(string $encryptedSummonerId)

// LOL/ChampionMastery

- LOL()->Champion(string $platform)->rotations()

// LOL/Clash

- LOL()->Clash(string $platform)->byPuuid(string $puuid)
- LOL()->Clash(string $platform)->bySummoner(string $summonerId)
- LOL()->Clash(string $platform)->team(string $teamId)
- LOL()->Clash(string $platform)->tournaments()
- LOL()->Clash(string $platform)->tournamentsByTeam(string $teamId)
- LOL()->Clash(string $platform)->tournamentsById(string $tournamentId)

// LOL/LeagueExp

- LOL()->LeagueExp(string $platform)->exp(string $queue, string $tier, string $division)

// LOL/League

- LOL()->League(string $platform)->byQueue(string $queue)
- LOL()->League(string $platform)->bySummonerId(string $summonerId)
- LOL()->League(string $platform)->byQueueTierDivision(string $queue, string $tier, string $division)
- LOL()->League(string $platform)->grandMasterLeagues(string $queue)
- LOL()->League(string $platform)->leagueId(string $leagueId)
- LOL()->League(string $platform)->masterLeagues(string $queue)

// LOL/Challenges

- LOL()->Challenges(string $platform)->challenges()
- LOL()->Challenges(string $platform)->percentiles()
- LOL()->Challenges(string $platform)->challengeIdConfig(string $challengeId)
- LOL()->Challenges(string $platform)->leaderboardByLevel(string $challengeId, string $level)
- LOL()->Challenges(string $platform)->percentilesByChallengeId(string $challengeId)
- LOL()->Challenges(string $platform)->playerData(string $puuid)

// LOL/Status

- LOL()->Status(string $platform)->status()

// LOL/Matches

- LOL()->Status(string $region)->ids(string $puuid, array $options = [])
- LOL()->Status(string $region)->match(string $matchId)
- LOL()->Status(string $region)->timeline(string $matchId)

// LOL/Spectator

- LOL()->Spectator(string $platform)->activeGames(string $summonerId)
- LOL()->Spectator(string $platform)->featuredGames()

// LOL/Summoner

- LOL()->Summoner(string $platform)->byAccount(string $accountId)
- LOL()->Summoner(string $platform)->byName(string $summonerName)
- LOL()->Summoner(string $platform)->byPuuid(string $puuid)
- LOL()->Summoner(string $platform)->bySummonerId(string $summonerId)

// TFT/League

- TFT()->League(string $platform)->challenger()
- TFT()->League(string $platform)->bySummonerId(string $summonerId)
- TFT()->League(string $platform)->byTierAndDivision(string $tier, string $division, array $options = [])
- TFT()->League(string $platform)->grandmaster()
- TFT()->League(string $platform)->byLeagueId(string $leagueId)
- TFT()->League(string $platform)->master()
- TFT()->League(string $platform)->topByQueue(string $queue)

// TFT/Matches

- TFT()->Matches(string $region)->ids(string $puuid, array $options = [])
- TFT()->Matches(string $region)->match(string $matchId)

// TFT/Status

- TFT()->Status(string $platform)->platformData()

// TFT/Summoner

- TFT()->Summoner(string $platform)->byAccountId(string $accountId)
- TFT()->Summoner(string $platform)->byName(string $name)
- TFT()->Summoner(string $platform)->byPuuid(string $puuid)
- TFT()->Summoner(string $platform)->bySummonerId(string $summonerId)


// Get recent LoL matches exemple

r\RiotApiWrapper('YOUR_API_KEY'); // Init RiotApiWrapper
$raw->Cache(); // (Optional) Enable cache.


// (Optional) Request options
$options = [
    'startTime' => strtotime('01/01/2023'), // (Optional) timestamp (seconds). Before this date, matches won't be  20, // (Optional) max results count
];

try {

    $matchesIds = $raw->LOL()->Matches('EUROPE')->ids('PUUID',$options); // Return matches ids list

    foreach ($matchesIds as $matchId){
        $matches[] = $raw->LOL()->Matches('EUROPE')->match($matchId); // Return match datas from match id
    }

    print_r($matches);

}Catch(Exception $exception){
    exit($exception->getMessage());
}Catch(\Callisto\RiotApiWrapper\Exceptions\RequestExceptions $exception){
    exit($exception->getMessage());
}

// Search summoner

$name = 'example'; // Summoner name to search

$raw = new \Callisto\RiotApiWrapper\RiotApiWrapper('YOUR_API_KEY'); // Init RiotApiWrapper
$raw->Cache(); // (Optional) Enable cache.

$searchPlatform =  ['BR1','EUN1','EUW1','JP1','KR','LA1','LA2']; // Select platforms you want to search on

try {

    foreach ($searchPlatform as $platform){
        $results[$platform] = $raw->LOL()->Summoner($platform)->byName($name); // Save result even if empty
    }
    
}catch (\Callisto\RiotApiWrapper\Exceptions\RequestExceptions $exception){
    exit($exception->getMessage());
} catch (Exception $e) {
    exit($e->getMessage());
}


print_r($results);

// Get summoner and last match

apper\RiotApiWrapper('YOUR_API_KEY'); //Init RiotApiWrapper
$raw->Cache(); // (Optional) Enable cache.

try {

    $summoner = $raw->TFT()->Summoner('EUW1')->byName('NAME'); // Get {NAME} summoner data

    $options = [
        'count' => 1, // (Optional) max results count
    ];

    $lastMatchId = $raw->TFT()->Matches('EUROPE')->ids($summoner['puuid'],$options)[0]; // Get last match id

    $lastMatch = $raw->TFT()->Matches('EUROPE')->match($lastMatchId); // Get $lastMatchId match data

    print_r($lastMatch);

} catch (Exception $exception) {
    exit($exception->getMessage());
} catch (\Callisto\RiotApiWrapper\Exceptions\RequestExceptions $exception) {
    exit($exception->getMessage());
}

$summoner = $raw->LOL()->Summoner('BR1')->byName('frosty');

array(7) {
    ["id"]              => string(47) "d28PpG7Udqz1DC426V0xhBcExDZ21m8eYY9Ys9zhOOsKjNM"
    ["accountId"]       => string(47) "f_WSG9mgV23Zxh132C_9d2o1DMYg3Rq9sPp_APHp1QGlcdA"
    ["puuid"]           => string(78) "oB7jr-sPTP2Vs8Y6fglY345VFRdjNfxfPoAsXI3ViJbBlAmWCvN81igfZO88Y5_5JlCQreBKKO4uA"
    ["name"]            => string(6) "frosty"
    ["profileIconId"]   => int(5490)
    ["revisionDate"]    => int(1681258365846)
    ["summonerLevel"]   => int(813)
}