codingame Release 1.0.1

takos22

Aug 22, 2021

CONTENTS

1 Getting started 3

2 Getting help 5

3 User Guide 7

4 API Reference 13

5 Changelog 33

6 Indices and tables 37

Index 39

i ii codingame, Release 1.0.1

The codingame module is a wrapper for the undocumented CodinGame API, it enables developers to interact with CodinGame through a Python programming interface.

Features: • Easy to develop • Supports both synchronous and asynchronous code

CONTENTS 1 codingame, Release 1.0.1

2 CONTENTS CHAPTER ONE

GETTING STARTED

Is this your first time using the module? This is the place to get started! • First steps: Introduction | Quickstart • Examples: Many examples are available in the repository.

3 codingame, Release 1.0.1

4 Chapter 1. Getting started CHAPTER TWO

GETTING HELP

If you’re having trouble with something, these resources might help. • Ask us and hang out with us in our Discord server. • If you’re looking for something specific, try the index or searching. • Report bugs in the issue tracker.

5 codingame, Release 1.0.1

6 Chapter 2. Getting help CHAPTER THREE

USER GUIDE

3.1 Introduction

This is the documentation for the codingame module.

3.1.1 Prerequisites

Python 3.6 or higher is required.

3.1.2 Installing

Install codingame with pip:

Linux or MacOS python3 -m pip install -U codingame

Windows py -3 -m pip install -U codingame

Installing the asynchronous version

If you want to use the asynchronous client, make sure to have the correct modules installed by doing:

Linux or MacOS python3 -m pip install -U codingame[async]

7 codingame, Release 1.0.1

Windows py -3 -m pip install -U codingame[async]

Virtual Environments

Sometimes you want to keep libraries from polluting system installs or use a different version of libraries than the ones installed on the system. You might also not have permissions to install libraries system-wide. For this purpose, the standard library as of Python comes with a concept called “Virtual Environment”s to help maintain these separate versions. A more in-depth tutorial is found on Virtual Environments and Packages. However, for the quick and dirty: 1. Go to your project’s working directory:

Linux or MacOS

cd your-website-dir

Windows

cd your-website-dir

2. Create a virtual environment:

Linux or MacOS

python3 -m venv venv

Windows

py -3 -m venv venv

3. Activate the virtual environment:

Linux or MacOS

source venv/bin/activate

8 Chapter 3. User Guide codingame, Release 1.0.1

Windows

venv\Scripts\activate.bat

4. Use pip like usual:

Linux or MacOS

pip install -U codingame

Windows

pip install -U codingame

Congratulations. You now have a virtual environment all set up. You can start to code, learn more in the Quickstart.

3.2 Quickstart

This page gives a brief introduction to the module. It assumes you have the module already installed, if you don’t check the Installing portion. You can find examples here.

3.2.1 Get a CodinGamer

Let’s get a CodinGamer from their pseudo with the Client.get_codingamer() method: import codingame client= codingame.Client() codingamer= client.get_codingamer("pseudo") print(codingamer) print(codingamer.pseudo) print(codingamer.public_handle) print(codingamer.avatar_url)

Note: You can also use a public handle (39 character long hexadecimal string at the end of its profile link) or a user ID. Just replace the "pseudo" with the public handle or user ID.

See also: See Client.get_codingamer() and CodinGamer for more info.

3.2. Quickstart 9 codingame, Release 1.0.1

3.2.2 Get a Clash of Code

Let’s get a Clash of Code from its public handle with the Client.get_clash_of_code() method: import codingame client= codingame.Client()

# get a pending public clash of code coc= client.get_pending_clash_of_code() # or get a clash of code from its public handle coc= client.get_clash_of_code("clash of code handle here") print(coc) print(coc.join_url) print(coc.modes) print(coc.programming_languages) print(coc.public_handle) print(coc.players)

Note: The public handle is the 39 character long hexadecimal string at the end of the Clash of Code invite link.

See also: See Client.get_pending_clash_of_code(), Client.get_clash_of_code() and ClashOfCode for more info.

3.2.3 Login

Let’s log in into a profile with the email and password with the Client.login() method: import codingame client= codingame.Client("email","password")

# then you can access the logged in codingamer like this print(client.logged_in) print(client.codingamer) print(client.codingamer.pseudo) print(client.codingamer.public_handle) print(client.codingamer.avatar_url)

See also: See Client and Client.login() for more info.

Note: Don’t worry, the email and the password aren’t stored. You can see that here.

10 Chapter 3. User Guide codingame, Release 1.0.1

3.3 Asynchronous client

The asynchronous client has the same methods as the synchronous client, but all of them are coroutines. That means that you can use methods like Client.login(), but you need to do await client.login(...) instead of client.login(...). It works like this for methods of CodinGame models like CodinGamer.get_followers() needs to be awaited with the asynchronous client.

3.3.1 Example

Here’s the first block of code of Quickstart but with the asynchronous client: import codingame import asyncio

async def main(): client= codingame.Client(is_async= True)

codingamer= await client.get_codingamer("pseudo") print(codingamer) print(codingamer.pseudo) print(codingamer.public_handle) print(codingamer.avatar_url)

asyncio.run(main())

3.3. Asynchronous client 11 codingame, Release 1.0.1

12 Chapter 3. User Guide CHAPTER FOUR

