PHPackages                             berskde/coc-api-php - 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. berskde/coc-api-php

ActiveLibrary[API Development](/categories/api)

berskde/coc-api-php
===================

PHP wrapper for querying the Supercell Clash of Clans API

v0.1.0(10mo ago)00MITPHPPHP &gt;=5.4

Since Jul 7Pushed 10mo agoCompare

[ Source](https://github.com/berskde/coc-api-php)[ Packagist](https://packagist.org/packages/berskde/coc-api-php)[ RSS](/packages/berskde-coc-api-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

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

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

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 berskde/coc-api-php

```

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

22

—

LowBetter than 22% of packages

Maintenance54

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 54.5% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

316d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b8bb1bf64b7403dd01053ba30dd58e6286b66c81af8d7c323f9218464a87056?d=identicon)[berskde](/maintainers/berskde)

---

Top Contributors

[![berskde](https://avatars.githubusercontent.com/u/58986361?v=4)](https://github.com/berskde "berskde (6 commits)")[![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)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/berskde-coc-api-php/health.svg)

```
[![Health](https://phpackages.com/badges/berskde-coc-api-php/health.svg)](https://phpackages.com/packages/berskde-coc-api-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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