PHPackages                             kshabazz/battlenet-d3 - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. kshabazz/battlenet-d3

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

kshabazz/battlenet-d3
=====================

An API (written in PHP) for accessing Battle.net Diablo 3 REST service.

1.3.0(10y ago)0322MITPHPPHP ^5.4

Since Nov 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/b01/d3)[ Packagist](https://packagist.org/packages/kshabazz/battlenet-d3)[ RSS](/packages/kshabazz-battlenet-d3/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (15)Used By (0)

Description
===========

[](#description)

A library, written in PHP, for accessing Battle.net Diablo 3 REST service.

This API provides a client for accessing Diablo 3 profiles, heroes, and items; which require an API key and battle-tag. There are also a few object models for: Profile, Hero, Item, and Skill (Active and Passive).

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

[](#requirements)

- PHP 5.4 - 5.6

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

[](#installation)

Add to your composer.json

```
"require": {
    "kshabazz/battlenet-d3": "^1.2"
}
```

Summary
-------

[](#summary)

You can either get the raw JSON data returned from Battle.Net or use some simple models that this library provides.

### Examples for Retrieving data (as JSON) from Battle.net

[](#examples-for-retrieving-data-as-json-from-battlenet)

```
use
    \Kshabazz\Slib\HttpClient,
    \Kshabazz\BattleNet\D3\Connections\Http as D3_Http,
    \Kshabazz\BattleNet\D3\Profile as D3_Profile;

// An API key and Battle.Net Tag are required for all request.
$apiKey       = 'apiKeyFromMashery';
$battleNetTag = 'msuBREAKER#1374';
$heroId       = 3955832;
$itemHash     = 'item/CioI4YeygAgSBwgEFcgYShEdhBF1FR2dbLMUHape7nUwDTiTA0'
              . 'AAUApgkwMYkOPQlAI';

// Get an HTTP client, currently only my custom HTTP client works.
$httpClient = new HttpClient();

// Initialize a battle.net HTTP client.
$d3Client = new D3_Http( $apiKey, $battleNetTag, $httpClient );

// Get the profile for the Battle.net tag (this will be the raw JSON).
$profileJson = $d3Client->getProfile();

// Get the Hero (again, this will be the raw JSON).
$heroJson = $d3Client->getHero( $heroId );

// Get an item (and again, this will be the raw JSON).
// Get the item from Battle.net.
$itemJson = $d3Client->getItem( $itemHash );

var_dump(
    "Profile:" . $profileJson,
    "\nHero:" . $heroJson,
    "\nItem" . $itemJson
);
```

### Examples Using Models (Profile/Hero/Item)

[](#examples-using-models-profileheroitem)

The following examples show how to use the models this library provides.

```
