Migrating to coc.py v3.0
Most of the outward facing library is the same, with a few changes detailed below. Significant changes are caused by builder base 2.0 update.
Logging in
The functions coc.login() and coc.login_with_keys() were removed.
Use coc.Client.login() or coc.Client.login_with_tokens() instead.
Builder Base v2
The builder base revamp has caused a bunch of breaking changes.
The most significant change is renaming all the versus things to builder_base things,
but there were some additions and a removal as well:
coc.Client.get_location_clans_versus()->coc.Client.get_location_clans_builder_base()coc.Client.get_location_players_versus()->coc.Client.get_location_players_builder_base()coc.Clan.versus_points()->coc.Clan.builder_base_points()coc.RankedClan.versus_points()->coc.RankedClan.builder_base_points()coc.ClanMember.versus_trophies()->coc.ClanMember.builder_base_trophies()coc.ClanMember.versus_rank()->coc.ClanMember.builder_base_rank()coc.RankedPlayer.versus_trophies()->coc.RankedPlayer.builder_base_trophies()coc.Player.versus_trophies()->coc.Player.builder_base_trophies()coc.Player.best_versus_trophies()->coc.Player.best_builder_base_trophies()coc.LegendStatistics.previous_versus_season()->coc.LegendStatistics.previous_builder_base_season()coc.LegendStatistics.best_versus_season()->coc.LegendStatistics.best_builder_base_season()coc.Player.versus_attack_wins()was removedcoc.Clan.required_builder_base_trophies()was addedcoc.ClanMember.builder_base_league()was addedcoc.Client.search_builder_base_leagues()was addedcoc.Client.get_builder_base_league()was addedcoc.Client.get_builder_base_league_named()was added
Game Objects
coc.py game data was updated and now includes all the recently added troops and heros. This is also reflected in the following enumerations:
coc.HOME_TROOP_ORDERnow knows the “Apprentice Warden”coc.SUPER_TROOP_ORDERnow knows the “Super Hog Rider”in the
coc.BUILDER_TROOPS_ORDER, “Super P.E.K.K.A” got renamed to “Power P.E.K.K.A”coc.BUILDER_TROOPS_ORDERnow knows the “Electrofire Wizard”coc.HERO_ORDERnow knows the “Battle Copter”
Leagues
Previously the structure of Leagues was a bit messy and not well aligned with what the API provides. Therefore they got a small rework:
WarLeaguewas replaced withBaseLeaguewhich has the same attributes, but is also used for the builder base league and the clan capital leagueLeagueinherits fromBaseLeaguenow and adds theiconattribute which is present for home village leaguesLeaguelost itslocalized_nameandlocalized_short_nameattributes as they are not present in the API
Furthermore
In order to get more in line with our coding style, the following methods were renamed:
coc.Client.get_warlog()->coc.Client.get_war_log()coc.Client.get_raidlog()->coc.Client.get_raid_log()
coc.ClanMember has a new cached property: player_house_elements()
coc.RaidDistrict has a new stars attribute