Giter Site home page Giter Site logo

vmpay / battle_net_dart Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 108 KB

Dart wrapper client for Battle.Net API. You can easily communicate with BattleNet service inside your Flutter/Dart application.

Home Page: https://pub.dev/packages/battle_net

License: MIT License

Dart 100.00%
battle-net battle-net-api battlenet battlenet-api blizzard blizzard-api flutter-package

battle_net_dart's Introduction

Dart wrapper client for Battle.Net API

workflow GitHub Pub package publisher Pub Points

You can easily communicate with BattleNet service inside your Flutter/Dart application.

Available Features

  • 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.

Getting started

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';

Usage

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();

Get Token Index

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);

Connected Realm

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);

Connected Realm Search

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,
);

Additional information

Available BattleNet regions

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

Localization

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

Copyright & License

This project follows MIT license.

battle_net_dart's People

Contributors

vmpay avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.