API REFERENCE

4.1 API Reference

The following section outlines the API of the codingame module. All the public classes, methods and functions are documented here.

4.1.1 Version Related Info

There are two main ways to query version information about the library. codingame.version_info A named tuple that is similar to sys.version_info. Just like sys.version_info the valid values for releaselevel are ‘alpha’, ‘beta’, ‘candidate’ and ‘final’. codingame.__version__ A string representation of the version. e.g. '1.0.0rc1'. This is based off of PEP 440.

4.1.2 Client

Hybrid client class codingame.Client(is_async=False) Client for the CodinGame API. Instanciates a SyncClient if is_async is False or not given. Instanciates a AsyncClient if is_async is True. Parameters is_async (bool) – Whether the client is asynchronous. Defaults to False. close() This function can be a coroutine. Closes the client session. property codingamer The CodinGamer that is logged in. None if the client isn’t logged in. Type Optional CodinGamer abstract get_challenge_leaderboard(challenge_id, group='global') This function can be a coroutine. Get the leaderboard of a challenge.

13 codingame, Release 1.0.1

You can specify an optional group of users to rank. Parameters • challenge_id (str) – The string that identifies the challenge. • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". • ChallengeNotFound – There is no challenge with the given challenge_id. Returns The challenge leaderboard. Return type ChallengeLeaderboard abstract get_clash_of_code(handle) This function can be a coroutine. Get a Clash of Code from its public handle. Parameters handle (str) – The Clash of Code’s public handle. 39 character long hexadecimal string (regex: [0-9]{7}[0-9a-f]{32}). Raises • ValueError – The Clash of Code handle isn’t in the good format. • ClashOfCodeNotFound – The Clash of Code with the given public handle isn’t found. Returns The ClashOfCode. Return type ClashOfCode abstract get_codingamer(codingamer) This function can be a coroutine. Get a CodinGamer from their public handle, their ID or from their username.

Note: codingamer can be the public handle, the id or the username. Using the public handle or the ID is reccomended because it won’t change even if the codingamer changes their username. The public handle is a 39 character long hexadecimal string that represents the user. Regex of a public handle: [0-9a-f]{32}[0-9]{7} The ID is a 7 number long integer.

Parameters codingamer (str or int) – The CodinGamer’s public handle, ID or username. Raises CodinGamerNotFound – The CodinGamer with the given public handle, ID or username isn’t found. Returns The CodinGamer. Return type CodinGamer

14 Chapter 4. API Reference codingame, Release 1.0.1

abstract get_global_leaderboard(page=1, type='GENERAL', group='global') This function can be a coroutine. Get the global leaderboard in CodinGame. You can specify an optional page, type of leaderboard and the group of users to rank. Parameters • page (Optional int) – The page of the leaderboard to get the users from. Default: 1. • type (Optional str) – The type of global leaderboard to show. One of "GENERAL", "CONTESTS", "BOT_PROGRAMMING", "OPTIM" or "CODEGOLF". Default: "GENERAL". • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". Returns The global leaderboard. Return type GlobalLeaderboard abstract get_language_ids() This function can be a coroutine. Get the list of all available language ids. abstract get_pending_clash_of_code() This function can be a coroutine. Get a pending Clash of Code. Returns The pending ClashOfCode if there’s one or None. Return type Optional ClashOfCode abstract get_puzzle_leaderboard(puzzle_id, group='global') This function can be a coroutine. Get the leaderboard of a puzzle. You can specify an optional group of users to rank. Parameters • puzzle_id (str) – The string that identifies the puzzle. • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". • PuzzleNotFound – There is no puzzle with the given puzzle_id. Returns The puzzle leaderboard.

4.1. API Reference 15 codingame, Release 1.0.1

Return type PuzzleLeaderboard abstract get_unseen_notifications() This function can be a coroutine. Get all the unseen notifications of the logged in CodinGamer. You need to be logged in to get notifications or else a LoginRequired will be raised.

Note: This method is a generator.

Raises LoginRequired – The Client needs to log in. See login(). Yields Notification – A Notification.

property is_async Whether the client is asynchronous. Type bool property logged_in Whether the client is logged in. Type bool abstract login(email, password) This function can be a coroutine. Login to a CodinGamer account. Parameters • email (str) – Email adress of the CodinGamer. • password (str) – Password of the CodinGamer. Raises LoginError – Error with the login (empty email, empty password, wrong email format, incorrect password, etc). Returns The CodinGamer that logged in. Return type CodinGamer

Synchronous client class codingame.client.sync.SyncClient Synchronous client for the CodinGame client. login(email, password) Login to a CodinGamer account. Parameters • email (str) – Email adress of the CodinGamer. • password (str) – Password of the CodinGamer. Raises LoginError – Error with the login (empty email, empty password, wrong email format, incorrect password, etc). Returns The CodinGamer that logged in. Return type CodinGamer

16 Chapter 4. API Reference codingame, Release 1.0.1

get_codingamer(codingamer) Get a CodinGamer from their public handle, their ID or from their username.

Note: codingamer can be the public handle, the id or the username. Using the public handle or the ID is reccomended because it won’t change even if the codingamer changes their username. The public handle is a 39 character long hexadecimal string that represents the user. Regex of a public handle: [0-9a-f]{32}[0-9]{7} The ID is a 7 number long integer.

