This library gives you access to the APIs of Battle.net based on the Retrofit library.
Some of the APIs require Oauth2, so for getting a valid access token you can use:
OauthActivity.startActivity()
Check out the sampleapp module for the complete flow!
- CAREER PROFILE /D3/PROFILE/:BATTLETAG/
- HERO PROFILE /D3/PROFILE/:BATTLETAG/HERO/:ID
- ITEM DATA /D3/DATA/ITEM/:DATA
- USER /ACCOUNT/USER
- USER /ACCOUNT/USER
- SEASON INDEX /DATA/D3/SEASON/
- SEASON /DATA/D3/SEASON/:ID
- SEASON LEADERBOARD /DATA/D3/SEASON/:ID/LEADERBOARD/:LEADERBOARD
- ERA INDEX /DATA/D3/ERA/
- ERA /DATA/D3/ERA/:ID
- ERA LEADERBOARD /DATA/D3/ERA/:ID/LEADERBOARD/:LEADERBOARD
For every implemented entry point you get a class of the same name to access the API.
Example: to call the CareerProfile of the D3 Community API:
BattleTag battleTag = new BattleTag(USERNAME, NUMBER);
CareerProfile careerProfile = D3CommunityAPI.getCareerProfile(context, Region.EU, battleTag, Locale.ENGLISH);
Every function will have two ways to be called:
- Synchronous (no callback at the end of the function)
- Asynchronous (with a retrofit callback at the end)
Example for the D3 Community API:
// Synchronous
public static CareerProfile getCareerProfile(@NonNull Context context, @NonNull Region region, @NonNull BattleTag battleTag, @NonNull Locale locale);
// Asynchronous
public static void getCareerProfile(@NonNull Context context, @NonNull Region region, @NonNull BattleTag battleTag, @NonNull Locale locale, @NonNull Callback<CareerProfile> callback);
To set up your own API KEY and API SECRET, override the next values in your strings.xml:
<string name="battlenet_lib_api_key">YOUR-API-KEY-HERE</string>
<string name="battlenet_lib_api_secret">YOUR-API-SECRETKEY-HERE</string>