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 removed

  • coc.Clan.required_builder_base_trophies() was added

  • coc.ClanMember.builder_base_league() was added

  • coc.Client.search_builder_base_leagues() was added

  • coc.Client.get_builder_base_league() was added

  • coc.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:

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:

  • WarLeague was replaced with BaseLeague which has the same attributes, but is also used for the builder base league and the clan capital league

  • League inherits from BaseLeague now and adds the icon attribute which is present for home village leagues

  • League lost its localized_name and localized_short_name attributes 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