Getting Started

## API Key

Sign in to bungie.net and visit the API registration portal. If you haven't already verified the email address associated with your bungie.net account, now is the time to do so. Make sure to check your spam or junk mail folder if the email verification link doesn't appear.

## Query the Platform

To fetch data from the platform, it's as simple as sending a HTTP request to it along with your API key and making use of the response, which is JSON-encoded.

### **PHP**

```
<?php
 $apiKey = 'YOUR-API-KEY-HERE';

 $ch = curl\_init();
 curl\_setopt($ch, CURLOPT\_URL, 'https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/');
 curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);
 curl\_setopt($ch, CURLOPT\_HTTPHEADER, array('X-API-Key: ' . $apiKey));

 $json = json\_decode(curl\_exec($ch));
 echo $json->Response->data->inventoryItem->itemName; //Gjallarhorn

```

### **JavaScript**

```
var apiKey = "YOUR-API-KEY-HERE";

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/", true);
xhr.setRequestHeader("X-API-Key", apiKey);

xhr.onreadystatechange = function(){
 if(this.readyState === 4 && this.status === 200){
 var json = JSON.parse(this.responseText);
 console.log(json.Response.data.inventoryItem.itemName); //Gjallarhorn
 }
}

xhr.send();

```

### **JavaScript (with jQuery)**

```
var apiKey = "YOUR-API-KEY-HERE";

$.ajax({
 url: "https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/",
 headers: {
 "X-API-Key": apiKey
 }
}).done(function(json){
 console.log(json.Response.data.inventoryItem.itemName); //Gjallarhorn
});

```

### **C# (Blocking)**

```
// Uses JSON.NET - http://www.nuget.org/packages/Newtonsoft.Json
using (var client = new HttpClient())
{
 client.DefaultRequestHeaders.Add("X-API-Key", "YOUR-API-KEY-HERE");

 var response = client.GetAsync("https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/").Result;
 var content = response.Content.ReadAsStringAsync().Result;
 dynamic item = Newtonsoft.Json.JsonConvert.DeserializeObject(content);

 Console.WriteLine(item.Response.data.inventoryItem.itemName); //Gjallarhorn
}

```

### **C# (Non-Blocking)**

```
// Uses JSON.NET - http://www.nuget.org/packages/Newtonsoft.Json
using (var client = new HttpClient())
{
 client.DefaultRequestHeaders.Add("X-API-Key", "YOUR-API-KEY-HERE");

 var response = await client.GetAsync("https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/");
 var content = await response.Content.ReadAsStringAsync();
 dynamic item = Newtonsoft.Json.JsonConvert.DeserializeObject(content);

 Console.WriteLine(item.Response.data.inventoryItem.itemName); //Gjallarhorn
}

```

### **Java**

```
 String apiKey = "YOUR-API-KEY-HERE";

 // Endpoint for Gjallarhorn
 String url = "https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/";

 URL obj = new URL(url);
 HttpURLConnection con = (HttpURLConnection) obj.openConnection();

 con.setRequestMethod("GET");

 // Set header
 con.setRequestProperty("X-API-KEY", apiKey);

 int responseCode = con.getResponseCode();
 System.out.println("\nSending 'GET' request to Bungie.Net : " + url);
 System.out.println("Response Code : " + responseCode);

 BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
 String inputLine;
 String response = "";

 while ((inputLine = in.readLine()) != null) {
 response += inputLine;
 }

 in.close();

 // Uses Gson - https://github.com/google/gson
 JsonParser parser = new JsonParser();
 JsonObject json = (JsonObject) parser.parse(response);

 System.out.println();
 System.out.println(json.getAsJsonObject("Response").getAsJsonObject("data").getAsJsonObject("inventoryItem").get("itemName"));
 //Gjallarhorn

```

### **Python**

```
import requests

#dictionary to hold extra headers
HEADERS = {"X-API-Key":'YOUR\_API\_KEY\_HERE'}

#make request for Gjallarhorn
r = requests.get("https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/", headers=HEADERS);

#convert the json object we received into a Python dictionary object
#and print the name of the item
inventoryItem = r.json()
print(inventoryItem['Response']['data']['inventoryItem']['itemName'])

#Gjallarhorn

```

# install.packages(c("magrittr", "httr"))
library(magrittr)
library(httr)

api\_key <- "YOUR\_API\_KEY\_HERE"

r <- GET("https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/",
 add\_headers("X-API-Key" = api\_key)
) %>% content("parsed")

r$Response$data$inventoryItem$itemName

### **PowerShell**

```
$apikey = 'YOUR-API-KEY-HERE'
$uri = 'https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/'

#Hashtable to hold headers
$headers = @{}
$headers.add('X-API-KEY', $apikey)

#Best practice is to use Invoke-WebRequest, cURL can be used as an alias.
$request = Invoke-WebRequest -Headers $headers -URI $uri -Method Get

#Convert HtmlWebRequestObject to PSCustomObject
$results = ConvertFrom-Json $request.Content

#Gjallarhorn
echo $results.response.data.inventoryitem.itemname

```

### **Perl**

```
use REST::Client;
use JSON;

# Add headers to the connection and set host
$client->addHeader("X-API-KEY", "YOUR-API-KEY-HERE");

# Perform HTTP GET on this URI
$client->GET('https://www.bungie.net/Platform/Destiny/Manifest/InventoryItem/1274330687/');

# Convert JSON response to Perl data structure
my $response = from\_json($client->responseContent());

# Gjallarhorn
print $response->{'Response'}->{'data'}->{'inventoryItem'}->{'itemName'};

```

## Where to Next?

Read more about the API.

See a list of endpoints.