Skip to content

Releases: mathsman5133/coc.py

Support for CapitalRaidSeasons and Context Manager

24 Oct 23:25

Choose a tag to compare

This update has quite a bit of change without breaking backward compatibility.

For starters, support for the context manager was added #121 allowing the use of

async def main():
	async with coc.Client() as client:
		# do stuff...

if __name__ == "__main__":
	asyncio.run(main())

Additionally, with the release of CapitalRaidSeasons we needed to improve the performance of fetching warlogs and capital raid logs. Previously, all records available from the API were fetched when in most cases, folks just needed the newest data. A limit parameter has been added to both get_warlog and get_raidlog.

Additionally, support for async for warlog has been added with the ability to fetch more data if needed.

raid_logs = await client.get_raidlog(clan_tag, page=True, limit=5)

# Set `paginate=True` to enable fetching beyond the limit value until
# there are more values to fetch
count = 0
async for i in raid_with_page:
    print(f"[{count}]-async limit: 5 page: True {i.start_time.time}")
    count += 1

This PR includes:
#122
#121
#130
#131

Update fixes issue #125

13 Oct 02:06
730f554

Choose a tag to compare

Minor release fixes the order of pets from Player.hero_pets

Th15 Update!

10 Oct 23:51
48c3a2e

Choose a tag to compare

The update contains updates from the TH15 release.

  • Update troops, spells, and pet orders
  • Update static json files
  • Added script to automate updating the json files
  • Removed the ResourceCost key from the json files

v2.1.1

07 Sep 09:36

Choose a tag to compare

Version bump to v2.1.1 to push to PyPi. See v2.1.0 release for detailed changelog.

Clan capitol support!

28 Aug 14:25

Choose a tag to compare

  • Support for Clan Capitols!
  • Updated our examples
  • Bug fixes and improvements!
    Fixed bug with iterating over clan.get_detailed_members where player objects were missing attributes #109
    Cleaned up how the async loop was being managed by library #111
    Please be sure to create issues for any bug fixes or feature requests!

v2.0.1

22 Jun 06:55

Choose a tag to compare

  • New achievements for clan capital

  • Switched to using Tuba's new links API (Thanks, Tuba)

  • Get the IP Address from logging into the developer site to save an API call (Thanks, Roshan)

v2.0.0

05 Jan 20:48

Choose a tag to compare

Migrating to coc.py v2.0

Most of the outward facing library is the same, with a few changes detailed below. One significant change is the
introduction of game data into Troop, Spell, Hero and Pet objects. You can read more about that here: :ref:game_data.

Logging in with keys

A popular request was made to be able to use the client without the automatic key management. You can now initiate coc.py
with a list of keys (or tokens), using the :meth:coc.login_with_keys method.

Parsing and creating army links

The June update brought about the ability to share and create army links. v2 brings the ability to do this within the client,
using the methods :meth:Client.parse_army_link and :meth:Client.create_army_link. These work best when paired with
the game data mentioned above, as you will receive (semi)complete Troop and Spell objects with stats for all troops and spells.

Thanks to Anub, Sco and others for helping to implement this.

Additional methods / attributes for models

A popular feature request was to be able to know "is this troop the max for the player's TH level". Before, this would
require you to keep a static list of troop levels and do a lookup. This has been integrated into coc.py, and many models
have this attribute now:

  • :attr:Troop.is_max_for_townhall

  • :attr:Spell.is_max_for_townhall

  • :attr:Hero.is_max_for_townhall

  • :attr:Pet.is_max_for_townhall

Similarly, you can use Troop.get_max_level_for_townhall to do the opposite - get the max troop level for a specific townhall.
More on that in the :ref:game_data section, however.

  • :attr:WarClan.average_attack_duration is now a valid property, thanks to doluk for implementing this.

  • :attr:Player.war_opted_in was added, to reflect the September update in the API.

  • :attr:ClanWar.attacks_per_member was added, which details the number of attacks each member has in the war, also in the September update.

  • :attr:Player.clan_previous_rank was fixed, it didn't point to the correct API field before.

Miscellaneous

  • ujson has been added to the requirements and will be used where possible,
    as a faster method of deserialising json payloads from the API.

  • Internal handling of keys has been written to make it more stable.

  • Flame Flinger, Super Bowler and Super Dragon were all added to coc.py.

v1.3.0

15 Jun 23:22

Choose a tag to compare

v1.3.0

  • Added Dragon Rider and Rocket Balloon

  • Added cls parameter for :meth:Clan.get_detailed_members()

  • Troops no longer included in Player.home_troops

  • :exc:InvalidArgument will now return a more helpful message.

  • limit parameter is now correctly cached when using search_x endpoints.

  • Added more typings and documentation improvements

v1.2.1

22 Apr 23:27

Choose a tag to compare

v1.2.1

  • Fixes an issue where Clan.members was empty if Clan.get_member was called before Clan.members.
    There was a similar issue with Player.heroes and Player.spells.

v1.2.0

19 Apr 23:13

Choose a tag to compare

v1.2.0

  • Adds new achievements and updated the order of existing ones.

  • Added :attr:Player.super_troops and :attr:Player.pets.

  • Added :attr:Troop.is_active to check whether a super troop is active.

  • Added :attr:WarAttack.duration

  • Added :attr:Clan.chat_language which is a :class:ChatLanguage object.

  • Fixed errors when coc.py tried to parse 5xx (e.g. 502) errors as HTML when they were dicts.

  • Improved docs for :attr:RankedPlayer.previous_rank.