Parameters codingamer (str or int) – The CodinGamer’s public handle, ID or username. Raises CodinGamerNotFound – The CodinGamer with the given public handle, ID or username isn’t found. Returns The CodinGamer. Return type CodinGamer

get_clash_of_code(handle) Get a Clash of Code from its public handle. Parameters handle (str) – The Clash of Code’s public handle. 39 character long hexadecimal string (regex: [0-9]{7}[0-9a-f]{32}). Raises • ValueError – The Clash of Code handle isn’t in the good format. • ClashOfCodeNotFound – The Clash of Code with the given public handle isn’t found. Returns The ClashOfCode. Return type ClashOfCode get_pending_clash_of_code() Get a pending Clash of Code. Returns The pending ClashOfCode if there’s one or None. Return type Optional ClashOfCode get_language_ids() Get the list of all available language ids. get_unseen_notifications() Get all the unseen notifications of the logged in CodinGamer. You need to be logged in to get notifications or else a LoginRequired will be raised.

Note: This method is a generator.

Raises LoginRequired – The Client needs to log in. See login(). Yields Notification – A Notification.

get_global_leaderboard(page=1, type='GENERAL', group='global') Get the global leaderboard in CodinGame.

4.1. API Reference 17 codingame, Release 1.0.1

You can specify an optional page, type of leaderboard and the group of users to rank. Parameters • page (Optional int) – The page of the leaderboard to get the users from. Default: 1. • type (Optional str) – The type of global leaderboard to show. One of "GENERAL", "CONTESTS", "BOT_PROGRAMMING", "OPTIM" or "CODEGOLF". Default: "GENERAL". • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". Returns The global leaderboard. Return type GlobalLeaderboard get_challenge_leaderboard(challenge_id, group='global') Get the leaderboard of a challenge. You can specify an optional group of users to rank. Parameters • challenge_id (str) – The string that identifies the challenge. • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". • ChallengeNotFound – There is no challenge with the given challenge_id. Returns The challenge leaderboard. Return type ChallengeLeaderboard get_puzzle_leaderboard(puzzle_id, group='global') Get the leaderboard of a puzzle. You can specify an optional group of users to rank. Parameters • puzzle_id (str) – The string that identifies the puzzle. • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments.

18 Chapter 4. API Reference codingame, Release 1.0.1

• LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". • PuzzleNotFound – There is no puzzle with the given puzzle_id. Returns The puzzle leaderboard. Return type PuzzleLeaderboard close() This function can be a coroutine. Closes the client session. property codingamer The CodinGamer that is logged in. None if the client isn’t logged in. Type Optional CodinGamer property is_async Whether the client is asynchronous. Type bool property logged_in Whether the client is logged in. Type bool

Asynchronous client class codingame.client.async_.AsyncClient Asynchronous client for the CodinGame API. async close() This function is a coroutine. Closes the client session. async login(email, password) This function is a coroutine. Login to a CodinGamer account. Parameters • email (str) – Email adress of the CodinGamer. • password (str) – Password of the CodinGamer. Raises LoginError – Error with the login (empty email, empty password, wrong email format, incorrect password, etc). Returns The CodinGamer that logged in. Return type CodinGamer async get_codingamer(codingamer) This function is a coroutine. Get a CodinGamer from their public handle, their ID or from their username.

Note: codingamer can be the public handle, the id or the username. Using the public handle or the ID is reccomended because it won’t change even if the codingamer changes their username.

4.1. API Reference 19 codingame, Release 1.0.1

The public handle is a 39 character long hexadecimal string that represents the user. Regex of a public handle: [0-9a-f]{32}[0-9]{7} The ID is a 7 number long integer.

Parameters codingamer (str or int) – The CodinGamer’s public handle, ID or username. Raises CodinGamerNotFound – The CodinGamer with the given public handle, ID or username isn’t found. Returns The CodinGamer. Return type CodinGamer

async get_clash_of_code(handle) This function is a coroutine. Get a Clash of Code from its public handle. Parameters handle (str) – The Clash of Code’s public handle. 39 character long hexadecimal string (regex: [0-9]{7}[0-9a-f]{32}). Raises • ValueError – The Clash of Code handle isn’t in the good format. • ClashOfCodeNotFound – The Clash of Code with the given public handle isn’t found. Returns The ClashOfCode. Return type ClashOfCode async get_pending_clash_of_code() This function is a coroutine. Get a pending Clash of Code. Returns The pending ClashOfCode if there’s one or None. Return type Optional ClashOfCode async get_language_ids() This function is a coroutine. Get the list of all available language ids. get_unseen_notifications() This function is a coroutine. Get all the unseen notifications of the logged in CodinGamer. You need to be logged in to get notifications or else a LoginRequired will be raised.

Note: This method is a generator.

Raises LoginRequired – The Client needs to log in. See login(). Yields Notification – A Notification.

20 Chapter 4. API Reference codingame, Release 1.0.1

