Skip to main content

A Python wrapper for Blizzard API

Reason this release was yanked:

Meant to be v4

Project description

Blizzard API 2

PyPI version Python Versions Downloads Build Status

GitHubDependabotCodeQLCode style: black

blizzardapi2 is a client library for Blizzard's APIs. It's a fork of the original library.

Current supported features include:

  • Battle.net User
  • WoW Profile
  • WoW Game Data
  • WoW Classic Game Data
  • Diablo 3 Community
  • Diablo 3 Game Data
  • Hearthstone Game Data
  • Starcraft 2 Community
  • Starcraft 2 Game Data

Modern features:

  • Full type hints support
  • Automatic token management with intelligent refresh
  • Enum-based region and locale validation
  • Clean, maintainable codebase
  • Comprehensive error handling

To gain access to Blizzard's API please register here to obtain a client id and client secret.

For more information on Blizzard's API visit:

Official Documentation
Official API Forum

Requirements

Python (3.11+)

Installing

pip install blizzardapi2

Examples

Basic Usage

from blizzardapi2 import BlizzardApi

api_client = BlizzardApi("client_id", "client_secret")

# Public API endpoint (uses automatic client credentials token)
categories_index = api_client.wow.game_data.get_achievement_categories_index(
    "us",  # region
    "en_US"  # locale
)

# Protected API endpoint (requires user OAuth token)
summary = api_client.wow.profile.get_account_profile_summary(
    "us",
    "en_US",
    "user_access_token"  # OAuth token from authorization code flow
)

# WoW Classic endpoint
connected_realms_index = api_client.wow.game_data.get_connected_realms_index(
    "us",
    "en_US",
    is_classic=True
)

Token Management

The library automatically manages client credentials tokens for public endpoints:

from blizzardapi2 import BlizzardApi

api_client = BlizzardApi("client_id", "client_secret")

# First call: library automatically fetches and caches a client credentials token
realms = api_client.wow.game_data.get_realms_index("us", "en_US")

# Subsequent calls: library reuses the cached token
achievements = api_client.wow.game_data.get_achievements_index("us", "en_US")

# When token expires: library automatically refreshes it
# You don't need to manage tokens manually!

Access token vs Client ID/Client Secret

You can pass in a client_id and client_secret and use almost any endpoint except for a few that require an access_token obtained via OAuth authorization code flow. You can find more information at https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow.

Important: The library handles all tokens securely by passing them in Authorization headers, never in URLs. When you provide a user OAuth token to methods like get_account_profile_summary(), the library automatically:

  1. Extracts the token from parameters
  2. Sends it via Authorization: Bearer <token> header
  3. Keeps tokens out of URL query strings

Here is the list of endpoints, specified by Blizzard, that require an OAuth token:

GET /oauth/userinfo
GET /profile/user/wow
GET /profile/user/wow/protected-character/{realm-id}-{character-id}
GET /profile/user/wow/collections
GET /profile/user/wow/collections/pets
GET /profile/user/wow/collections/mounts

Note: For these protected endpoints, you must implement the OAuth authorization code flow in your application to obtain a user access token. The library does not handle the OAuth flow itself - it only accepts and uses the token you provide.

Documentation

For detailed documentation on each game's API, see the following README files:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blizzardapi2-3.0.4.tar.gz (88.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blizzardapi2-3.0.4-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file blizzardapi2-3.0.4.tar.gz.

File metadata

  • Download URL: blizzardapi2-3.0.4.tar.gz
  • Upload date:
  • Size: 88.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for blizzardapi2-3.0.4.tar.gz
Algorithm Hash digest
SHA256 7e9d9c2a41081c86bd2f9723824a369be10bfe4b175fbcc083dfad20a53cc2c4
MD5 31478b0532ab60dc6d8c470e4322d3b6
BLAKE2b-256 57b654b92bb2fa168d13bfdeff4848cf58c834767bc058687b7ce3d39c151908

See more details on using hashes here.

File details

Details for the file blizzardapi2-3.0.4-py3-none-any.whl.

File metadata

  • Download URL: blizzardapi2-3.0.4-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for blizzardapi2-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7f7fcbdf453d97a937128950f38d095180f863fe81d9a2cfe15fc06140facdd3
MD5 2fbd80dbe6f2514db35d8e3ffda51d88
BLAKE2b-256 f7e735b452345ad445d0e0e33ebcdb8c1b02260d12253f18e0597cb4e149b7dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page