PHPackages                             toniperic/php-clash-of-clans - 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. toniperic/php-clash-of-clans

AbandonedArchivedLibrary

toniperic/php-clash-of-clans
============================

PHP wrapper for querying the Supercell Clash of Clans API

3866511[1 PRs](https://github.com/toniperic/php-clash-of-clans/pulls)PHP

Since Mar 18Pushed 9y ago9 watchersCompare

[ Source](https://github.com/toniperic/php-clash-of-clans)[ Packagist](https://packagist.org/packages/toniperic/php-clash-of-clans)[ RSS](/packages/toniperic-php-clash-of-clans/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Clash of Clans API
==================

[](#clash-of-clans-api)

[![Build Status](https://camo.githubusercontent.com/1638d088ee775a2c51895d8bec4f90ce9087a9c8b7c8da22d9b9aeb427a59bab/68747470733a2f2f7472617669732d63692e6f72672f746f6e6970657269632f7068702d636c6173682d6f662d636c616e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/toniperic/php-clash-of-clans)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5a6e79b539bbbb593262cfbe36d625d5891caa8b4923d0d54448e6d5f2bfd7e6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746f6e6970657269632f7068702d636c6173682d6f662d636c616e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/toniperic/php-clash-of-clans/?branch=master)

Easily query Supercell's API for Clash of Clans data! This package uses official API. For more information, please visit

**This package is tested and working on PHP 5.5 and greater, including PHP 7.0!**

Do note that the API might change at any given moment, as there are no stable releases yet.

Requirements
------------

[](#requirements)

For using this package, you need to obtain an API key at

Installation
------------

[](#installation)

### Using Composer

[](#using-composer)

```
composer require toniperic/php-clash-of-clans=dev-master

```

Usage
-----

[](#usage)

When instantiating Client, you have to provide your API key:

```
$client = new Client('API_KEY_HERE');
```

Clans
-----

[](#clans)

Refers to `/clans` endpoint from the official docs.

You can use any of the parameters specified in the official docs as keys, and the values as parameter values, likewise

```
$client->getClans(['name' => 'Foo', 'minMembers' => 30]); // returns array of Clan objects
```

Tip: if you are only searching by clan name, you don't have to specify the array as parameter but just a simple string:

```
$client->getClans('Foo'); // returns array of Clan objects
```

For all available parameters, please browse through the [offical docs](https://developer.clashofclans.com).

Get specific clan by tag
------------------------

[](#get-specific-clan-by-tag)

Refers to `/clans/{clanTag}` endpoint from the official docs.

It's very easy to use:

```
$clan = $client->getClan('#2VP0J0VV'); // returns Clan object

$clan->name(); // "Hattrickers"
$clan->level(); // 8
$clan->warWins(); // 168
```

For more available methods, visit `ClashOfClans\Api\Clan\Clan` class.

### Getting leader info

[](#getting-leader-info)

```
$leader = $clan->memberList()->leader(); // returns Player
$leader->name(); // "VanSilent"
$leader->donations(); // 3451
$leader->expLevel(); // 118
$leader->trophies(); // 2548
```

For more available methods, visit `ClashOfClans\Api\Clan\Player` class.

### Getting co-leaders and elders

[](#getting-co-leaders-and-elders)

```
$coLeaders = $clan->memberList()->coLeaders(); // array of Player objects
$elders = $clan->memberList()->elders(); // array of Player objects
```

Leagues
-------

[](#leagues)

Refers to `/leagues` endpoint from the official docs.

```
$leagues = $client->getLeagues(); // returns array of League objects

$leagues[0]->id(); // 29000001
$leagues[0]->name(); // Bronze League III
```

Locations
---------

[](#locations)

Refers to `/locations` endpoint from the official docs.

Getting all available locations is pretty easy:

```
$client->getLocations(); // returns array of Location objects
```

### Get specific location by ID

[](#get-specific-location-by-id)

Refers to `/locations/{locationId}` endpoint from the official docs.

```
$location = $client->getLocation(32000066); // returns Location object

$location->name(); // Croatia
$location->countryCode(); // HR
$location->isCountry(); // true
```

### Get rankings for specific location

[](#get-rankings-for-specific-location)

Refers to `/locations/{locationId}/rankings/{rankingId}` endpoint from the official docs.

```
$rankings = $client->getRankingsForLocation($locationId, 'clans'); // returns array of Clan objects

// top clan
$rankings[0]->name(); // Foobar
$rankings[0]->trophies(); // 47846

```

Instead of 'clans', as the second parameter you can also pass string `players` which will return array of Player objects.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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/fac258981042360c249a80a8f6d33fed54802c00f07307eff2f9088a8843ac9a?d=identicon)[toniperic](/maintainers/toniperic)

---

Top Contributors

[![azacchino](https://avatars.githubusercontent.com/u/10451904?v=4)](https://github.com/azacchino "azacchino (1 commits)")[![BerkanYildiz](https://avatars.githubusercontent.com/u/15068742?v=4)](https://github.com/BerkanYildiz "BerkanYildiz (1 commits)")[![chgasparoto](https://avatars.githubusercontent.com/u/2037349?v=4)](https://github.com/chgasparoto "chgasparoto (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![toniperic](https://avatars.githubusercontent.com/u/5714104?v=4)](https://github.com/toniperic "toniperic (1 commits)")

### Embed Badge

![Health badge](/badges/toniperic-php-clash-of-clans/health.svg)

```
[![Health](https://phpackages.com/badges/toniperic-php-clash-of-clans/health.svg)](https://phpackages.com/packages/toniperic-php-clash-of-clans)
```

PHPackages © 2026

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