async get_global_leaderboard(page=1, type='GENERAL', group='global') This function is a coroutine. Get the global leaderboard in CodinGame. You can specify an optional page, type of leaderboard and the group of users to rank. Parameters • page (Optional int) – The page of the leaderboard to get the users from. Default: 1. • type (Optional str) – The type of global leaderboard to show. One of "GENERAL", "CONTESTS", "BOT_PROGRAMMING", "OPTIM" or "CODEGOLF". Default: "GENERAL". • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". Returns The global leaderboard. Return type GlobalLeaderboard async get_challenge_leaderboard(challenge_id, group='global') This function is a coroutine. Get the leaderboard of a challenge. You can specify an optional group of users to rank. Parameters • challenge_id (str) – The string that identifies the challenge. • group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". • ChallengeNotFound – There is no challenge with the given challenge_id. Returns The challenge leaderboard. Return type ChallengeLeaderboard async get_puzzle_leaderboard(puzzle_id, group='global') This function is a coroutine. Get the leaderboard of a puzzle. You can specify an optional group of users to rank. Parameters • puzzle_id (str) – The string that identifies the puzzle.

4.1. API Reference 21 codingame, Release 1.0.1

• group (Optional str) – The group of users to rank. For every group except "global", you need to be logged in. One of "global", "country", "company", "school" or "following". Default: "global". Raises • ValueError – One of the arguments isn’t one of the accepted arguments. • LoginRequired – The client isn’t logged in and the group is one of "country", "company", "school" or "following". • PuzzleNotFound – There is no puzzle with the given puzzle_id. Returns The puzzle leaderboard. Return type PuzzleLeaderboard property codingamer The CodinGamer that is logged in. None if the client isn’t logged in. Type Optional CodinGamer property is_async Whether the client is asynchronous. Type bool property logged_in Whether the client is logged in. Type bool

4.1.3 CodinGame Models

Models are classes that are created from the data received from CodinGame and are not meant to be created by the user of the library.

Danger: The classes listed below are not intended to be created by users and are also read-only. For example, this means that you should not make your own CodinGamer instances nor should you modify the CodinGamer instance yourself.

CodinGamer

class codingame.CodinGamer Represents a CodinGamer. public_handle Public handle of the CodinGamer (hexadecimal str). Type str id ID of the CodinGamer. Last 7 digits of the public_handle reversed. Type int rank Worldwide rank of the CodinGamer.

22 Chapter 4. API Reference codingame, Release 1.0.1

Type int level Level of the CodinGamer. Type int xp XP points of the CodinGamer. Type int country_id Country ID of the CodinGamer. Type str category Category of the CodinGamer. Can be STUDENT or PROFESSIONAL.

Note: You can use student and professional to get a bool that describes the CodinGamer’s category.

Type Optional str

student Whether the CodinGamer is a student. Type bool professional Whether the CodinGamer is a professional. Type bool pseudo Pseudo of the CodinGamer. Type Optional str tagline Tagline of the CodinGamer. Type Optional str biography Biography of the CodinGamer. Type Optional str company Company of the CodinGamer. Type Optional str school School of the CodinGamer. Type Optional str avatar Avatar ID of the CodinGamer. You can get the avatar url with avatar_url. Type Optional int

4.1. API Reference 23 codingame, Release 1.0.1

cover Cover ID of the CodinGamer. You can get the cover url with cover_url. Type Optional int property avatar_url Avatar URL of the CodinGamer. Type Optional str property cover_url Cover URL of the CodinGamer. Type Optional str property profile_url The URL of the CodinGamer profile. Type str get_followers() This function can be a coroutine. Get all the followers of a CodinGamer. You need to be logged in as the CodinGamer to get its followers or else a LoginRequired will be raised. If you can’t log in, you can use CodinGamer.get_followers_ids() instead.

Note: This property is a generator.

Raises LoginRequired – The Client needs to log in. See Client.login(). Yields CodinGamer – The follower.

get_followers_ids() This function can be a coroutine. Get all the IDs of the followers of a CodinGamer. Returns The CodinGamer’s followers IDs. See CodinGamer.id. Return type list get_followed() This function can be a coroutine. Get all the followed CodinGamers. You need to be logged in as the CodinGamer to get its followed CodinGamers or else a LoginRequired will be raised. If you can’t log in, you can use CodinGamer.get_followed_ids() instead.

Note: This property is a generator.

Raises LoginRequired – The Client needs to log in. See Client.login(). Yields CodinGamer – The followed CodinGamer.

get_followed_ids() This function can be a coroutine.

24 Chapter 4. API Reference codingame, Release 1.0.1

Get all the IDs of the followed CodinGamers. Returns The IDs of the followed CodinGamers. See CodinGamer.id. Return type list get_clash_of_code_rank() This function can be a coroutine. Get the Clash of Code rank of the CodinGamer. Returns The Clash of Code rank of the CodinGamer. Return type int

Clash of Code class codingame.ClashOfCode Represents a Clash of Code. public_handle Public handle of the Clash of Code (hexadecimal str). Type str join_url URL to join the Clash of Code. Type str public Whether the Clash of Code is public. Type bool min_players Minimum number of players. Type int max_players Maximum number of players. Type int modes List of possible modes. Type Optional list of str programming_languages List of possible programming languages. Type Optional list of str started Whether the Clash of Code is started. Type bool finished Whether the Clash of Code is finished. Type bool

4.1. API Reference 25 codingame, Release 1.0.1

