rls-api (PHP Implementation)
, (*1)
This is the un-official PHP client library for the RocketLeagueStats API., (*2)
Installation
composer require craigchilds/rls-api
Usage
Here are a few examples of how you can use the api to fetch different types of data., (*3)
Fetching a list of the playlists
use RocketLeagueStats\Stats as Api;
$api = new Api([
'api_key' => 'your_api_key_here'
]);
$playlists = $api->playlists()->toCollection();
use RocketLeagueStats\Stats as Api;
use RocketLeagueStats\Data\Platform;
$api = new Api([
'api_key' => 'your_api_key_here'
]);
$player = $api->player(Platform::PS4, 'PS4_UserNameHere');
use RocketLeagueStats\Stats as Api;
$api = new Api([
'api_key' => 'your_api_key_here'
]);
$results = $api->search('UserNameHere')->toCollection();
Environment Variables
If you want you can supply the api key through an environment variable. Lets say, if you had DotEnv installed on your project you could add the entry to your .env file., (*4)
RLS_API_KEY="rls_api_key_here"
And then you will not need to pass it in the constructor of the RocketLeagueStats\Stats class. Here is an example batch player request without passing the api key:, (*5)
use RocketLeagueStats\Stats as Api;
use RocketLeagueStats\Data\Collection;
$api = new Api();
$players = new Collection([
['player' => 'UserName1', 'platform' => Platform::PS4],
['player' => 'UserName1', 'platform' => Platform::Steam],
]);
$allPlayers = $api->batch($players);
Links