Dead simple wrapper of Riot Games API (LoL)
- PHP 7.1
- works better with ext-curl installed
composer require proveyourskillz/lol-api
$api = new PYS\LolApi\Api(API_KEY);
ServiceProvider and Facade are registered automatically through package discovery
In config/app.php
add PYS\LolApi\Laravel\ServiceProvider
as provider
Register ServiceProvider according documentation
Optionally you can add facade to aliases 'LolApi' => PYS\LolApi\Laravel\Facade::class
After installation, you can use API through facade or inject as dependency
You can find examples of usage in examples
dir
You can pass region to request as 2-3 characters code but better use Region
class constants
use PYS\LolApi\ApiRequest\Region;
$summoner = $api->summoner(Region::EUW, $summonerId);
There are several ways to get Summoner: by account id, summoner id or by name
// 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');
For more information see Summoner API reference
Recent
$matches = $api->matchList($region, $accountId);
Recent via Summoner
$matches = $api->summoner($region, $summonerId)->recentMatches();
Using query (e.g. one last match)
$matches = $api->matchList(
$region,
$accountId,
[
'beginIndex' => 0,
'endIndex' => 1,
]
);
Match by Id
$match = $api->match($region, $matchId);
Match within Tournament
$match = $api->match($region, $matchId, $tournamentId);
For more information see Match API reference
Leagues and Positions of summoner by Summoner Id
$leaguesPositions = $api->leaguePosition($region, $summonerId);
Leagues and Positions of summoner via Summoner object
$leaguesPositions = $api
->summoner($region, $summonerId)
->leaguesPositions();
Leagues by Summoner Id
$leagues = $api->league($region, $summonerId);
Examples from above (e.g., match list request with query) are shows usage of syntax sugar methods and can be rewritten as
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);
Query objects have fluent setters for easy setup some properties like dates etc.
// Setup query object to get last 5 matches in 24 hours
$query = new MatchListQuery;
$query
->fromDate(new DateTime('-24 hours'))
->lastMatches(5);
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Alpha version
- Anton Orlov anton@proveyourskillz.com
- Pavel Dudko pavel@proveyourskillz.com
MIT