mode The mode of the Clash of Code. Type Optional str creation_time Creation time of the Clash of Code. Type datetime.datetime start_time Start time of the Clash of Code. If the Clash of Code hasn’t started yet, this is the expected start time of the Clash of Code. Type datetime.datetime end_time End time of the Clash of Code. Type Optional datetime.datetime time_before_start Time before the start of the Clash of Code. Type datetime.timedelta time_before_end Time before the end of the Clash of Code. Type Optional datetime.timedelta players List of the players in the Clash of Code. Type list of Player class codingame.Player Represents a Clash of Code player. clash_of_code Clash of Code the Player belongs to. Type ClashOfCode public_handle Public handle of the CodinGamer (hexadecimal str). Type str id ID of the CodinGamer. Last 7 digits of the public_handle reversed. Type int pseudo Pseudo of the CodinGamer. Type int avatar Avatar ID of the CodinGamer. You can get the avatar url with avatar_url. Type Optional int cover Cover ID of the CodinGamer. In this case, always None.

26 Chapter 4. API Reference codingame, Release 1.0.1

Type Optional int started Whether the Clash of Code is started. Type bool finished Whether the Clash of Code is finished. Type bool status Status of the Player. Can be OWNER or STANDARD.

Note: You can use owner to get a bool that describes whether the player is the owner.

Type str

owner Whether the player is the Clash of Code owner. Type bool position Join position of the Player. Type Optional int rank Rank of the Player. Only use this when the Clash of Code is finished because it isn’t precise until then. Type Optional int duration Time taken by the player to solve the problem of the Clash of Code. Type Optional datetime.timedelta language_id Language ID of the language the player used in the Clash of Code. Type Optional str score Score of the Player (between 0 and 100). Type Optional int code_length Length of the Player’s code. Only available when the Clash of Code’s mode is SHORTEST. Type Optional int solution_shared Whether the Player shared his code. Type Optional bool submission_id ID of the player’s submission. Type Optional int

4.1. API Reference 27 codingame, Release 1.0.1

property avatar_url Avatar URL of the CodinGamer. Type Optional str property cover_url Cover URL of the CodinGamer. Type Optional str

Notification class codingame.Notification Represents a Notification. id ID of the notification. Type int type_group Group type of the notification. Type str type Precise type of the notification. Type str creation_time Creation time of the notification. Type datetime priority Priority of the notification. Type int urgent If the notification is urgent. Type bool data Data of the notification.

Note: Every notification type has different data. So there isn’t the same keys and values everytime.

Type dict

_raw The dict from CodinGame describing the notification. Useful when there’s more data that isn’t included in the normal fields. Type dict

28 Chapter 4. API Reference codingame, Release 1.0.1

Leaderboards

Global leaderboard class codingame.GlobalRankedCodinGamer Ranked CodinGamer in global leaderboard. property avatar_url Avatar URL of the CodinGamer. Type Optional str property cover_url Cover URL of the CodinGamer. Type Optional str class codingame.GlobalLeaderboard Global leaderboard. users Global leaderboard ranking. type Global leaderboard type. One of "GENERAL", "CONTESTS", "BOT_PROGRAMMING", "OPTIM", "CODEGOLF". group Group of CodinGamer who are ranked. One of "global", "country", "company", "school", "following". page Page of the leaderboard.

Challenge leaderboard class codingame.League League in a challenge or puzzle leaserboard. index Index of the league. count Number of users in the league. name Name of the league. users Name of the league. class codingame.ChallengeRankedCodinGamer Ranked CodinGamer in challenge leaderboards. property avatar_url Avatar URL of the CodinGamer. Type Optional str property cover_url Cover URL of the CodinGamer.

4.1. API Reference 29 codingame, Release 1.0.1

Type Optional str leaderboard The leaderboard that this CodinGamer is part of. percentage Test cases completion percentage of the CodinGamer. progress Progress of the CodinGamer. I don’t understand what this is, so if you know, please join the support server and tell me. programming_language The programming language used by the CodinGamer in this puzzle. test_session_handle The handle of the test session that tested the solution of the CodinGamer. league_rank The rank of the CodinGamer in their league. global_rank The rank of the CodinGamer in the world. league The league of the CodinGamer in this puzzle. class codingame.ChallengeLeaderboard Challenge leaderboard. users Challenge leaderboard ranking. leagues Leagues of the challenge. Empty list if no leagues. has_leagues Whether the challenge has leagues. name Name of the challenge. group Group of CodinGamer who are ranked. One of "global", "country", "company", "school", "following". programming_languages Number of CodinGamers who used a language in the challenge.

Puzzle leaderboard class codingame.PuzzleRankedCodinGamer Ranked CodinGamer in puzzle leaderboards. property avatar_url Avatar URL of the CodinGamer. Type Optional str property cover_url Cover URL of the CodinGamer.

30 Chapter 4. API Reference codingame, Release 1.0.1

Type Optional str leaderboard The leaderboard that this CodinGamer is part of. percentage Test cases completion percentage of the CodinGamer. progress Progress of the CodinGamer. I don’t understand what this is, so if you know, please join the support server and tell me. programming_language The programming language used by the CodinGamer in this puzzle. test_session_handle The handle of the test session that tested the solution of the CodinGamer. league_rank The rank of the CodinGamer in their league. global_rank The rank of the CodinGamer in the world. league The league of the CodinGamer in this puzzle. class codingame.PuzzleLeaderboard Puzzle leaderboard. users Puzzle leaderboard ranking. leagues Leagues of the puzzle. Empty list if no leagues. has_leagues Whether the puzzle has leagues. name Name of the puzzle. group Group of CodinGamer who are ranked. One of "global", "country", "company", "school", "following". programming_languages Number of CodinGamers who used a language in the puzzle.

