Giter Club home page Giter Club logo

battlenet's Introduction

BattleNet

Build Status Go Report Card GoDoc

A Golang library for retrieving data from Blizzard's Battle.net API.

Requires Go 1.12 or higher.

Install

$ go get github.com/munsy/battlenet

Example

package main

import (
        "flag"
        "fmt"
        "net/http"
        "time"

        "github.com/munsy/battlenet"
)

var tokenFlag = flag.String("t", "", "Battle.net API token (required).")

func main() {
        flag.Parse()

        if *tokenFlag == "" {
                fmt.Println("No token provided.")
                return
        }

        // Create settings for the client. This is not required, but
        // is necessary for non-default settings.
        settings := &battlenet.Settings{
                Client: &http.Client{Timeout: (10 * time.Second)},
                Locale: battlenet.Locale.AmericanEnglish,
                Region: battlenet.Regions.US,
        }

        // Create a new client for accessing the Battle.net Account API.
        // There are also clients for Diablo III, Starcraft II, and WoW.
        client, err := battlenet.AccountClient(settings, *tokenFlag)

        if nil != err {
                panic(err)
        }

        // Make a request. Each method corresponds to a Battle.net endpoint.
        response, err := client.BattleID()

        if nil != err {
                panic(err)
        }

        // Get the underlying data. You can also see the endpoint that was called,
        // as well as your quota usage.
        bid := response.Data

        fmt.Printf("ID: %d\n", bid.ID)
        fmt.Printf("BattleTag: %s\n", bid.BattleTag)
}

$ go build -o account.exe
$ ./account.exe -t $YOUR_API_TOKEN_HERE
ID: 12345654321
BattleTag: Munsy#78910

Additional examples for Diablo III, Starcraft II, and World of Warcraft can be found in the examples package.

Bug Reporting/Fixing

Please submit all bug reports as issues. This section will be updated in the future with a more comprehensive guide to submitting helpful bug reports and/or bug fixes.

Contributing

  • Testing is mostly what is needed right now
  • Submit contributions as pull requests

Licensing

GoBattleNet is licensed under the MIT License. See LICENSE for the full license text.

battlenet's People

Contributors

munsy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

tutuchan bsmr

battlenet's Issues

WoW Game Data API

Add a client that handles the WoW Game Data API (distinct endpoints from the ones in the already-available wow client).

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.