PHPackages                             dncusmir/bsapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dncusmir/bsapi

ActiveLibrary[API Development](/categories/api)

dncusmir/bsapi
==============

a client for BrawlStars api

11PHPCI failing

Since May 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dncusmir/BsApi)[ Packagist](https://packagist.org/packages/dncusmir/bsapi)[ RSS](/packages/dncusmir-bsapi/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

BrawStars Api PHP
=================

[](#brawstars-api-php)

[![CI-CD](https://github.com/dncusmir/BsApi/workflows/CI-CD/badge.svg)](https://github.com/dncusmir/BsApi/workflows/CI-CD/badge.svg)[![](https://camo.githubusercontent.com/ac0cbc0d7eb674d72e6fd61abf86a2884c27a3ef26aa18f5bbeec87550b5226a/68747470733a2f2f73686570686572642e6465762f6769746875622f646e6375736d69722f42734170692f636f7665726167652e737667)](https://camo.githubusercontent.com/ac0cbc0d7eb674d72e6fd61abf86a2884c27a3ef26aa18f5bbeec87550b5226a/68747470733a2f2f73686570686572642e6465762f6769746875622f646e6375736d69722f42734170692f636f7665726167652e737667)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Total Downloads](https://camo.githubusercontent.com/aa4b6bb23999b7db664ec3dee4b31411c8fd53f4b44324dcca0e3b15104cc3d6/68747470733a2f2f706f7365722e707567782e6f72672f646e6375736d69722f62736170692f646f776e6c6f616473)](//packagist.org/packages/dncusmir/bsapi)[![Stable release](https://camo.githubusercontent.com/64d91441d2ceb3c7180ac15fac53e8769d197400958fcf9beee6e5f82999002f/68747470733a2f2f706f7365722e707567782e6f72672f646e6375736d69722f62736170692f76657273696f6e2e737667)](https://packagist.org/packages/dncusmir/bsapi)

A PHP client to use [BrawStars Api](https://developer.brawlstars.com/#/) implementing [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-17](https://www.php-fig.org/psr/psr-17/) and [PSR-18](https://www.php-fig.org/psr/psr-18/).

Instalation
-----------

[](#instalation)

### Prerequisites

[](#prerequisites)

BrawStars Api requires PHP 7.3 or greater.

### Via composer:

[](#via-composer)

```
composer require dncusmir/bsapi

```

It also needs actual implementation for [PSR-7](https://www.php-fig.org/psr/psr-7/) and [PSR-18](https://www.php-fig.org/psr/psr-18/). For example [Guzzle 6 HTTP Adapter](https://github.com/php-http/guzzle6-adapter) for the http client and [laminas-diactoros](https://github.com/laminas/laminas-diactoros) for the http factory.

```
composer require php-http/guzzle6-adapter
composer require laminas/laminas-diactoros

```

Usage
-----

[](#usage)

First make sure to get your api key at (). Using the client and factory from before:

```
use Dncusmir\BsApi\BsApi;
use Laminas\Diactoros\RequestFactory;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

// get your client and factory: can use any compatible psr-7 / psr-17 packages
$config = [
    'timeout' => 25,
];
$httpClient = GuzzleAdapter::createWithConfig($config);
$httpRequestFactory = new RequestFactory();

// create your api object to use for api calls
$apiKey = 'your api key';
$api = new BsApi($apiKey, $httpClient, $httpRequestFactory);
```

Now you can make api calls to the [BrawStars Api](https://api.brawlstars.com/v1/).

Usage examples
--------------

[](#usage-examples)

##### Getting a player's name:

[](#getting-a-players-name)

```
$playerTag = "#8GVLPUGRJ";

$player = $api->getPlayerInformation($playerTag);

echo $player['name'] . PHP_EOL;
```

##### Getting a player's brawlers and their trophies

[](#getting-a-players-brawlers-and-their-trophies)

```
foreach ($player['brawlers'] as $brawler) {
    echo $brawler['name'] . ' ' . $brawler['trophies'] . PHP_EOL;
}
```

Functions
---------

[](#functions)

###### Get player information for a specific tag

[](#get-player-information-for-a-specific-tag)

```
public function getPlayerInformation(string $playerTag): array
```

###### Get log of recent battles for a player

[](#get-log-of-recent-battles-for-a-player)

```
public function getPlayerBattleLog(string $playerTag): array
```

###### Get club information.

[](#get-club-information)

```
public function getClubInformation(string $clubTag): array
```

###### List club members.

[](#list-club-members)

```
public function getClubMembers(string $clubTag): array
```

###### Get player rankings for a country or global rankings.

[](#get-player-rankings-for-a-country-or-global-rankings)

```
public function getPlayerRankings(string $countryCode): array
```

###### Get club rankings for a country or global rankings.

[](#get-club-rankings-for-a-country-or-global-rankings)

```
public function getClubRankings(string $countryCode): array
```

###### Get brawler rankings for a country or global rankings.

[](#get-brawler-rankings-for-a-country-or-global-rankings)

```
public function getBrawlerRankings(string $countryCode, string $brawlerId): array
```

###### Get list of available brawlers.

[](#get-list-of-available-brawlers)

```
public function getBrawlers(): array
```

###### Get information about a brawler.

[](#get-information-about-a-brawler)

```
public function getBrawlerInformation(string $brawlerId): array
```

Return format
-------------

[](#return-format)

The return format for each function matches the ones on [BrawlStars Api documentation](https://developer.brawlstars.com/#/documentation).

Exceptions
----------

[](#exceptions)

All functions throw exceptions: `ClientException` (wrong client configuration, timeout reached etc) and `ResponseException` (bad api key, wrong player tag, etc).

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4bcd056ece60bcefeef5014466799f5227b05a32f91f09e92ad18504ada01be6?d=identicon)[dncusmir](/maintainers/dncusmir)

---

Top Contributors

[![dncusmir](https://avatars.githubusercontent.com/u/53871347?v=4)](https://github.com/dncusmir "dncusmir (16 commits)")

---

Tags

apiphppsr-17psr-18psr-7

### Embed Badge

![Health badge](/badges/dncusmir-bsapi/health.svg)

```
[![Health](https://phpackages.com/badges/dncusmir-bsapi/health.svg)](https://phpackages.com/packages/dncusmir-bsapi)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