4.1.4 Exceptions

The following exceptions are thrown by the library. exception codingame.CodinGameAPIError(message) Base exception for the CodinGame API. exception codingame.LoginError(message) Raised when the login data is incorrect. exception codingame.EmailRequired(message) Raised when the email given at login is empty.

4.1. API Reference 31 codingame, Release 1.0.1

exception codingame.MalformedEmail(message) Raised when the email given at login isn’t well formed. exception codingame.PasswordRequired(message) Raised when the password given at login is empty. exception codingame.EmailNotLinked(message) Raised when the email given at login isn’t linked to a CodinGamer account. exception codingame.IncorrectPassword(message) Raised when the password given at login is incorrect. exception codingame.LoginRequired(message=None) Raised when an action requires the client to log in. exception codingame.NotFound(message) Raised when something isn’t found. exception codingame.CodinGamerNotFound(message) Raised when a CodinGamer isn’t found. exception codingame.ClashOfCodeNotFound(message) Raised when a Clash of Code isn’t found. exception codingame.ChallengeNotFound(message) Raised when a Challenge isn’t found. exception codingame.PuzzleNotFound(message) Raised when a Puzzle isn’t found.

Exception Hierarchy

• Exception – CodinGameAPIError ∗ LoginError · EmailRequired · MalformedEmail · PasswordRequired · EmailNotLinked · IncorrectPassword · LoginRequired ∗ NotFound · CodinGamerNotFound · ClashOfCodeNotFound · ChallengeNotFound · PuzzleNotFound

32 Chapter 4. API Reference CHAPTER FIVE

CHANGELOG

5.1 Changelog

5.1.1 v1.0.1

• Add CodinGamer.profile_url.

5.1.2 v1.0.0

Rewrite. • Add support for asynchronous client with Client(is_async=True), see Asynchronous client. • Add support for context managers: # synchronous with Client() as client: client.get_global_leaderboard()

#asynchronous async with Client(is_async=True) as client: await client.get_global_leaderboard()

• Remove properties like CodinGamer.followers in favor of methods like CodinGamer.get_followers() to better differentiate API calls and to make it compatible with async API calls. Here’s a list of all ofthechanged ones: – Client.language_ids -> Client.get_language_ids() – Client.unseen_notifications -> Client.get_unseen_notifications() – CodinGamer.followers -> CodinGamer.get_followers() – CodinGamer.followers_ids -> CodinGamer.get_followers_ids() – CodinGamer.following -> CodinGamer.get_followed() – CodinGamer.following_ids -> CodinGamer.get_followed_ids() – CodinGamer.clash_of_code_rank -> CodinGamer.get_clash_of_code_rank() • Add more exceptions: LoginError regroups all the exceptions related to login: LoginRequired, EmailRequired, MalformedEmail, PasswordRequired, EmailNotLinked and IncorrectPassword. And NotFound regroups CodinGamerNotFound, ClashOfCodeNotFound, ChallengeNotFound and PuzzleNotFound

33 codingame, Release 1.0.1

• Make all attributes of CodinGame models read-only. • Add ChallengeLeaderboard.has_leagues and PuzzleLeaderboard.has_leagues. • Add Notification._raw. • Change ClashOfCode.time_before_start and ClashOfCode.time_before_end from float to datetime.timedelta. • Remove argument type validation, not my fault if you can’t read the docs. • Rewrite the way the client works to implement a class to manage the connection state and separate the Client that the user uses from the HTTP client that interacts with the API.

5.1.3 v0.4.0

Leaderboards support. • Add Client.get_global_leaderboard() with GlobalLeaderboard and GlobalRankedCodinGamer. • Add Client.get_challenge_leaderboard() with ChallengeLeaderboard, ChallengeRankedCodinGamer and League. • Add Client.get_puzzle_leaderboard() with PuzzleLeaderboard, PuzzleRankedCodinGamer and League. • Update docs style, code style and tests.

5.1.4 v0.3.5

• Add support for user IDs in Client.get_codingamer(). • Add CodinGamer.followers_ids and CodinGamer.following_ids to get information about followed users and followers without logging in. • Add CodinGamer.clash_of_code_rank.

5.1.5 v0.3.4

• Add support for python 3.9.

5.1.6 v0.3.3

• Add support for usernames in Client.get_codingamer(). • Add CodinGamer.xp.

34 Chapter 5. Changelog codingame, Release 1.0.1

5.1.7 v0.3.2

Pending Clash of Code support. • Add Client.get_pending_clash_of_code(). • Change Notification.date to Notification.creation_time.

5.1.8 v0.3.1

Notification support. • Add Client.notifications property and Notification class. • Add LoginRequired exception.

5.1.9 v0.3.0

Login support. • Add Client.login(). • Add Client.logged_in and Client.codingamer. • Add Client.language_ids property. • Add CodinGamer.followers and CodinGamer.following properties.

