Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - FuzzyStatic/blizzard: Go client library for Blizzard API data · GitHub
Skip to content

Latest commit

History

276 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

blizzard

Go ReferenceGo Report Card

This is a Go client library for gathering Blizzard API reference data

Table of Contents

Getting Started

First, download the Blizzard library:

go get github.com/FuzzyStatic/blizzard/v3

Start using the library by initiating a new Blizzard config structure for your desired region and locale (client_id and client_secret can be acquired through your developer account at https://develop.battle.net/) and requesting an access token:

usBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.US,
Locale: blizzard.EnUS,
})
err=usBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}
euBlizzClient, err:=blizzard.NewClient(blizzard.Config{
ClientID: "my_client_id",
ClientSecret: "my_client_secret",
HTTPClient: http.DefaultClient,
Region: blizzard.EU,
Locale: blizzard.EnGB,
})
err=euBlizzClient.AccessTokenRequest(ctx)
iferr!=nil {
fmt.Println(err)
}

Fetching Diablo 3 Data

You can use the functions prefixed with "D3" to acquire Diablo 3 information. For example, you can get information about the current D3 hardcore necromancer leaderboards:

dat, _, err:=usBlizzClient.D3SeasonLeaderboardHardcoreNecromancer(ctx, 15)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Hearthstone Data

You can use the functions prefixed with "HS" to acquire Hearthstone information. For example, you can get information about all the Hearthstone cards:

dat, _, err:=usBlizzClient.HSCardsAll(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching Overwatch League Data

You can use the functions prefixed with "OWL" to acquire Overwatch League information. For example, you can get information about the Overwatch League:

dat, _, err:=usBlizzClient.OWLSummaryData(ctx)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching StarCraft 2 Data

You can use the functions prefixed with "SC2" to acquire StarCraft 2 information. For example, you can get information about the current SC2 grandmaster ladder:

dat, _, err:=usBlizzClient.SC2LadderGrandmaster(ctx, blizzard.EU)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Data

You can use the functions prefixed with "WoW" to acquire World of Warcraft information. For example, you can get information about your WoW character profile:

dat, _, err:=usBlizzClient.WoWCharacterProfileSummary(ctx, "illidan", "wildz")
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or get information about specific spells:

dat, _, err:=usBlizzClient.WoWSpell(ctx, 17086)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

or the PvP leaderboards:

dat, _, err:=usBlizzClient.WoWCharacterPvPBracketStatistics(ctx, wowp.Bracket3v3)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Fetching World of Warcraft Classic Data

You can use the functions prefixed with "ClassicWoW" to acquire World of Warcraft Classic information. Blizzard provides data for three Classic versions: Era (the original Classic experience), Anniversary (the enhanced Classic edition), and Progression (the current Classic progression).

For example, you can get information about WoW Classic Era creature data:

dat, _, err:=usBlizzClient.ClassicWoWEraCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Anniversary creature data:

dat, _, err:=usBlizzClient.ClassicWoWAnniversaryCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Or get information about WoW Classic Progression creature data:

dat, _, err:=usBlizzClient.ClassicWoWCreature(ctx, 30)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Authorization for User Data

To use the UserInfoHeader or WoWUserCharacters functions to acquire data about other users (and not your own), you must use the OAuth2 redirect method to get an authorized token. This is useful for building websites that display more personal or individualized data. The following code snippet is an example on how to acquire authorized tokens for other users. A working example can be found in the examples/authCodeFlow directory. Before the redirect URI will work, you will have to add it to your client settings at https://develop.battle.net/access:

package main
import (
"context""encoding/json""fmt""log""net/http""github.com/FuzzyStatic/blizzard/v3""github.com/FuzzyStatic/blizzard/v3/oauth""golang.org/x/oauth2"
)
var (
cfg oauth2.ConfigusBlizzClient*blizzard.Client
)
// HomepagefuncHomePage(w http.ResponseWriter, r*http.Request) {
fmt.Println("Homepage Hit!")
u:=cfg.AuthCodeURL("my_random_state")
http.Redirect(w, r, u, http.StatusFound)
}
// AuthorizefuncAuthorize(w http.ResponseWriter, r*http.Request) {
err:=r.ParseForm()
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
state:=r.Form.Get("state")
ifstate!="my_random_state" {
http.Error(w, "State invalid", http.StatusBadRequest)
return
}
code:=r.Form.Get("code")
ifcode=="" {
http.Error(w, "Code not found", http.StatusBadRequest)
return
}
token, err:=cfg.Exchange(context.Background(), code)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
e:=json.NewEncoder(w)
e.SetIndent("", " ")
err=e.Encode(*token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
dat1, _, err:=usBlizzClient.UserInfoHeader(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat1)
dat2, _, err:=usBlizzClient.WoWUserCharacters(token)
iferr!=nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", dat2)
}
funcmain() {
blizz=blizzard.NewClient("client_id", "client_secret", blizzard.US, blizzard.EnUS)
cfg=usBlizzClient.AuthorizeConfig("http://<mydomain>:9094/oauth2", oauth.ProfileD3, oauth.ProfileSC2, oauth.ProfileWoW)
http.HandleFunc("/", HomePage)
http.HandleFunc("/oauth2", Authorize)
// We start up our Client on port 9094log.Println("Client is running at 9094 port.")
log.Fatal(http.ListenAndServe(":9094", nil))
}

Fetching OAuth Data

Now you can validate those tokens with the OAuth API:

dat, _, err:=usBlizzClient.TokenValidation(ctx, token)
iferr!=nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", dat)

Streaming Provider Service (Playable Titles)

Cloud‑gaming partners can ask Blizzard which titles a given user is allowed to launch. To do this, request the streaming.titles and openid scopes when building the authorization URL. After the user completes the OAuth flow you will have an access token suitable for SPS.

Use the new SPSPlayableTitles helper to call the service:

pts, hdr, err:=usBlizzClient.SPSPlayableTitles(ctx, token)
iferr!=nil {
fmt.Println(err)
}
for_, t:=rangepts.Titles {
fmt.Printf("%d: %s\n", t.ID, t.Name)
}

The response contains every eligible title or sub‑title available to the account.

For a complete runnable example, see examples/sps.

Header Information

Each API call will return HTTP response header information, if any. Use the second return variable to get a structure containing the response header information.

dat, header, err:=usBlizzClient.WoWAuctions(context.Background(), 1138)
iferr!=nil {
fmt.Println(err)
}
fmt.Println(header.BattlenetNamespace)
fmt.Println(header.LastModified)
...

Documentation

See the Blizzard API reference and the Go reference for all the different datasets that can be acquired. For questions and discussion about the blizzard API go to the Blizzard API Forum.

Special Thanks

Thanks to JSON-to-Go for making JSON to Go structure creation simple.

Thanks to all who contribute to keep this package current.