Skip to content

ahsxn/brawl-stars-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BrawlStars API

A PHP library to conveniently access and query the BrawlStars API. It includes a pre-defined set of classes that initialise themselves dynamically from API responses.

This package uses the official BrawlStars API. For more information, please visit https://developer.brawlstars.com/

To read the brawlstars-php documentation please vist https://ahsan112.gitbook.io/brawlstars-php/

Requirements

To use this package, you need to obtain an API key at https://developer.brawlstars.com/

Installation

Using Composer

composer require ahsan112/brawlstars-php

Usage

When instantiating the BrawlStarsClient, you have to provide your API key:

$client = new BrawlStarsClient('key');

Players

Refers to /players endpoint from the official docs.

Retrieve a player

$player = $client->getPlayer('tag');

A Player object is returned

$player->soloVictories()
$player->highestTrophies()
$player->brawlers();
$player->brawlers()->brawler('leon');
$player->brawlers()->brawler('leon')->power();

For more methods read the brawlstars-php documentation.

Retrieve a player's battle log

$battleLog = client->getPlayerBattleLog('tag');

$battleLog->all() // retrives all battles as BattleLogList Object
$battleLog->latest() // retrives the most recent battle by the player
$battleLog->latest()->result();
$battleLog->latest()->teams();

For more methods read the brawlstars-php documentation.

Clubs

Refers to /clubs/{clubTag} endpoint from the official docs.

$club = $client->getClub('club tag'); // returns Club object

$club->name(); 
$club->description(); 
$club->members(); // ClubMembersList Object 

For more methods read the brawlstars-php documentation.

Getting club president, vice-presidents, seniors

$president = $club->president(); 
$president->name();
$president->trophies(); 

$vicePresidents = $club->vicePresidents(); 
$seniors = $club->seniors(); 

Rankings

Season ranking

Refers to /rankings{countryCode}/seasons/{seasonId} endpoint from the official docs.

$seasonRanking = $client->getSeasonRanking(); // default is ('global', 'latest')
$seasonRanking = $client->getSeasonRanking('gb', '56');

$seasonRanking->topTen();
$seasonRanking->first()->name();
$seasonRanking->first()->trophies();

Clubs Ranking

Refers to /rankings{countryCode}/clubs endpoint from the official docs.

$clubRanking = $client->getClubsRanking(); // default is ('global')
$clubRanking = $client->getClubsRanking('gb');

$clubRanking->topTen();
$clubRanking->first()->name();
$clubRanking->first()->trophies();
$clubRanking->first()->memberCount();

Brawler Ranking

Refers to /rankings{countryCode}/brawlers/{brawlerId} endpoint from the official docs.

$brawlerRanking = $client->getBrawlerRanking('brawler id');

$brawlerRanking->topTen();
$brawlerRanking->first()->name();
$brawlerRanking->first()->trophies();
$brawlerRanking->first()->club();

Player Ranking

Refers to /rankings/{countryCode}/players endpoint from the official docs.

$playerRanking = $client->getPlayerRanking('tag');

$playerRanking->topTen();
$playerRanking->first()->name();
$playerRanking->first()->trophies();
$playerRanking->first()->club();

For more methods read the brawlstars-php documentation.

Events

Refers to /events/rotation endpoint from the official docs.

$events = $client->getEvents();

$events->all();
$events->first()->startTime();
$events->first()->endTime();
$events->first()->map();

For more methods read the brawlstars-php documentation.

About

php api wrapper for the official brawl starts api

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages