codingame 1.5.0 API Reference#
The following section outlines the API of the codingame module. All the
public classes, methods and functions are documented here.
Client#
Hybrid client#
- class codingame.Client(is_async=False)[source]#
Client for the CodinGame API.
Instanciates a
SyncClientifis_asyncisFalseor not given. Instanciates aAsyncClientifis_asyncisTrue.Note
There are docs for both
SyncClientandAsyncClient.- Parameters:
is_async (bool) – Whether the client is asynchronous. Defaults to
False.
- property codingamer#
The CodinGamer that is logged in.
Noneif the client isn’t logged in.- Type:
Optional
CodinGamer
- abstract create_private_clash_of_code(language_ids=[], modes=[])#
This function can be a coroutine.
Create a private
Clash of Codewith specified programming languages and modes.You need to be logged in to create a Clash of Code or else a
LoginRequiredwill be raised.Note
If an invalid language is given, the API will ignores that language instead of raising an error. This function acts the same way.
- Parameters:
language_ids (
listofstr) – The programming languages allowed in the Clash of Code. Get the list of options withget_language_ids(). Default: All languages allowed.modes (
listofstr) – The modes from which the Clash of Code mode is chosen from. The valid modes are SHORTEST, FASTEST and REVERSE. Default: All modes allowed.
- Raises:
ValueError – The modes are invalid.
LoginRequired – The Client needs to log in. See
login().
- Returns:
ClashOfCodeThe created Clash Of Code.
.. versionadded:: 1.5
- abstract get_challenge_leaderboard(challenge_id, group='global')#
This function can be a coroutine.
Get the
leaderboard of a challenge.You can specify an optional group of users to rank.
- Parameters:
- 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:
ChallengeLeaderboardThe leaderboard of the requested challenge.
.. versionadded:: 0.4
- abstract get_clash_of_code(handle)#
This function can be a coroutine.
Get a
Clash of Codefrom 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:
ClashOfCodeThe requested Clash Of Code.
.. versionadded:: 0.2
- abstract get_codingamer(codingamer)#
This function can be a coroutine.
Get a
CodinGamerfrom their public handle, their ID or from their pseudo.Note
codingamercan be the public handle, the ID or the pseudo. Using the public handle or the ID is reccomended because it won’t change even if the codingamer changes their pseudo.The public handle is a 39 character long hexadecimal string that is unique to the CodinGamer and identifies them. Regex of a public handle:
[0-9a-f]{32}[0-9]{7}The ID is a 7 number long integer.
- Parameters:
codingamer (
strorint) – The CodinGamer’s public handle, ID or pseudo.- Raises:
CodinGamerNotFound – The CodinGamer with the given public handle, ID or pseudo isn’t found.
- Returns:
CodinGamerThe requested CodinGamer.
.. versionadded:: 0.1
.. versionchanged:: 0.2 – Renamed
Client.codingamer()toget_codingamer()... versionchanged:: 0.3.3 – Add searching with CodinGamer pseudo.
.. versionchanged:: 0.3.5 – Add searching with CodinGamer ID.
- abstract get_global_leaderboard(page=1, type='GENERAL', group='global')#
This function can be a coroutine.
Get the
global leaderboardof 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:
GlobalLeaderboardThe global leaderboard of CodinGame.
.. versionadded:: 0.4
- abstract get_language_ids()#
This function can be a coroutine.
Get the list of all available language IDs.
- Returns:
.. versionadded:: 0.3
.. versionchanged:: 1.0 – Renamed
Client.language_idstoget_language_ids().
- abstract get_pending_clash_of_code()#
This function can be a coroutine.
Get the pending public
Clash of Code.- Returns:
- Optional
ClashOfCode The pending Clash Of Code if there’s one, or
Noneif there’s no current public Clash Of Code.
- Optional
.. versionadded:: 0.3.2
- 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:
- 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:
PuzzleLeaderboardThe leaderboard of the requested puzzle.
.. versionadded:: 0.4
- abstract get_read_notifications()#
This function can be a coroutine.
Get the read
notificationsof the logged inCodinGamer.You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Warning
There can be some old notifications missing.
Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– A read notification.
New in version 1.3.
- abstract get_unread_notifications()#
This function can be a coroutine.
Get all the unread
notificationsof the logged inCodinGamer.This includes unseen notifications along with the unread ones.
You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– An unread notification.
New in version 1.3.
- abstract get_unseen_notifications()#
This function can be a coroutine.
Get all the unseen
notificationsof the logged inCodinGamer.You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– An unseen notification.
New in version 0.3.1.
Changed in version 1.0: Renamed
Client.notificationstoget_unseen_notifications().
- abstract join_private_clash_of_code(handle)#
This function can be a coroutine.
Join the private
Clash of Codewith the specified handle.You need to be logged in to join a Clash of Code or else a
LoginRequiredwill be raised.- Parameters:
handle (
ClashOfCodeorstr) – The Clash of Code to join or its public handle.- Raises:
ValueError – The Clash of Code handle isn’t in the good format.
LoginRequired – The Client needs to log in. See
login().ClashOfCodeFinished – The Clash of Code is already finished.
- Returns:
ClashOfCodeThe joined Clash Of Code.
.. versionadded:: 1.5
- abstract login(email=None, password=None, remember_me_cookie=None)#
This function can be a coroutine.
Login to a CodinGame account.
Error
As of 2021-10-27, the only way to login is with cookie authentication, so with the
remember_me_cookieparameter, because of an endpoint change, see Login. Using email/password authentication will raise aLoginError.- Parameters:
email (Optional
str) – Email adress of the CodinGamer. Not needed if using session ID login.password (Optional
str) – Password of the CodinGamer. Not needed if using cookie login.remember_me_cookie (Optional
str) –rememberMecookie from CodinGame cookies. Not needed if using email/password login.
- Raises:
LoginError – Error with the login (empty email, empty password, wrong email format, incorrect password, etc).
- Returns:
CodinGamerThe CodinGamer that logged in.
.. versionadded:: 0.3
- abstract mark_notifications_as_read(notifications)#
This function can be a coroutine.
Mark
notificationsof the logged inCodinGameras read.You need to be logged in to mark notifications as read or else a
LoginRequiredwill be raised.- Parameters:
notifications (
listofNotificationorint) – The notifications to mark as read. Can be either the notification or its ID.- Raises:
LoginRequired – The Client needs to log in. See
login().ValueError – notifications parameter is empty.
- Returns:
datetimeThe time when this notification was marked as read.
.. versionadded:: 1.4
- abstract mark_notifications_as_seen(notifications)#
This function can be a coroutine.
Mark
notificationsof the logged inCodinGameras seen.You need to be logged in to mark notifications as seen or else a
LoginRequiredwill be raised.- Parameters:
notifications (
listofNotificationorint) – The notifications to mark as seen. Can be either the notification or its ID.- Raises:
LoginRequired – The Client needs to log in. See
login().ValueError – notifications parameter is empty.
- Returns:
datetimeThe time when this notification was marked as seen.
.. versionadded:: 1.4
- request(service, func, parameters=[])#
This function can be a coroutine.
Make a request to the CodinGame API service.
This is useful if you want to use some services that aren’t implemented yet in this library, but you want to use the authentication that this library provides.
Note
The CodinGame API URLs are in the format
https://www.codingame.com/services/{service}/{func}.- Parameters:
- Raises:
ValueError –
serviceorfunctionparameter is empty.HTTPError – Error with the API (service or function not found, wrong number of parameters, bad parameters, etc).
- Returns:
- Anything
The data returned by the CodinGame API, usually a
dict.
.. versionadded:: 1.2
Synchronous client#
- class codingame.client.sync.SyncClient[source]#
Synchronous client for the CodinGame client.
- login(email=None, password=None, remember_me_cookie=None)[source]#
Login to a CodinGame account.
Error
As of 2021-10-27, the only way to login is with cookie authentication, so with the
remember_me_cookieparameter, because of an endpoint change, see Login. Using email/password authentication will raise aLoginError.- Parameters:
email (Optional
str) – Email adress of the CodinGamer. Not needed if using session ID login.password (Optional
str) – Password of the CodinGamer. Not needed if using cookie login.remember_me_cookie (Optional
str) –rememberMecookie from CodinGame cookies. Not needed if using email/password login.
- Raises:
LoginError – Error with the login (empty email, empty password, wrong email format, incorrect password, etc).
- Returns:
CodinGamerThe CodinGamer that logged in.
.. versionadded:: 0.3
- get_codingamer(codingamer)[source]#
Get a
CodinGamerfrom their public handle, their ID or from their pseudo.Note
codingamercan be the public handle, the ID or the pseudo. Using the public handle or the ID is reccomended because it won’t change even if the codingamer changes their pseudo.The public handle is a 39 character long hexadecimal string that is unique to the CodinGamer and identifies them. Regex of a public handle:
[0-9a-f]{32}[0-9]{7}The ID is a 7 number long integer.
- Parameters:
codingamer (
strorint) – The CodinGamer’s public handle, ID or pseudo.- Raises:
CodinGamerNotFound – The CodinGamer with the given public handle, ID or pseudo isn’t found.
- Returns:
CodinGamerThe requested CodinGamer.
.. versionadded:: 0.1
.. versionchanged:: 0.2 – Renamed
Client.codingamer()toget_codingamer()... versionchanged:: 0.3.3 – Add searching with CodinGamer pseudo.
.. versionchanged:: 0.3.5 – Add searching with CodinGamer ID.
- get_clash_of_code(handle)[source]#
Get a
Clash of Codefrom 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:
ClashOfCodeThe requested Clash Of Code.
.. versionadded:: 0.2
- get_pending_clash_of_code()[source]#
Get the pending public
Clash of Code.- Returns:
- Optional
ClashOfCode The pending Clash Of Code if there’s one, or
Noneif there’s no current public Clash Of Code.
- Optional
.. versionadded:: 0.3.2
- create_private_clash_of_code(language_ids=[], modes=[])[source]#
Create a private
Clash of Codewith specified programming languages and modes.You need to be logged in to create a Clash of Code or else a
LoginRequiredwill be raised.Note
If an invalid language is given, the API will ignores that language instead of raising an error. This function acts the same way.
- Parameters:
language_ids (
listofstr) – The programming languages allowed in the Clash of Code. Get the list of options withget_language_ids(). Default: All languages allowed.modes (
listofstr) – The modes from which the Clash of Code mode is chosen from. The valid modes are SHORTEST, FASTEST and REVERSE. Default: All modes allowed.
- Raises:
ValueError – The modes are invalid.
LoginRequired – The Client needs to log in. See
login().
- Returns:
ClashOfCodeThe created Clash Of Code.
.. versionadded:: 1.5
- join_private_clash_of_code(clash_of_code)[source]#
Join the private
Clash of Codewith the specified handle.You need to be logged in to join a Clash of Code or else a
LoginRequiredwill be raised.- Parameters:
handle (
ClashOfCodeorstr) – The Clash of Code to join or its public handle.- Raises:
ValueError – The Clash of Code handle isn’t in the good format.
LoginRequired – The Client needs to log in. See
login().ClashOfCodeFinished – The Clash of Code is already finished.
- Returns:
ClashOfCodeThe joined Clash Of Code.
.. versionadded:: 1.5
- get_language_ids()[source]#
Get the list of all available language IDs.
- Returns:
.. versionadded:: 0.3
.. versionchanged:: 1.0 – Renamed
Client.language_idstoget_language_ids().
- get_unseen_notifications()[source]#
Get all the unseen
notificationsof the logged inCodinGamer.You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– An unseen notification.
New in version 0.3.1.
Changed in version 1.0: Renamed
Client.notificationstoget_unseen_notifications().
- get_unread_notifications()[source]#
Get all the unread
notificationsof the logged inCodinGamer.This includes unseen notifications along with the unread ones.
You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– An unread notification.
New in version 1.3.
- get_read_notifications()[source]#
Get the read
notificationsof the logged inCodinGamer.You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Warning
There can be some old notifications missing.
Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– A read notification.
New in version 1.3.
- mark_notifications_as_seen(notifications)[source]#
Mark
notificationsof the logged inCodinGameras seen.You need to be logged in to mark notifications as seen or else a
LoginRequiredwill be raised.- Parameters:
notifications (
listofNotificationorint) – The notifications to mark as seen. Can be either the notification or its ID.- Raises:
LoginRequired – The Client needs to log in. See
login().ValueError – notifications parameter is empty.
- Returns:
datetimeThe time when this notification was marked as seen.
.. versionadded:: 1.4
- mark_notifications_as_read(notifications)[source]#
Mark
notificationsof the logged inCodinGameras read.You need to be logged in to mark notifications as read or else a
LoginRequiredwill be raised.- Parameters:
notifications (
listofNotificationorint) – The notifications to mark as read. Can be either the notification or its ID.- Raises:
LoginRequired – The Client needs to log in. See
login().ValueError – notifications parameter is empty.
- Returns:
datetimeThe time when this notification was marked as read.
.. versionadded:: 1.4
- get_global_leaderboard(page=1, type='GENERAL', group='global')[source]#
Get the
global leaderboardof 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:
GlobalLeaderboardThe global leaderboard of CodinGame.
.. versionadded:: 0.4
- get_challenge_leaderboard(challenge_id, group='global')[source]#
Get the
leaderboard of a challenge.You can specify an optional group of users to rank.
- Parameters:
- 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:
ChallengeLeaderboardThe leaderboard of the requested challenge.
.. versionadded:: 0.4
- get_puzzle_leaderboard(puzzle_id, group='global')[source]#
Get the
leaderboard of a puzzle.You can specify an optional group of users to rank.
- Parameters:
- 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:
PuzzleLeaderboardThe leaderboard of the requested puzzle.
.. versionadded:: 0.4
- property codingamer#
The CodinGamer that is logged in.
Noneif the client isn’t logged in.- Type:
Optional
CodinGamer
- request(service, func, parameters=[])#
This function can be a coroutine.
Make a request to the CodinGame API service.
This is useful if you want to use some services that aren’t implemented yet in this library, but you want to use the authentication that this library provides.
Note
The CodinGame API URLs are in the format
https://www.codingame.com/services/{service}/{func}.- Parameters:
- Raises:
ValueError –
serviceorfunctionparameter is empty.HTTPError – Error with the API (service or function not found, wrong number of parameters, bad parameters, etc).
- Returns:
- Anything
The data returned by the CodinGame API, usually a
dict.
.. versionadded:: 1.2
Asynchronous client#
- class codingame.client.async_.AsyncClient[source]#
Asynchronous client for the CodinGame API.
- async login(email=None, password=None, remember_me_cookie=None)[source]#
This function is a coroutine.
Login to a CodinGame account.
Error
As of 2021-10-27, the only way to login is with cookie authentication, so with the
remember_me_cookieparameter, because of an endpoint change, see Login. Using email/password authentication will raise aLoginError.- Parameters:
email (Optional
str) – Email adress of the CodinGamer. Not needed if using session ID login.password (Optional
str) – Password of the CodinGamer. Not needed if using cookie login.remember_me_cookie (Optional
str) –rememberMecookie from CodinGame cookies. Not needed if using email/password login.
- Raises:
LoginError – Error with the login (empty email, empty password, wrong email format, incorrect password, etc).
- Returns:
CodinGamerThe CodinGamer that logged in.
.. versionadded:: 0.3
- async get_codingamer(codingamer)[source]#
This function is a coroutine.
Get a
CodinGamerfrom their public handle, their ID or from their pseudo.Note
codingamercan be the public handle, the ID or the pseudo. Using the public handle or the ID is reccomended because it won’t change even if the codingamer changes their pseudo.The public handle is a 39 character long hexadecimal string that is unique to the CodinGamer and identifies them. Regex of a public handle:
[0-9a-f]{32}[0-9]{7}The ID is a 7 number long integer.
- Parameters:
codingamer (
strorint) – The CodinGamer’s public handle, ID or pseudo.- Raises:
CodinGamerNotFound – The CodinGamer with the given public handle, ID or pseudo isn’t found.
- Returns:
CodinGamerThe requested CodinGamer.
.. versionadded:: 0.1
.. versionchanged:: 0.2 – Renamed
Client.codingamer()toget_codingamer()... versionchanged:: 0.3.3 – Add searching with CodinGamer pseudo.
.. versionchanged:: 0.3.5 – Add searching with CodinGamer ID.
- async get_clash_of_code(handle)[source]#
This function is a coroutine.
Get a
Clash of Codefrom 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:
ClashOfCodeThe requested Clash Of Code.
.. versionadded:: 0.2
- async get_pending_clash_of_code()[source]#
This function is a coroutine.
Get the pending public
Clash of Code.- Returns:
- Optional
ClashOfCode The pending Clash Of Code if there’s one, or
Noneif there’s no current public Clash Of Code.
- Optional
.. versionadded:: 0.3.2
- async create_private_clash_of_code(language_ids=[], modes=[])[source]#
This function is a coroutine.
Create a private
Clash of Codewith specified programming languages and modes.You need to be logged in to create a Clash of Code or else a
LoginRequiredwill be raised.Note
If an invalid language is given, the API will ignores that language instead of raising an error. This function acts the same way.
- Parameters:
language_ids (
listofstr) – The programming languages allowed in the Clash of Code. Get the list of options withget_language_ids(). Default: All languages allowed.modes (
listofstr) – The modes from which the Clash of Code mode is chosen from. The valid modes are SHORTEST, FASTEST and REVERSE. Default: All modes allowed.
- Raises:
ValueError – The modes are invalid.
LoginRequired – The Client needs to log in. See
login().
- Returns:
ClashOfCodeThe created Clash Of Code.
.. versionadded:: 1.5
- async join_private_clash_of_code(clash_of_code)[source]#
This function is a coroutine.
Join the private
Clash of Codewith the specified handle.You need to be logged in to join a Clash of Code or else a
LoginRequiredwill be raised.- Parameters:
handle (
ClashOfCodeorstr) – The Clash of Code to join or its public handle.- Raises:
ValueError – The Clash of Code handle isn’t in the good format.
LoginRequired – The Client needs to log in. See
login().ClashOfCodeFinished – The Clash of Code is already finished.
- Returns:
ClashOfCodeThe joined Clash Of Code.
.. versionadded:: 1.5
- async get_language_ids()[source]#
This function is a coroutine.
Get the list of all available language IDs.
- Returns:
.. versionadded:: 0.3
.. versionchanged:: 1.0 – Renamed
Client.language_idstoget_language_ids().
- async get_unseen_notifications()[source]#
This function is a coroutine.
Get all the unseen
notificationsof the logged inCodinGamer.You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– An unseen notification.
New in version 0.3.1.
Changed in version 1.0: Renamed
Client.notificationstoget_unseen_notifications().
- async get_unread_notifications()[source]#
This function is a coroutine.
Get all the unread
notificationsof the logged inCodinGamer.This includes unseen notifications along with the unread ones.
You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– An unread notification.
New in version 1.3.
- async get_read_notifications()[source]#
This function is a coroutine.
Get the read
notificationsof the logged inCodinGamer.You need to be logged in to get notifications or else a
LoginRequiredwill be raised.Warning
There can be some old notifications missing.
Note
This method is a generator.
- Raises:
LoginRequired – The Client needs to log in. See
login().- Yields:
Notification– A read notification.
New in version 1.3.
- async mark_notifications_as_seen(notifications)[source]#
This function is a coroutine.
Mark
notificationsof the logged inCodinGameras seen.You need to be logged in to mark notifications as seen or else a
LoginRequiredwill be raised.- Parameters:
notifications (
listofNotificationorint) – The notifications to mark as seen. Can be either the notification or its ID.- Raises:
LoginRequired – The Client needs to log in. See
login().ValueError – notifications parameter is empty.
- Returns:
datetimeThe time when this notification was marked as seen.
.. versionadded:: 1.4
- async mark_notifications_as_read(notifications)[source]#
This function is a coroutine.
Mark
notificationsof the logged inCodinGameras read.You need to be logged in to mark notifications as read or else a
LoginRequiredwill be raised.- Parameters:
notifications (
listofNotificationorint) – The notifications to mark as read. Can be either the notification or its ID.- Raises:
LoginRequired – The Client needs to log in. See
login().ValueError – notifications parameter is empty.
- Returns:
datetimeThe time when this notification was marked as read.
.. versionadded:: 1.4
- async get_global_leaderboard(page=1, type='GENERAL', group='global')[source]#
This function is a coroutine.
Get the
global leaderboardof 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:
GlobalLeaderboardThe global leaderboard of CodinGame.
.. versionadded:: 0.4
- async get_challenge_leaderboard(challenge_id, group='global')[source]#
This function is a coroutine.
Get the
leaderboard of a challenge.You can specify an optional group of users to rank.
- Parameters:
- 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:
ChallengeLeaderboardThe leaderboard of the requested challenge.
.. versionadded:: 0.4
- async get_puzzle_leaderboard(puzzle_id, group='global')[source]#
This function is a coroutine.
Get the
leaderboard of a puzzle.You can specify an optional group of users to rank.
- Parameters:
- 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:
PuzzleLeaderboardThe leaderboard of the requested puzzle.
.. versionadded:: 0.4
- property codingamer#
The CodinGamer that is logged in.
Noneif the client isn’t logged in.- Type:
Optional
CodinGamer
- request(service, func, parameters=[])#
This function can be a coroutine.
Make a request to the CodinGame API service.
This is useful if you want to use some services that aren’t implemented yet in this library, but you want to use the authentication that this library provides.
Note
The CodinGame API URLs are in the format
https://www.codingame.com/services/{service}/{func}.- Parameters:
- Raises:
ValueError –
serviceorfunctionparameter is empty.HTTPError – Error with the API (service or function not found, wrong number of parameters, bad parameters, etc).
- Returns:
- Anything
The data returned by the CodinGame API, usually a
dict.
.. versionadded:: 1.2
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.PartialCodinGamer(state, data)[source]#
Represents a partial CodinGamer.
This class doesn’t have all the data of a CodinGamer. Use
client.get_codingamer(partial_codingamer.public_handle)for that.- id#
ID of the CodinGamer. Last 7 digits of the
public_handlereversed.- Type:
- avatar#
Avatar ID of the CodinGamer. You can get the avatar url with
avatar_url.- Type:
Optional
int
- get_followers()[source]#
This function can be a coroutine.
Get all the followers of a CodinGamer.
You need to be logged in to get the followers or else a
LoginRequiredwill be raised. If you can’t log in, you can useCodinGamer.get_followers_ids()instead.Note
This property is a generator.
Warning
The
xpattribute of the following codingamers isNone.- Raises:
LoginRequired – The Client needs to log in. See
Client.login().- Yields:
CodinGamer– The follower.
- get_followers_ids()[source]#
This function can be a coroutine.
Get all the IDs of the followers of a CodinGamer.
- Returns:
listofintThe CodinGamer’s followers IDs. See
CodinGamer.id.
- get_followed()[source]#
This function can be a coroutine.
Get all the followed CodinGamers.
You need to be logged in to get the followed CodinGamers or else a
LoginRequiredwill be raised. If you can’t log in, you can useCodinGamer.get_followed_ids()instead.Note
This property is a generator.
Warning
The
xpattribute of the followed codingamers isNone.- Raises:
LoginRequired – The Client needs to log in. See
Client.login().- Yields:
CodinGamer– The followed CodinGamer.
- class codingame.CodinGamer(state, data)[source]#
Represents a CodinGamer.
- id#
ID of the CodinGamer. Last 7 digits of the
public_handlereversed.- Type:
- category#
Category of the CodinGamer. Can be
STUDENTorPROFESSIONAL.Note
You can use
studentandprofessionalto get aboolthat describes the CodinGamer’s category.- Type:
Optional
str
- avatar#
Avatar ID of the CodinGamer. You can get the avatar url with
avatar_url.- Type:
Optional
int
- get_clash_of_code_rank()#
This function can be a coroutine.
Get the Clash of Code rank of the CodinGamer.
- Returns:
intThe Clash of Code rank of the CodinGamer.
- get_followed()#
This function can be a coroutine.
Get all the followed CodinGamers.
You need to be logged in to get the followed CodinGamers or else a
LoginRequiredwill be raised. If you can’t log in, you can useCodinGamer.get_followed_ids()instead.Note
This property is a generator.
Warning
The
xpattribute of the followed codingamers isNone.- 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.
Get all the IDs of the followed CodinGamers.
- Returns:
listofintThe IDs of the followed CodinGamers. See
CodinGamer.id.
- get_followers()#
This function can be a coroutine.
Get all the followers of a CodinGamer.
You need to be logged in to get the followers or else a
LoginRequiredwill be raised. If you can’t log in, you can useCodinGamer.get_followers_ids()instead.Note
This property is a generator.
Warning
The
xpattribute of the following codingamers isNone.- 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:
listofintThe CodinGamer’s followers IDs. See
CodinGamer.id.
Clash of Code#
- class codingame.ClashOfCode(state, data)[source]#
Represents a Clash of Code.
- 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:
- fetch()[source]#
This function can be a coroutine.
Get and update the information about this Clash Of Code.
This modifies this object’s own attributes in place.
- join(refetch=False)[source]#
This function can be a coroutine.
Join this Clash Of Code.
You need to be logged in to join a Clash of Code or else a
LoginRequiredwill be raised.- Parameters:
refetch (
bool) – Whether to update this object after joining. Default: False- Raises:
LoginRequired – The Client needs to log in. See
Client.login().
- start(refetch=False)[source]#
This function can be a coroutine.
Start this Clash Of Code.
You need to be logged in as the owner to start a Clash of Code or else a
LoginRequiredwill be raised.Note
This sets the countdown to the start to 5s. You will need to fetch the Clash Of Code again in 5-10s.
- Parameters:
refetch (
bool) – Whether to update this object after starting. Default: False- Raises:
LoginRequired – The Client needs to log in. See
Client.login().
- leave(refetch=False)[source]#
This function can be a coroutine.
Leave this Clash Of Code.
You need to be logged in or else a
LoginRequiredwill be raised.- Parameters:
refetch (
bool) – Whether to update this object after leaving. Default: False- Raises:
LoginRequired – The Client needs to log in. See
Client.login().
- get_question(refetch=False)[source]#
This function can be a coroutine.
Get the question for this Clash of Code.
You need to be logged in or else a
LoginRequiredwill be raised.- Parameters:
refetch (
bool) – Whether to update this object after getting the question. Default: False- Raises:
LoginRequired – The Client needs to log in. See
Client.login().
- play_test_cases(language_id, code, indexes=None, refetch=False)[source]#
This function can be a coroutine.
Play test cases for this Clash of Code with the given code.
You need to be logged in or else a
LoginRequiredwill be raised.- Parameters:
language_id (
str) – The language ID of the used programming language.code (
str) – The code to test against the test cases.indexes (
listofint) – The indexes of the test cases to test the code. Default: all test casesrefetch (
bool) – Whether to update this object after getting the question. Default: False
- Raises:
LoginRequired – The Client needs to log in. See
Client.login().
- submit(language_id, code, share=False, refetch=False)[source]#
This function can be a coroutine.
Submit your solution for this Clash of Code.
You need to be logged in or else a
LoginRequiredwill be raised.- Parameters:
- Raises:
LoginRequired – The Client needs to log in. See
Client.login().
- class codingame.Player(state, clash_of_code, started, finished, data)[source]#
Represents a Clash of Code player.
- clash_of_code#
Clash of Code the Player belongs to.
- Type:
- public_handle#
Public handle of the CodinGamer (hexadecimal str). Sometimes missing, prefer
id.- Type:
- id#
ID of the CodinGamer. Last 7 digits of the
public_handlereversed.- Type:
- avatar#
Avatar ID of the CodinGamer. You can get the avatar url with
avatar_url.- 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
timedelta
- code_length#
Length of the Player’s code. Only available when the Clash of Code’s mode is
SHORTEST.- Type:
Optional
int
Whether the Player shared their code.
- Type:
Optional
bool
Notification#
- class codingame.Notification(state, data)[source]#
Represents a Notification.
- type_group#
Group type of the notification.
- Type:
- type#
Precise type of the notification.
- Type:
- data#
Data of the notification.
Note
Every notification type has different data. So there isn’t the same keys and values every time.
- Type:
Optional
dict
- codingamer#
CodinGamer that sent the notification, only appears in some notification types.
- Type:
Optional
PartialCodinGamer
- mark_as_seen()[source]#
This function can be a coroutine.
Mark this notification as seen.
Warning
If you want to mark multiple notifications as seen at the same time, use
Client.mark_notifications_as_seen()as it only makes one API request for all the notifications instead of one API request for each notification.- Returns:
datetimeThe time when this notification was marked as seen.
.. versionadded:: 1.4
- mark_as_read()[source]#
This function can be a coroutine.
Mark this notification as read.
Warning
If you want to mark multiple notifications as read at the same time, use
Client.mark_notifications_as_read()as it only makes one API request for all the notifications instead of one API request for each notification.- Returns:
datetimeThe time when this notification was marked as read.
.. versionadded:: 1.4
Enumerations#
- class codingame.NotificationTypeGroup[source]#
Enumeration for the
Notification.type_group.Warning
There might be some missing type groups.
- class codingame.NotificationType[source]#
Enumeration for the
Notification.type.- new_league = 'new-league'#
Type:
strWhen a new league is added to an arena.
If the new league is higher than your current one, you will get demoted, otherwise your league will stay the same.
- eligible_for_next_league = 'eligible-for-next-league'#
Type:
strWhen you are better than the boss of your current league.
This means you will be promoted soon.
- contribution_clash_mode_removed = 'contribution-clash-mode-removed'#
Type:
strWhen your contribution is modified.
- contribution_moderated = 'contribution-moderated'#
Type:
strWhen your contribution is validated or denied.
- new_league_opened = 'new-league-opened'#
Type:
strWhen a new league is opened.
I don’t know why this isn’t in
NotificationTypeGroup.arenalikeNotificationType.new_league,NotificationType.eligible_for_next_leagueandNotificationType.promoted_league.
Notification data#
- class codingame.LanguageMapping(state, mapping)[source]#
Mapping to store text with multiple languages.
This class has the same interface as
dictfor backwards compatibility.
- class codingame.NotificationData(state, data)[source]#
Base class for the notification data classes.
This class has the same interface as
dictfor backwards compatibility.- _raw#
Raw data of the
Notification, useful when one of the values isn’t an attribute.- Type:
- classmethod from_type(type, state, data)[source]#
Create the correct
NotificationDatasubclass according to thenotification type.- Parameters:
type (
NotificationType) – The notification type.data (
dict) – The notification data.
- Returns:
NotificationDataThe parsed data of the notifcation.
- class codingame.AchievementUnlockedData(state, data)[source]#
Data of a
NotificationType.achievement_unlockednotification.- label#
Type:
LanguageMapping
- class codingame.LeagueData(state, data)[source]#
Data of
NotificationType.new_league,NotificationType.eligible_for_next_league,NotificationType.promoted_leagueandNotificationType.new_league_openednotifications.- title_label#
Type:
LanguageMapping
- class codingame.NewBlogData(state, data)[source]#
Data of a
NotificationType.new_blognotification.- title#
Type:
LanguageMapping
- url#
Type:
LanguageMapping
- class codingame.ClashInviteData(state, data)[source]#
Data of a
NotificationType.clash_invitenotification.
- class codingame.ClashOverData(state, data)[source]#
Data of a
NotificationType.clash_overnotification.
- class codingame.Contribution(state, data)[source]#
Data about a contribution.
This class has the same interface as
dictfor backwards compatibility.
- class codingame.PuzzleSolution(state, data)[source]#
Data about a puzzle solution.
This class has the same interface as
dictfor backwards compatibility.
- class codingame.NewCommentData(state, data)[source]#
Data of a
NotificationType.new_commentandNotificationType.new_comment_responsenotifications.- type#
Type:
LanguageMapping
- class codingame.ContributionData(state, data)[source]#
Data of
NotificationType.contribution_received,NotificationType.contribution_accepted,NotificationType.contribution_refusedandNotificationType.contribution_clash_mode_removednotifications.
- class codingame.FeatureData(state, data)[source]#
Data of a
NotificationType.featurenotification.- description#
Type:
LanguageMapping
- class codingame.NewHintData(state, data)[source]#
Data of a
NotificationType.new_hintnotification.- puzzle_title#
Type:
LanguageMapping
- class codingame.ContributionModeratedData(state, data)[source]#
Data of a
NotificationType.contribution_moderatednotification.- action_type#
Type:
ContributionModeratedActionType
- contribution#
Type:
Contribution
- class codingame.NewPuzzleData(state, data)[source]#
Data of a
NotificationType.new_puzzlenotification.- level#
Type:
LanguageMapping
- name#
Type:
LanguageMapping
- class codingame.PuzzleOfTheWeekData(state, data)[source]#
Data of a
NotificationType.puzzle_of_the_weeknotification.- puzzle_name#
Type:
LanguageMapping
- class codingame.QuestCompletedData(state, data)[source]#
Data of a
NotificationType.quest_completednotification.- label#
Type:
LanguageMapping
- class codingame.FriendRegisteredData(state, data)[source]#
Data of a
NotificationType.friend_registerednotification.
- class codingame.NewLevelData(state, data)[source]#
Data of a
NotificationType.new_levelnotification.
- class codingame.GenericData(state, data)[source]#
Data of a
NotificationType.info_generic,NotificationType.warning_genericandNotificationType.important_genericnotifications.- title#
Type:
LanguageMapping
- description#
Type:
LanguageMapping
- class codingame.CustomData(state, data)[source]#
Data of a
NotificationType.customnotification.- title#
Type:
LanguageMapping
- description#
Type:
LanguageMapping
- class codingame.CareerCandidateData(state, data)[source]#
Data of a
NotificationType.career_new_candidateandNotificationType.career_update_candidatenotifications.
- class codingame.TestFinishedData(state, data)[source]#
Data of a
NotificationType.test_finishednotification.
- class codingame.JobAcceptedData(state, data)[source]#
Data of a
NotificationType.job_acceptednotification.
- class codingame.JobExpiredData(state, data)[source]#
Data of a
NotificationType.job_expirednotification.
- class codingame.NewWorkBlogData(state, data)[source]#
Data of a
NotificationType.new_work_blognotification.- title#
Type:
LanguageMapping
- url#
Type:
LanguageMapping
- class codingame.OfferApplyData(state, data)[source]#
Data of a
NotificationType.offer_applynotification.
Leaderboards#
Global leaderboard#
- class codingame.GlobalRankedCodinGamer(state, leaderboard, data)[source]#
Ranked CodinGamer in global leaderboard.
- leaderboard#
Type:
GlobalLeaderboard
- avatar#
Type:
MemberDescriptorType
- category#
Type:
MemberDescriptorType
- company#
Type:
MemberDescriptorType
- country_id#
Type:
MemberDescriptorType
- cover#
Type:
MemberDescriptorType
- id#
Type:
MemberDescriptorType
- level#
Type:
MemberDescriptorType
- professional#
Type:
MemberDescriptorType
- pseudo#
Type:
MemberDescriptorType
- public_handle#
Type:
MemberDescriptorType
- rank#
Type:
MemberDescriptorType
- school#
Type:
MemberDescriptorType
- score#
Type:
MemberDescriptorType
- student#
Type:
MemberDescriptorType
- class codingame.GlobalLeaderboard(state, lb_type, group, page, data)[source]#
Global leaderboard.
- type#
Type:
strGlobal leaderboard type. One of
"GENERAL","CONTESTS","BOT_PROGRAMMING","OPTIM","CODEGOLF".
- group#
Type:
strGroup of CodinGamer who are ranked. One of
"global","country","company","school","following".
- count#
Type:
MemberDescriptorType
Challenge leaderboard#
- class codingame.ChallengeRankedCodinGamer(state, leaderboard, data)[source]#
Ranked CodinGamer in challenge leaderboards.
- avatar#
Type:
MemberDescriptorType
- category#
Type:
MemberDescriptorType
- company#
Type:
MemberDescriptorType
- country_id#
Type:
MemberDescriptorType
- cover#
Type:
MemberDescriptorType
- id#
Type:
MemberDescriptorType
- level#
Type:
MemberDescriptorType
- professional#
Type:
MemberDescriptorType
- pseudo#
Type:
MemberDescriptorType
- public_handle#
Type:
MemberDescriptorType
- rank#
Type:
MemberDescriptorType
- school#
Type:
MemberDescriptorType
- score#
Type:
MemberDescriptorType
- student#
Type:
MemberDescriptorType
- leaderboard#
Type:
ChallengeLeaderboardThe leaderboard that this CodinGamer is part of.
- progress#
-
Progress of the CodinGamer. I don’t understand what this is, so if you know, please join the support server and tell me.
Puzzle leaderboard#
- class codingame.PuzzleRankedCodinGamer(state, leaderboard, data)[source]#
Ranked CodinGamer in puzzle leaderboards.
- avatar#
Type:
MemberDescriptorType
- category#
Type:
MemberDescriptorType
- company#
Type:
MemberDescriptorType
- country_id#
Type:
MemberDescriptorType
- cover#
Type:
MemberDescriptorType
- id#
Type:
MemberDescriptorType
- level#
Type:
MemberDescriptorType
- professional#
Type:
MemberDescriptorType
- pseudo#
Type:
MemberDescriptorType
- public_handle#
Type:
MemberDescriptorType
- rank#
Type:
MemberDescriptorType
- school#
Type:
MemberDescriptorType
- score#
Type:
MemberDescriptorType
- student#
Type:
MemberDescriptorType
- leaderboard#
Type:
PuzzleLeaderboardThe leaderboard that this CodinGamer is part of.
- progress#
-
Progress of the CodinGamer. I don’t understand what this is, so if you know, please join the support server and tell me.
Exceptions#
The following exceptions are thrown by the library.
- exception codingame.MalformedEmail(message)[source]#
Raised when the email given at login isn’t well formed.
- exception codingame.PasswordRequired(message)[source]#
Raised when the password given at login is empty.
- exception codingame.EmailNotLinked(message)[source]#
Raised when the email given at login isn’t linked to a CodinGamer account.
- exception codingame.IncorrectPassword(message)[source]#
Raised when the password given at login is incorrect.
- exception codingame.WrongCaptchaAnswer(message)[source]#
Raised when the captcha in the email/password login is incorrect.
See Login to fix this
- exception codingame.LoginRequired(message=None)[source]#
Raised when an action requires the client to log in.
- exception codingame.ClashOfCodeError(message)[source]#
Raised when there is an error with a Clash of Code.
- exception codingame.ClashOfCodeCancelled(message)[source]#
Raised when trying to join a Clash of Code that was cancelled.
- exception codingame.ClashOfCodeStarted(message)[source]#
Raised when trying to join an already started Clash of Code.
- exception codingame.ClashOfCodeFinished(message)[source]#
Raised when trying to join an already finished Clash of Code.
- exception codingame.ClashOfCodeFull(message)[source]#
Raised when trying to join a Clash of Code that reached the maximum number of players.