Getting Started

All resources are loaded through the SC2BnetFactory and resource helper methods.

SC2BnetFactory

class sc2bnet.SC2BnetFactory(preferred_locale=None, public_key=None, private_key=None, cache=None)[source]
Parameters:
  • preferred_locale – The locale to use when available. Not all regions support all locals.
  • app_key – Your application key. When non-null it is used to sign your requests to the Web API.
  • cache_dir – The path to a pre-existing writable folder to cache responses in.
achievement[source]

A dict of achivementId -> Achievement containing all possible achievements. Lazy loaded and cached in the factory locale.

icon[source]

A nested dict of url -> offset -> Icon containing all possible icons. Lazy loaded and cached in the factory locale.

load_ladder(region, ladder_id)[source]

Load a new Ladder from the given id. Ladders are not cached.

load_profile(region, bnet_id, realm, name)[source]

Load a new PlayerProfile using the given options. Profiles are not cached.

reward[source]

A dict of rewardId -> Reward containing all possible rewards. Lazy loaded and cached in the factory locale.

Resources

Player Profile

class sc2bnet.PlayerProfile(region, bnet_id, realm, name, factory)[source]
Parameters:
  • region – The player’s region: us, eu, kr, tw, cn, or sea
  • bnet_id – The player’s unique battle.net id
  • realm – The realm within the region the player is registered to. Generally a 1 or 2
  • name – The player’s current Battle.net name
  • factory – A reference to the SC2BnetFactory to use when constructing resources.

This class should not be manually constructed, use SC2BnetFactory.load_profile().

Create a new PlayerProfile with basic data. No web API calls are made by default. The load_details(), load_ladders(), and load_matches() methods can be used to pull additional information from the Battle.net API.

achievement_points_by_category = None

A dict category -> points that breaks the total achievement points down by category.

achievements = None

A dict of achivement -> completion date for achivements completed by this player.

clan_name = None

The name of the clan the player belongs to.

clan_tag = None

The tag of the clan the player belongs to.

combined_levels = None

The player’s overall character level.

current_season = None

The reference to the Season object for the current season

current_season_game_count = None

The number of games played this season

current_season_number = None

The current season number

hots_campaign_completion = None

The difficulty level used to complete the HotS campaign: CASUAL, NORMAL, HARD, or BRUTAL

id = None

The character’s unique Battle.net id.

The html profile page on Battle.net

load_details()[source]

Loads the majority of the player profile data. Everything except for current_season, previous_season, and recent_matches.

load_ladders()[source]

Loads the current and previous season ladder data into current_season and previous_season respectively.

load_matches()[source]

Loads recent matches into the recent_matches attribute.

name = None

The character’s current name

portrait = None

A reference to the Icon object the player is currently using as a portrait

previous_season = None

The reference to the Season object for the previous season

primary_race = None

One of ZERG, PROTOSS, TERRAN, or RANDOM

protoss_level = None

The player’s Protoss character level.

protoss_level_xp = None

The player’s current XP progress to the next Protoss level. -1 if at max level.

protoss_total_xp = None

The player’s total Protoss XP

protoss_wins = None

Total career Protoss wins.

realm = None

The id for the character’s home realm in the region

recent_matches = None

A list of recent matches played by the player

region = None

The region of Battle.net this character belongs to

rewards_earned = None

A list of rewards this player has earned

rewards_selected = None

A list of the earned rewards selected to be showcased.

terran_level = None

The player’s Terran character level.

terran_level_xp = None

The player’s current XP progress to the next Terran level. -1 if at max level.

terran_total_xp = None

The player’s total Terran XP

terran_wins = None

Total career Terran wins.

total_achievement_points = None

The total point value of all achievements completed by this player.

total_games = None

Total career games played.

wol_campaign_completion = None

The difficulty level used to complete the WoL campaign: CASUAL, NORMAL, HARD, or BRUTAL

zerg_level = None

The player’s Zerg character level.

zerg_level_xp = None

The player’s current XP progress to the next Zerg level. -1 if at max level.

zerg_total_xp = None

The player’s total Zerg XP

zerg_wins = None

Total career Zerg wins.

Ladder

class sc2bnet.Ladder(region, ladder_id, factory)[source]

Represents a single ladder in a single season.

arranged_team = None

A boolean flag that is true of the team is arranged team. False if the team was partially random. None if not known

division = None

The division id of the ladder

expansion = None

The expansion the ladder is linked to. “” if it cannot be determined.

id = None

The unique integer id for the ladder

league = None

The league of the ladder: BRONZE, SILVER, GOLD, PLATINUM, DIAMOND, MASTER, GRANDMASTER

load_details()[source]

