Dart wrapper client for Battle.Net API
You can easily communicate with BattleNet service inside your Flutter/Dart application.
- User Authentication
- Authorization Request - The authorization request is the first part of the authorization code flow, OAuth's authentication flow for performing API requests on behalf of a user.
- Access Token Request - The access token request is the second part of the authorization code flow.
- User Info - Returns basic information about the user associated with the current bearer token.
- Application Authentication
- Post Client Credentials - Access Token Request. This is the only request necessary for the client credential flow, OAuth's authentication flow intended for application servers.
- Token Validation
- Post Token Validation - Verifies that a given bearer token is valid and retrieves metadata about the token, including the client_id used to create the token, expiration timestamp, and scopes granted to the token.
- WoW Token API
- Get Token Index - Returns the WoW Token index.
- Connected Realm API
- Connected Realm - Returns a connected realm by ID.
- Connected Realms Search - Performs a search of connected realms.
Add to your pubspec.yaml the latest version of the library
dependencies:
battle_net: ^<latest_version>
Now in your Dart code, you can use:
import 'package:battle_net/battle_net.dart';
Provide client id and client secret, which can be found in your developer account on BattleNet.
final BattleNet battleNet =
BattleNet(clientId: 'clientId', clientSecret: 'clientSecret');
Now you can fetch data from BattleNet services.
final ClientCredentialsResponse clientCredentialsResponse =
await battleNet.postClientCredentials();
You can fetch Retail WoW Token price in EU region using this example.
final TokenIndex tokenIndex = await battleNet.getTokenIndex(
accessToken: clientCredentialsResponse.accessToken,
region: BattleNetRegion.eu,
namespace: BattleNetNamespace.dynamic,
locale: BattleNetLocale.enGB);
You can also fetch connected realm details by id using the example below:
const int connectedRealmId = 1301;
final ConnectedRealmResponse connectedRealm = await battleNet.getConnectedRealm(
accessToken: clientCredentialsResponse.accessToken,
region: BattleNetRegion.eu,
namespace: BattleNetNamespace.dynamic,
id: connectedRealmId);
You can also fetch connected realm details by id using the example below:
final ConnectedRealmSearchResponse result =
await battleNet.getConnectedRealmSearch(
accessToken: clientCredentialsResponse.accessToken,
region: BattleNetRegion.eu,
namespace: BattleNetNamespace.dynamic,
statusType: ServerStatus.UP,
realmsTimezone: RealmTimezone.EUROPE_PARIS,
hasQueue: false,
populationType: PopulationType.FULL,
realmsIsTournament: false,
);
API data is limited to specific regions. BattleNet region is the region of the data to retrieve. Locale support is limited to locations supported on Blizzard community game sites.
Region | Data |
---|---|
US | Battle.net, WoW, D3, SC2 |
EU | Battle.net, WoW, D3, SC2 |
KR | Battle.net, WoW, D3, SC2 |
TW | Battle.net, WoW, D3, SC2 |
For example,
BattleNetRegion.eu
All available API resources provide localized strings using BattleNetLocale parameter. Supported locales vary from region to region and align with those supported on Blizzard community sites.
Region | Host | Available Locales |
---|---|---|
North America | https://us.api.blizzard.com/ | en_US, es_MX, pt_BR |
Europe | https://eu.api.blizzard.com/ | en_GB, es_ES, fr_FR, ru_RU, de_DE, pt_PT, it_IT |
Korea | https://kr.api.blizzard.com/ | ko_KR |
Taiwan | https://tw.api.blizzard.com/ | zh_TW |
For example,
BattleNetLocale.enGB
This project follows MIT license.