5.1.10 v0.2.1

• Add argument type validation.

5.1.11 v0.2.0

Clash of Code support. • Add Client.get_clash_of_code(), ClashOfCode, Player and ClashOfCodeNotFound. • Change Client.codingamer() to Client.get_codingamer().

5.1.12 v0.1.0

First release. • Add Client. • Add Client.codingamer(), CodinGamer and CodinGamerNotFound.

5.1. Changelog 35 codingame, Release 1.0.1

36 Chapter 5. Changelog CHAPTER SIX

INDICES AND TABLES

• genindex • search

37 codingame, Release 1.0.1

38 Chapter 6. Indices and tables INDEX

Symbols company (codingame.CodinGamer attribute), 23 __version__ (in module codingame), 13 count (codingame.League attribute), 29 _raw (codingame.Notification attribute), 28 country_id (codingame.CodinGamer attribute), 23 cover (codingame.CodinGamer attribute), 23 A cover (codingame.Player attribute), 26 cover_url codingame.ChallengeRankedCodinGamer AsyncClient (class in codingame.client.async_), 19 ( property avatar (codingame.CodinGamer attribute), 23 ), 29 cover_url codingame.CodinGamer property avatar (codingame.Player attribute), 26 ( ), 24 cover_url codingame.GlobalRankedCodinGamer avatar_url (codingame.ChallengeRankedCodinGamer ( property property), 29 ), 29 cover_url codingame.Player property avatar_url (codingame.CodinGamer property), 24 ( ), 28 cover_url codingame.PuzzleRankedCodinGamer avatar_url (codingame.GlobalRankedCodinGamer ( property property), 29 ), 30 creation_time codingame.ClashOfCode attribute avatar_url (codingame.Player property), 27 ( ), 26 creation_time codingame.Notification attribute avatar_url (codingame.PuzzleRankedCodinGamer ( ), 28 property), 30 B data (codingame.Notification attribute), 28 duration biography (codingame.CodinGamer attribute), 23 (codingame.Player attribute), 27 E category (codingame.CodinGamer attribute), 23 EmailNotLinked, 32 ChallengeLeaderboard (class in codingame), 30 EmailRequired, 31 ChallengeNotFound, 32 end_time (codingame.ClashOfCode attribute), 26 ChallengeRankedCodinGamer (class in codingame), 29 clash_of_code (codingame.Player attribute), 26 F ClashOfCode (class in codingame), 25 finished (codingame.ClashOfCode attribute), 25 ClashOfCodeNotFound, 32 finished (codingame.Player attribute), 27 Client (class in codingame), 13 close() (codingame.Client method), 13 G close() (codingame.client.async_.AsyncClient method), get_challenge_leaderboard() (codingame.Client 19 method), 13 close() (codingame.client.sync.SyncClient method), 19 get_challenge_leaderboard() code_length (codingame.Player attribute), 27 (codingame.client.async_.AsyncClient method), CodinGameAPIError, 31 21 CodinGamer (class in codingame), 22 get_challenge_leaderboard() codingamer (codingame.Client property), 13 (codingame.client.sync.SyncClient method), 18 codingamer (codingame.client.async_.AsyncClient get_clash_of_code() (codingame.Client method), 14 property), 22 get_clash_of_code() codingamer (codingame.client.sync.SyncClient prop- (codingame.client.async_.AsyncClient method), erty), 19 20 CodinGamerNotFound, 32

39 codingame, Release 1.0.1 get_clash_of_code() GlobalRankedCodinGamer (class in codingame), 29 (codingame.client.sync.SyncClient method), 17 group (codingame.ChallengeLeaderboard attribute), 30 get_clash_of_code_rank() (codingame.CodinGamer group (codingame.GlobalLeaderboard attribute), 29 method), 25 group (codingame.PuzzleLeaderboard attribute), 31 get_codingamer() (codingame.Client method), 14 get_codingamer() (codingame.client.async_.AsyncClient H method), 19 has_leagues (codingame.ChallengeLeaderboard get_codingamer() (codingame.client.sync.SyncClient attribute), 30 method), 16 has_leagues (codingame.PuzzleLeaderboard attribute), get_followed() (codingame.CodinGamer method), 24 31 get_followed_ids() (codingame.CodinGamer method), 24 I get_followers() (codingame.CodinGamer method), id (codingame.CodinGamer attribute), 22 24 id (codingame.Notification attribute), 28 get_followers_ids() (codingame.CodinGamer id (codingame.Player attribute), 26 method), 24 IncorrectPassword, 32 get_global_leaderboard() (codingame.Client index (codingame.League attribute), 29 method), 14 is_async (codingame.Client property), 16 get_global_leaderboard() is_async (codingame.client.async_.AsyncClient prop- (codingame.client.async_.AsyncClient method), erty), 22 20 is_async (codingame.client.sync.SyncClient property), get_global_leaderboard() 19 (codingame.client.sync.SyncClient method), 17 get_language_ids() (codingame.Client method), 15 J get_language_ids() (codingame.client.async_.AsyncClientjoin_url (codingame.ClashOfCode attribute), 25 method), 20 get_language_ids() (codingame.client.sync.SyncClient L method), 17 language_id (codingame.Player attribute), 27 get_pending_clash_of_code() (codingame.Client leaderboard (codingame.ChallengeRankedCodinGamer method), 15 attribute), 30 get_pending_clash_of_code() leaderboard (codingame.PuzzleRankedCodinGamer at- (codingame.client.async_.AsyncClient method), tribute), 31 20 League (class in codingame), 29 get_pending_clash_of_code() league (codingame.ChallengeRankedCodinGamer at- (codingame.client.sync.SyncClient method), 17 tribute), 30 get_puzzle_leaderboard() (codingame.Client league (codingame.PuzzleRankedCodinGamer at- method), 15 tribute), 31 get_puzzle_leaderboard() league_rank (codingame.ChallengeRankedCodinGamer (codingame.client.async_.AsyncClient method), attribute), 30 21 league_rank (codingame.PuzzleRankedCodinGamer at- get_puzzle_leaderboard() tribute), 31 (codingame.client.sync.SyncClient method), 18 leagues (codingame.ChallengeLeaderboard attribute), get_unseen_notifications() (codingame.Client 30 method), 16 leagues (codingame.PuzzleLeaderboard attribute), 31 get_unseen_notifications() level (codingame.CodinGamer attribute), 23 (codingame.client.async_.AsyncClient method), logged_in (codingame.Client property), 16 20 logged_in (codingame.client.async_.AsyncClient prop- get_unseen_notifications() erty), 22 (codingame.client.sync.SyncClient method), 17 logged_in (codingame.client.sync.SyncClient property), global_rank (codingame.ChallengeRankedCodinGamer 19 attribute), 30 login() (codingame.Client method), 16 global_rank (codingame.PuzzleRankedCodinGamer at- login() (codingame.client.async_.AsyncClient method), tribute), 31 19 GlobalLeaderboard (class in codingame), 29 login() (codingame.client.sync.SyncClient method), 16

