Miscellaneous

Graphics

Badge

class coc.Badge

Represents a Clash Of Clans Badge.

small

str - URL for a small sized badge (70x70).

medium

str - URL for a medium sized badge (200x200).

large

str - URL for a large sized badge (512x512).

async save(filepath, size=None) int

Save this badge as a file-like object.

Parameters:
  • filepath (os.PathLike) – The filename to save the badge to.

  • size (Optional[str]) – Either small, medium or large. The default is medium.

Returns:

The number of bytes written

Return type:

int

Raises:
property url: str

the default icon URL. Returns the medium-sized icon URL if available. Falls back to small and large (in that order) if not

Type:

str

Icon

class coc.Icon

Represents a Clash Of Clans Icon.

tiny

str: URL for a tiny sized icon (32x32).

small

str: URL for a small sized icon (72x72).

medium

str: URL for a medium sized icon (288x288).

async save(filepath: str, size: str | None = None) int

Save this icon as a file-like object.

Parameters:
  • filepath (os.PathLike) – The filename to save the badge to.

  • size (Optional[str]) – Either tiny, small or medium. The default is small.

Returns:

:class:`int`

Return type:

The number of bytes written.

Raises:
property url: str

the default icon URL. Returns the medium-sized icon URL if available. Falls back to small and tiny (in that order) if not

Type:

str

Time

Timestamp

class coc.Timestamp

Represents a Clash of Clans Timestamp

raw_time

str: The raw timestamp string (ISO8601) as given by the API.

property now: datetime

Returns the time of the timestamp as a datetime object in UTC.

Type:

datetime

property seconds_until: int

Returns the number of seconds until the timestamp. This may be negative.

Type:

int

property time: datetime

Returns the timestamp as a UTC datetime object.

Type:

datetime

TimeDelta

class coc.TimeDelta

Represents a Timedelta object corresponding to things that take time to do in the API.

Some examples include:

  • Upgrade times

  • Training times

  • Cooldown times

This object works in a very similar fashion to datetime’s timedelta object, but with a few more helpful attributes.

Note

You should not construct this yourself, instead use it from the attribute of an e.g. Troop model.

days

The number of days in the timedelta.

Type:

int

hours

The number of hours in the timedelta. This does not include days. For example, if an upgrade took 36 hours, the .days attribute would be 1, and .hours would be 12.

Type:

int

minutes

The number of minutes in the timedelta. The same logic applies as with hours.

Type:

int

seconds

The number of seconds in the timedelta. The same logic applies as with hours.

Type:

int

total_seconds()

Returns the total number of seconds in the time object.

This is the addition of all days, hours, minutes, seconds.

Returns:

The number of seconds

Return type:

int

Location

class coc.Location

Represents a Clash of Clans Location

id

int - The location ID

name

str - The location name

is_country

bool - Indicates whether the location is a country

country_code

str - The shorthand country code, if the location is a country

localised_name

str - A localised name of the location. The extent of the use of this is unknown at present.

Season

class coc.Season

Represents a Clash of Clans Player’s Season.

ChatLanguage

class coc.ChatLanguage

Represents a clan’s chat language.

id
Type:

int: The language’s unique ID

name
Type:

str: The language’s full name, for example English.

language_code
Type:

str The language’s abbreviated code, for example EN.

GoldPassSeason

class coc.GoldPassSeason

Represents a gold pass season.

start_time

Timestamp: The gold pass season start time

end_time

Timestamp: The gold pass season end time

duration

datetime.timedelta: The duration of the gold pass season

TID

class coc.TID

Represents a Translation ID (TID) for Clash of Clans game elements.

name

The translation ID for the name of the game element.

Type:

str

info

The translation ID for additional info/description of the game element.

Type:

str

Translation

class coc.Translation

Represents translations for multiple languages.

Supports multiple access patterns:

  • Attribute access: translation.russian, translation.english

  • Dictionary access (uppercase): translation["RU"], translation["EN"]

  • Dictionary access (lowercase): translation["ru"], translation["en"]

english
Type:

str

arabic
Type:

str

chinese
Type:

str

chinese_traditional
Type:

str

german
Type:

str

spanish
Type:

str

persian
Type:

str

finnish
Type:

str

french
Type:

str

indonesian
Type:

str

italian
Type:

str

japanese
Type:

str

korean
Type:

str

malay
Type:

str

dutch
Type:

str

norwegian
Type:

str

polish
Type:

str

portuguese
Type:

str

russian
Type:

str

thai
Type:

str

turkish
Type:

str

vietnamese
Type:

str