https://github.com/craigchilds94/rls-api-lib-php
Rocket League Stats PHP API Library
https://github.com/craigchilds94/rls-api-lib-php
api php rocket-league
Last synced: about 2 months ago
JSON representation
Rocket League Stats PHP API Library
- Host: GitHub
- URL: https://github.com/craigchilds94/rls-api-lib-php
- Owner: CraigChilds94
- License: mit
- Created: 2016-07-05T21:50:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-27T12:02:24.000Z (about 8 years ago)
- Last Synced: 2025-03-28T06:51:14.772Z (2 months ago)
- Topics: api, php, rocket-league
- Language: PHP
- Size: 29.3 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# rls-api (PHP Implementation)
[](https://travis-ci.org/CraigChilds94/rls-api-lib-php)
[](https://www.codacy.com/app/craigchilds94/rls-api-lib-php?utm_source=github.com&utm_medium=referral&utm_content=CraigChilds94/rls-api-lib-php&utm_campaign=Badge_Grade)This is the un-official PHP client library for the RocketLeagueStats API.
### 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.
##### Fetching a list of the playlists
```php
use RocketLeagueStats\Stats as Api;$api = new Api([
'api_key' => 'your_api_key_here'
]);$playlists = $api->playlists()->toCollection();
```##### Fetching a player by platform & name
```php
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');
```##### Searching for a player on any platform
```php
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](https://github.com/vlucas/phpdotenv) installed on your project you could add the entry to your `.env` file.
```
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:
```php
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
* [Example](https://github.com/CraigChilds94/rls-api-lib-php/blob/master/example.php)
* [API Documentation](http://documentation.rocketleaguestats.com/)