PHP code example of proveyourskillz / lol-api

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

    

proveyourskillz / lol-api example snippets


$api = new PYS\LolApi\Api(API_KEY);

use PYS\LolApi\ApiRequest\Region;

$summoner = $api->summoner(Region::EUW, $summonerId);

// You can get summoner in several ways by passing type in third argument
// Default version: summoner, you can ommit it
$summonerById = $api->summoner($region, $summonerId);
$summonerByAccount = $api->summoner($region, $accountId, 'account');
$summonerByName = $api->summoner($region, $name, 'name');

$matches = $api->matchList($region, $accountId);

$matches = $api->summoner($region, $summonerId)->recentMatches();

$matches = $api->matchList(
    $region,
    $accountId,
    [
        'beginIndex' => 0,
        'endIndex' => 1,
    ]
);

$match = $api->match($region, $matchId);

$match = $api->match($region, $matchId, $tournamentId);

$leaguesPositions = $api->leaguePosition($region, $summonerId);

$leaguesPositions = $api
    ->summoner($region, $summonerId)
    ->leaguesPositions();

$leagues = $api->league($region, $summonerId);

use PYS\LolApi\ApiRequest\MatchListRequest;
use PYS\LolApi\ApiRequest\Query\MatchListQuery;

$api = new PYS\LolApi\Api($API_KEY);

$query = new MatchListQuery;
$request = new MatchListRequest($region, $accountId);
$request->setQuery($query->lastMatches(1));

$matchList = $api->make($request);

// Setup query object to get last 5 matches in 24 hours
$query = new MatchListQuery;
$query
    ->fromDate(new DateTime('-24 hours'))
    ->lastMatches(5);