Load additional ladder details from the Web API.

name = None

The name of the ladder

queue = None

The queue this ladder draws opponents from.

rank = None

A dict mapping rank -> LadderRanking

rankings = None

A list of LadderRanking on the ladder.

region = None

The region the ladder is active on

type = None

The type of teams for the ladder; 1v1, 2v2, 3v3, 4v4 (FFA is unranked). 0v0 if can’t be determined.

Achievement

class sc2bnet.Achievement(data, factory)[source]

Represents a battle.net achievement

category_id = None

The id of the achievement’s category.

description = None

The description of the achievement.

icon = None

A reference to the Icon for this achievement.

id = None

The achievement’s unique id.

points = None

The number of points granted by the achievement

title = None

The title of the achievement.

Reward

class sc2bnet.Reward(data, factory)[source]

Represents a Battle.net reward.

achievement = None

A reference to the Achievement that unlocks this reward. None if none needed.

achievement_id = None

The unique id of the achievement that unlocks this reward

icon = None

A reference to the Icon for this award.

id = None

The unique id for this reward

title = None

The title of this award

Support Objects

Season

class sc2bnet.Season(data, profile, number)[source]

Represents the ranked ladder activity for a single person in one season on one region.

number = None

The season number

profile = None

A backreference to the PlayerProfile this season is for

rankings = None

A list of LadderRanking references for ladder rankings this season

region = None

Region this season is active on

teams = None

A list of Team references for teams this player has played on this season.

Ladder Ranking

class sc2bnet.LadderRanking(region, data, team, ladder, factory)[source]

Represents a ladder ranking for a team. Depending on how the ladder ranking was loaded, different attributes are available.

highest_rank = None

The highest team rank. 0 if not available

join_time = None

The time the team joined the ladder. None if not available

ladder = None

A reference to the Ladder object this ranking is for.

losses = None

The current loss total.

points = None

The team’s current point total. 0 if not available

previous_rank = None

The previous team rank. 0 if not available

rank = None

The current team rank.

team = None

A reference to the Team object that this ranking is for

wins = None

The current win total.

Team

class sc2bnet.Team(region, data, season, factory)[source]

Represents a collection of players playing on a ranked ladder in one season.

members = None

A list of PlayerProfile references for members of the team

rankings = None

A list of LadderRanking references for ranks achieved by this team in this season.

region = None

The region this team is active in

season = None

A back reference to the Season this team is a part of.

Match

class sc2bnet.Match(data, factory)[source]

Represents a single match played by a player.

end_time = None

The date the match was played (in UTC?)

map = None

The map the match was played on

result = None

The result of the match for the player. One of: WIN, LOSS, ??.

speed = None

The effective game speed during the match. Generally FASTER.

type = None

The type of match that was played. One of:

  • CUSTOM - Arcade map
  • CO_OP - VS AI
  • THREES - 3v3 (can it tell between HotS and WoL?)
  • ???

Portrait

class sc2bnet.Ladder(region, ladder_id, factory)[source]

Represents a single ladder in a single season.

arranged_team = None

A boolean flag that is true of the team is arranged team. False if the team was partially random. None if not known

division = None

The division id of the ladder

expansion = None

The expansion the ladder is linked to. “” if it cannot be determined.

id = None

The unique integer id for the ladder

league = None

The league of the ladder: BRONZE, SILVER, GOLD, PLATINUM, DIAMOND, MASTER, GRANDMASTER

load_details()[source]

Load additional ladder details from the Web API.

name = None

The name of the ladder

queue = None

The queue this ladder draws opponents from.

rank = None

A dict mapping rank -> LadderRanking

rankings = None

A list of LadderRanking on the ladder.

region = None

The region the ladder is active on

type = None

The type of teams for the ladder; 1v1, 2v2, 3v3, 4v4 (FFA is unranked). 0v0 if can’t be determined.

Icon

class sc2bnet.Icon(title, data, factory)[source]

Represents an icon embedded in a compound image.

TODO: Extract the actual icon, cache the compound image.

height = None

The height of the icon

offset = None

The index of the icon in an imaginary array of icon images counting from left to right, top to bottom on the linked compound image.

title = None

The working title for the icon

url = None

The of the compound image the icon is contained in.

width = None

The width of the icon

x = None

The x shift on the linked compound image for the top left corner of the icon

y = None

The y shift on the linked compound image for the top left corner of the icon

SC2BnetError

class sc2bnet.SC2BnetError(data)[source]

Thrown when there are errors in the Web API response.

code = None

The code from the response

json = None

The full json response

message = None

The message from the response

Contents:

Indices and tables

Project Versions

Table Of Contents

This Page