-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started
First, you will need to create an application on bungie.net to get your API key. https://www.bungie.net/en/Application Then you can use that API key in the code below.
The core class is called DestinyAPI, this is where you set your API key, and optionally: the client id, secret, and OAuth code.
DestinyAPI api = new DestinyAPI().setApiKey("YOUR_API_KEY_HERE").setClientID("CLIENT_ID").setClientSecret("CLIENT_SECRET").setOauthCode("OAUTH_CODE");
DestinyAPI has to be initialized prior to any of the features inside the API that make requests to Bungie.net. The Client id, client secret, and OAuth code only need to be used whenever OAuth is in play, so to start you don't need to bother with them.
Let's say we wanted to get all users with the name dec4234
for(BungieUser bu : DestinyAPI.getValidUsers("dec4234")) {
System.out.println(bu.getDisplayName());
}
It is good practice to check if the user is valid prior to getting information about them, as users can have an account on bungie.net without actually having any destiny profile information to get.
How about all of the members of a specific clan?
for(BungieUser bu : da.getClan("Heavenly Mayhem").getMembers()) {
if(bu.isValidUser()) {
System.out.println(bu.getDisplayName() + " " + bu.getDaysSinceLastPlayed());
}
}
Retrieving large lists of users such as members of a clan can be quite an intensive action, so use it at your own risk.