40 Index codingame, Release 1.0.1

LoginError, 31 public (codingame.ClashOfCode attribute), 25 LoginRequired, 32 public_handle (codingame.ClashOfCode attribute), 25 public_handle (codingame.CodinGamer attribute), 22 M public_handle (codingame.Player attribute), 26 MalformedEmail, 31 PuzzleLeaderboard (class in codingame), 31 max_players (codingame.ClashOfCode attribute), 25 PuzzleNotFound, 32 min_players (codingame.ClashOfCode attribute), 25 PuzzleRankedCodinGamer (class in codingame), 30 mode (codingame.ClashOfCode attribute), 25 Python Enhancement Proposals modes (codingame.ClashOfCode attribute), 25 PEP 440, 13 N R rank name (codingame.ChallengeLeaderboard attribute), 30 (codingame.CodinGamer attribute), 22 rank name (codingame.League attribute), 29 (codingame.Player attribute), 27 name (codingame.PuzzleLeaderboard attribute), 31 S NotFound, 32 Notification (class in codingame), 28 school (codingame.CodinGamer attribute), 23 score (codingame.Player attribute), 27 O solution_shared (codingame.Player attribute), 27 start_time (codingame.ClashOfCode attribute), 26 owner (codingame.Player attribute), 27 started (codingame.ClashOfCode attribute), 25 P started (codingame.Player attribute), 27 status (codingame.Player attribute), 27 page (codingame.GlobalLeaderboard attribute), 29 student (codingame.CodinGamer attribute), 23 PasswordRequired, 32 submission_id (codingame.Player attribute), 27 percentage (codingame.ChallengeRankedCodinGamer SyncClient (class in codingame.client.sync), 16 attribute), 30 percentage (codingame.PuzzleRankedCodinGamer at- T tribute), 31 tagline (codingame.CodinGamer attribute), 23 Player (class in codingame), 26 test_session_handle players (codingame.ClashOfCode attribute), 26 (codingame.ChallengeRankedCodinGamer position (codingame.Player attribute), 27 attribute), 30 priority (codingame.Notification attribute), 28 test_session_handle professional (codingame.CodinGamer attribute), 23 (codingame.PuzzleRankedCodinGamer at- profile_url (codingame.CodinGamer property), 24 tribute), 31 programming_language time_before_end (codingame.ClashOfCode attribute), (codingame.ChallengeRankedCodinGamer 26 attribute), 30 time_before_start (codingame.ClashOfCode at- programming_language tribute), 26 (codingame.PuzzleRankedCodinGamer at- type (codingame.GlobalLeaderboard attribute), 29 tribute), 31 type (codingame.Notification attribute), 28 programming_languages type_group (codingame.Notification attribute), 28 (codingame.ChallengeLeaderboard attribute), 30 U programming_languages (codingame.ClashOfCode at- urgent (codingame.Notification attribute), 28 tribute), 25 users (codingame.ChallengeLeaderboard attribute), 30 programming_languages users (codingame.GlobalLeaderboard attribute), 29 (codingame.PuzzleLeaderboard attribute), users (codingame.League attribute), 29 31 users (codingame.PuzzleLeaderboard attribute), 31 progress (codingame.ChallengeRankedCodinGamer at- tribute), 30 V progress (codingame.PuzzleRankedCodinGamer version_info (in module codingame), 13 attribute), 31 pseudo (codingame.CodinGamer attribute), 23 X pseudo (codingame.Player attribute), 26 xp (codingame.CodinGamer attribute), 23

Index 41