PHPackages                             xgerhard/destiny-api-wrapper - 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. xgerhard/destiny-api-wrapper

ActivePackage[API Development](/categories/api)

xgerhard/destiny-api-wrapper
============================

PHP wrapper for Destiny 2 API

0.0.1(6y ago)114mitPHPPHP &gt;=5.3.0

Since Oct 23Pushed 6y agoCompare

[ Source](https://github.com/xgerhard/destiny-api-wrapper)[ Packagist](https://packagist.org/packages/xgerhard/destiny-api-wrapper)[ RSS](/packages/xgerhard-destiny-api-wrapper/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Destiny2 PHP API wrapper
========================

[](#destiny2-php-api-wrapper)

A PHP Client/API wrapper for the Destiny 2 API

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

[](#installation)

Run the following command:

```
composer require xgerhard/destiny-api-wrapper
```

Usage
-----

[](#usage)

### DestinyClient

[](#destinyclient)

Get your API-key here:

```
$oDestiny = new Destiny\Client('Bungie-API-key-here');
```

**Searching for a player**

```
use Destiny\Client;
use Destiny\Exceptions\PlayerNotFoundException;

try
{
    $oDestiny = new Destiny\Client('Bungie-API-key-here');
    $oPlayer = $oDestiny->searchPlayer('xgerhard');

    echo $oPlayer->membershipId; // 4611686018467322796
    echo $oPlayer->membershipType; // 4
    echo $oPlayer->displayName; // xgerhard#21555

    // There are multiple ways of searching a player
    // Search on all platforms by player username
    $oPlayer = $oDestiny->searchPlayer('xgerhard');

    // Search on specific platform by player username (1 = xbox, 2 = ps, 3 = pc)
    $oPlayer = $oDestiny->searchPlayer('xgerhard', 1);

    // Search by BungieNet uniqueName
    // Set an unique ID here: https://www.bungie.net/en/Profile/Settings/?category=AboutMe
    // Link the platforms you play on here: https://www.bungie.net/en/Profile/Settings/?category=Accounts
    // By using profiles->getCurrent you will receive the platform you played on most recently
    $oPlayer = $oDestiny->searchUser('xgerhard')->profiles->getCurrent();

    // Combination of searchPlayer & searchUser
    // Search by platform username first, if no results search by uniqueName on BungieNet
    $oPlayer = $oDestiny->searchPlayerUser('xgerhard');

    // Search on specific platform only, if no results search by uniqueName on BungieNet
    $oPlayer = $oDestiny->searchPlayerUser('xgerhard', 1);

    // $oPlayer = Destiny\Player
}
catch(PlayerNotFoundException $e)
{
    // If no players could be found
    echo $e->getMessage();
}
```

**loadPlayer**

If you store the player details in for example a database, you can load the `Destiny\Player` object by providing (at least) the player `membershipType` and `membershipId`.

```
use Destiny\Client;
use Destiny\Exceptions\InvalidPlayerParametersException;

try
{
    $oDestiny = new Destiny\Client('Bungie-API-key-here');
    $oPlayer = $oDestiny->loadPlayer([
        'membershipType' => 4,
        'membershipId' => '4611686018467322796',
        'displayName' => 'xgerhard#21555'
    ]);

    // $oPlayer = Destiny\Player
}
catch(InvalidPlayerParametersException $e)
{
    // If required player data is missing
    echo $e->getMessage();
}
```

### Destiny\\Player

[](#destinyplayer)

#### CharacterCollection

[](#charactercollection)

The player characters are stored in a character collection. This collection can be queried to get the character data.

**getAll()**

Returns all characters

```
$oPlayer = $oDestiny->searchPlayer('xgerhard');
$aCharacters = $oPlayer->characters->getAll();

/*
Array
(
    [2305843009301405871] => Destiny\Character Object
        (
            [membershipId] => 4611686018467322796
            [membershipType] => 4
            [characterId] => 2305843009301405871
            ....
        )

    [2305843009301408262] => Destiny\Character Object
        (
            [membershipId] => 4611686018467322796
            [membershipType] => 4
            [characterId] => 2305843009301408262
            ....
        )
)
*/
```

**getCurrent()**

Returns the current (last played) character

```
$oPlayer = $oDestiny->searchPlayer('xgerhard');
$aCharacters = $oPlayer->characters->getCurrent();

/*
Destiny\Character Object
(
    [membershipId] => 4611686018467322796
    [membershipType] => 4
    [characterId] => 2305843009301408262
    [dateLastPlayed] => 2019-06-22T15:43:44Z
    [minutesPlayedThisSession] => 30
    ....
)
*/
```

**fetch()**

To fetch characters a list of components needs to be provided, by default it will load and fetch them all (inventory, progression, activities etc.). To reduce the size of the `Destiny\CharacterCollection` object and probably speed up the code, you can manually provide these components.

Available components: [https://bungie-net.github.io/multi/schema\_Destiny-DestinyComponentType.html#schema\_Destiny-DestinyComponentType](https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType)

When `fetch()` is finished it will return all characters (function `getAll()`).

```
$oPlayer = $oDestiny->searchPlayer('xgerhard');

// If I only need the characters data (for example: characterId, dateLastPlayed)
$aCharacters = $oPlayer->characters->fetch([200]);

// If I want to check characters inventory
$oPlayer->characters->fetch([
    200, // Character basic info
    205, // Character equipment
    300, // Item instances
    305 // Item sockets
]);

// Get primary weapon for all characters
foreach($oPlayer->characters->getAll() as $oCharacter)
{
    $oPrimary = $oCharacter->inventory->get('primary');
}

// Or just for the current character
$oPlayer->characters->getCurrent()->inventory->get('primary');
```

### Destiny\\Character

[](#destinycharacter)

#### InventoryCollection

[](#inventorycollection)

Characters have an inventory property, use the 'get' function to request inventory/equipment items. The first parameter is the identifier of the item, the second parameter is a boolean to include perk details.

```
$oPlayer = $oDestiny->searchUser('xgerhard')->profiles->getCurrent();

// Fetch character data, including equipment, item instances, item sockets
$oCurrentCharacter = $oPlayer->characters->getCurrent([200, 205, 300, 305]);

$oPrimary = $oCurrentCharacter->inventory->get('primary', true));

/*
Destiny\EquipmentItem Object
(
    [itemInstanceId] => 6917529067574353832
    [itemHash] => 347366834
    [name] => Ace of Spades
    [bucketTypeHash] => 1498876634
    [light] => 750
    [quantity] => 1
    [perks] => Array
        (
            [0] => Memento Mori
            [1] => Corkscrew Rifling
            [2] => High-Caliber Rounds
            [3] => Firefly
            [4] => Smooth Grip
            [5] => Last Hand
            [6] => Empty Catalyst Socket
        )
)
*/

// $oPrimary = Destiny\EquipmentItem
```

The first parameter can be an array to request multiple items.

```
$aItems = $oCurrentCharacter->inventory->get(['helmet', 'chest']);

/*
Array
(
    [helmet] => Destiny\EquipmentItem Object
        (
            [itemInstanceId] => 6917529088474208321
            [itemHash] => 2124666626
            [name] => Wing Discipline
            [bucketTypeHash] => 3448274439
            [light] => 750
            [quantity] => 1
        )
    [chest] => Destiny\EquipmentItem Object
        (
            [itemInstanceId] => 6917529085963882227
            [itemHash] => 2562470699
            [name] => Tangled Web Plate
            [bucketTypeHash] => 14239492
            [light] => 750
            [quantity] => 1
        )
)
*/
```

### Manifest

[](#manifest)

The manifest is a database containing information about items/activities etc. you can query the database by using the hash of the item.

**getManifest()**

```
$oManifest = $oDestiny->getManifest();
$oItem = $oManifest->getDefinition('InventoryItem', 3588934839);

/*
stdClass Object
(
    [displayProperties] => stdClass Object
        (
            [description] => "Wings flutter. Beauty distracts. Poison injects. The butterfly's curse extends to your enemies. A short life, shortened further by your hand." —Ada-1
            [name] => Le Monarque
            [icon] => /common/destiny2_content/icons/4b66c583e88a316cc3b0cf017a3e9a7b.jpg
            [hasIcon] => 1
        )
    ....
*/

// $oManifest = Destiny\Manifest
```

**updateManifest()**

To keep the database up to date, with for example new items, you can use this function to check for updates. If the response of the function is true, the manifest is either updated or already was up to date.

```
var_dump($oDestiny->updateManifest());
/*
bool(true)
*/
```

### License

[](#license)

This Destiny API wrapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec7ded9a1684bbc46d8b62eb52bcc0edac1d2185a6bf73df99ef2b3e6dd77539?d=identicon)[xgerhard](/maintainers/xgerhard)

---

Top Contributors

[![xgerhard](https://avatars.githubusercontent.com/u/13732765?v=4)](https://github.com/xgerhard "xgerhard (18 commits)")

### Embed Badge

![Health badge](/badges/xgerhard-destiny-api-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/xgerhard-destiny-api-wrapper/health.svg)](https://phpackages.com/packages/xgerhard-destiny-api-wrapper)
```

###  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)
