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
R[]
# These commonly-used packages can be installed from CRAN with:
# 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
# [1] "Gjallarhorn"
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;
# Create the connection
my $client = REST::Client->new();
# 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.