Skip to content

codingame_tools.client.service.services.codingamer

codingamer

Async CodinGamer service endpoint.

CgCodingamerServiceHelper

CgCodingamerServiceHelper(service)

Bases: CgServiceHelper['CgCodingamerService']

Helper methods for CgCodingamerService. Currently empty.

Source code in codingame_tools/client/service/cg_service.py
124
125
def __init__(self, service: TService) -> None:
    self.service = service

CgCodingamerService

CgCodingamerService(client)

Bases: CgService

Async Codingamer service endpoint.

Source code in codingame_tools/client/service/services/codingamer.py
26
27
28
def __init__(self, client: CgClient) -> None:
    super().__init__(client, "CodinGamer")
    self.helper = CgCodingamerServiceHelper(self)

find_codingame_points_stats_by_handle async

find_codingame_points_stats_by_handle(handle)

Find a codingamer's points/ranking stats by their opaque public handle.

Parameters:

  • handle (str) –

    The codingamer's opaque public handle string (not their numeric ID).

Returns:

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a dict.

Source code in codingame_tools/client/service/services/codingamer.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
async def find_codingame_points_stats_by_handle(
            self,
            handle: str,
        ) -> CgCodingamePointsStats:
    """Find a codingamer's points/ranking stats by their opaque public handle.

    Args:
        handle: The codingamer's opaque public handle string (not their numeric ID).

    Returns:
        A CgCodingamePointsStats object.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a dict.
    """
    raw_stats = await self.service_request_to_dict(
            "findCodingamePointsStatsByHandle", [handle])
    return CgCodingamePointsStats.from_dict(raw_stats)

find_codingamer_public_informations async

find_codingamer_public_informations(codingamer_id=None)

Find a codingamer's public profile information by their numeric ID.

This is a genuinely public endpoint--no login is required when codingamer_id is explicitly provided. A login is only required to resolve the default codingamer_id when one is not provided.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer's numeric ID. If not provided, defaults to the logged-in codingamer's ID.

Returns:

Raises:

  • CgAuthenticationError

    If codingamer_id is not provided and no codingamer ID can be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a dict.

Source code in codingame_tools/client/service/services/codingamer.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
async def find_codingamer_public_informations(
            self,
            codingamer_id: int | None = None,
        ) -> CgCodingamer:
    """Find a codingamer's public profile information by their numeric ID.

       This is a genuinely public endpoint--no login is required when `codingamer_id` is
       explicitly provided. A login is only required to resolve the default
       `codingamer_id` when one is not provided.

    Args:
        codingamer_id: The codingamer's numeric ID. If not provided, defaults to the
                       logged-in codingamer's ID.

    Returns:
        A CgCodingamer object.

    Raises:
        CgAuthenticationError:
            If `codingamer_id` is not provided and no codingamer ID can be resolved from
            the session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a dict.
    """
    if codingamer_id is None:
        await self.require_authenticate()
        codingamer_id = self.client.codingamer_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    raw_codingamer = await self.service_request_to_dict(
            "findCodinGamerPublicInformations", [codingamer_id], require_login=False)
    return CgCodingamer.from_dict(raw_codingamer)

find_followers async

find_followers(codingamer_id=None, current_codingamer_id=None, arg3=None)

Find the followers of a codingamer.

Empirically, current_codingamer_id is not a free "viewpoint" parameter: the server rejects the call with a 422 unless it equals the logged-in codingamer's own ID, even when codingamer_id refers to a different codingamer. It appears to exist purely so the server can compute is_follower/is_following on each result relative to the logged-in codingamer, rather than relative to codingamer_id.

arg3's purpose is unknown. Passing a scalar (int, str, bool) causes a 422; only None and {} have been observed to succeed--possibly reserved for future pagination/filtering parameters.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer whose followers to list. Defaults to the logged-in codingamer's ID.

  • current_codingamer_id (int | None, default: None ) –

    Must equal the logged-in codingamer's ID (server-enforced; see above). Defaults to the logged-in codingamer's ID.

  • arg3 (dict[str, Any] | None, default: None ) –

    Third positional argument to the underlying findFollowers API call. Purpose unknown; defaults to None.

Returns:

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login, or if either ID is not provided and cannot be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a list.

Source code in codingame_tools/client/service/services/codingamer.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
async def find_followers(
            self,
            codingamer_id: int | None = None,
            current_codingamer_id: int | None = None,
            arg3: dict[str, Any] | None = None,
        ) -> list[CgCodingamerFollower]:
    """Find the followers of a codingamer.

       Empirically, `current_codingamer_id` is not a free "viewpoint" parameter: the server
       rejects the call with a 422 unless it equals the logged-in codingamer's own ID, even
       when `codingamer_id` refers to a different codingamer. It appears to exist purely so
       the server can compute `is_follower`/`is_following` on each result relative to the
       logged-in codingamer, rather than relative to `codingamer_id`.

       `arg3`'s purpose is unknown. Passing a scalar (int, str, bool) causes a 422; only
       `None` and `{}` have been observed to succeed--possibly reserved for future
       pagination/filtering parameters.

    Args:
        codingamer_id: The codingamer whose followers to list. Defaults to the logged-in
                       codingamer's ID.
        current_codingamer_id: Must equal the logged-in codingamer's ID (server-enforced;
                       see above). Defaults to the logged-in codingamer's ID.
        arg3:          Third positional argument to the underlying findFollowers API call.
                       Purpose unknown; defaults to None.

    Returns:
        A list of CgCodingamerFollower objects.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login, or if either ID
            is not provided and cannot be resolved from the session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a list.
    """
    await self.require_authenticate()
    own_id = self.client.codingamer_id
    if codingamer_id is None:
        codingamer_id = own_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    if current_codingamer_id is None:
        current_codingamer_id = own_id
        if current_codingamer_id is None:
            raise CgAuthenticationError()
    raw_followers = await self.service_request_to_list(
            "findFollowers", [codingamer_id, current_codingamer_id, arg3])
    return CgCodingamerFollower.from_list(cast(list[JsonDict], raw_followers))

find_following async

find_following(codingamer_id=None, current_codingamer_id=None)

Find the codingamers that a codingamer is following.

Same codingamer_id/current_codingamer_id semantics as find_followers (see its docstring)--current_codingamer_id must equal the logged-in codingamer's own ID, and serves only to compute is_follower/is_following from the logged-in codingamer's perspective. Unlike find_followers, there is no third (unknown) argument.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer whose followees to list. Defaults to the logged-in codingamer's ID.

  • current_codingamer_id (int | None, default: None ) –

    Must equal the logged-in codingamer's ID (server-enforced). Defaults to the logged-in codingamer's ID.

Returns:

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login, or if either ID is not provided and cannot be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a list.

Source code in codingame_tools/client/service/services/codingamer.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
async def find_following(
            self,
            codingamer_id: int | None = None,
            current_codingamer_id: int | None = None,
        ) -> list[CgCodingamerFollower]:
    """Find the codingamers that a codingamer is following.

       Same `codingamer_id`/`current_codingamer_id` semantics as `find_followers` (see its
       docstring)--`current_codingamer_id` must equal the logged-in codingamer's own ID, and
       serves only to compute `is_follower`/`is_following` from the logged-in codingamer's
       perspective. Unlike `find_followers`, there is no third (unknown) argument.

    Args:
        codingamer_id: The codingamer whose followees to list. Defaults to the logged-in
                       codingamer's ID.
        current_codingamer_id: Must equal the logged-in codingamer's ID (server-enforced).
                       Defaults to the logged-in codingamer's ID.

    Returns:
        A list of CgCodingamerFollower objects.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login, or if either ID
            is not provided and cannot be resolved from the session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a list.
    """
    await self.require_authenticate()
    own_id = self.client.codingamer_id
    if codingamer_id is None:
        codingamer_id = own_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    if current_codingamer_id is None:
        current_codingamer_id = own_id
        if current_codingamer_id is None:
            raise CgAuthenticationError()
    raw_following = await self.service_request_to_list(
            "findFollowing", [codingamer_id, current_codingamer_id])
    return CgCodingamerFollower.from_list(cast(list[JsonDict], raw_following))

find_codingamer_follow_card async

find_codingamer_follow_card(codingamer_id=None, current_codingamer_id=None)

Find a codingamer's follow-card summary--their public profile plus follow-relationship flags relative to another codingamer.

Same codingamer_id/current_codingamer_id semantics as find_followers (see its docstring)--current_codingamer_id must equal the logged-in codingamer's own ID (server-enforced with a 422 otherwise); it serves only to compute is_follower/is_following from the logged-in codingamer's perspective. The response shape is identical to a single entry of find_followers/find_following.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer whose follow card to fetch. Defaults to the logged-in codingamer's ID.

  • current_codingamer_id (int | None, default: None ) –

    Must equal the logged-in codingamer's ID (server-enforced). Defaults to the logged-in codingamer's ID.

Returns:

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login, or if either ID is not provided and cannot be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a dict.

Source code in codingame_tools/client/service/services/codingamer.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
async def find_codingamer_follow_card(
            self,
            codingamer_id: int | None = None,
            current_codingamer_id: int | None = None,
        ) -> CgCodingamerFollower:
    """Find a codingamer's follow-card summary--their public profile plus
       follow-relationship flags relative to another codingamer.

       Same `codingamer_id`/`current_codingamer_id` semantics as `find_followers` (see its
       docstring)--`current_codingamer_id` must equal the logged-in codingamer's own ID
       (server-enforced with a 422 otherwise); it serves only to compute
       `is_follower`/`is_following` from the logged-in codingamer's perspective. The response
       shape is identical to a single entry of `find_followers`/`find_following`.

    Args:
        codingamer_id: The codingamer whose follow card to fetch. Defaults to the logged-in
                       codingamer's ID.
        current_codingamer_id: Must equal the logged-in codingamer's ID (server-enforced).
                       Defaults to the logged-in codingamer's ID.

    Returns:
        A CgCodingamerFollower object.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login, or if either ID
            is not provided and cannot be resolved from the session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a dict.
    """
    await self.require_authenticate()
    own_id = self.client.codingamer_id
    if codingamer_id is None:
        codingamer_id = own_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    if current_codingamer_id is None:
        current_codingamer_id = own_id
        if current_codingamer_id is None:
            raise CgAuthenticationError()
    raw_card = await self.service_request_to_dict(
            "findCodingamerFollowCard", [codingamer_id, current_codingamer_id])
    return CgCodingamerFollower.from_dict(raw_card)

find_follower_ids async

find_follower_ids(codingamer_id=None)

Find the numeric IDs of a codingamer's followers.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer whose follower IDs to list. Defaults to the logged-in codingamer's ID.

Returns:

  • list[int]

    A list of numeric codingamer IDs.

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login, or if codingamer_id is not provided and no codingamer ID can be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a list.

Source code in codingame_tools/client/service/services/codingamer.py
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
async def find_follower_ids(
            self,
            codingamer_id: int | None = None,
        ) -> list[int]:
    """Find the numeric IDs of a codingamer's followers.

    Args:
        codingamer_id: The codingamer whose follower IDs to list. Defaults to the logged-in
                       codingamer's ID.

    Returns:
        A list of numeric codingamer IDs.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login, or if
            `codingamer_id` is not provided and no codingamer ID can be resolved from the
            session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a list.
    """
    if codingamer_id is None:
        await self.require_authenticate()
        codingamer_id = self.client.codingamer_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    raw_ids = await self.service_request_to_list("findFollowerIds", [codingamer_id])
    return cast(list[int], raw_ids)

find_following_ids async

find_following_ids(codingamer_id=None)

Find the numeric IDs of the codingamers that a codingamer is following.

Parameters:

  • codingamer_id (int | None, default: None ) –

    The codingamer whose followee IDs to list. Defaults to the logged-in codingamer's ID.

Returns:

  • list[int]

    A list of numeric codingamer IDs.

Raises:

  • CgAuthenticationError

    If the session is not authenticated and cannot implicitly login, or if codingamer_id is not provided and no codingamer ID can be resolved from the session's credentials.

  • CgClientHttpError

    If a transport error occurs, if the response content could not be decoded at all, if the status code is not 2xx, or if the decoded content is not a list.

Source code in codingame_tools/client/service/services/codingamer.py
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
async def find_following_ids(
            self,
            codingamer_id: int | None = None,
        ) -> list[int]:
    """Find the numeric IDs of the codingamers that a codingamer is following.

    Args:
        codingamer_id: The codingamer whose followee IDs to list. Defaults to the logged-in
                       codingamer's ID.

    Returns:
        A list of numeric codingamer IDs.

    Raises:
        CgAuthenticationError:
            If the session is not authenticated and cannot implicitly login, or if
            `codingamer_id` is not provided and no codingamer ID can be resolved from the
            session's credentials.
        CgClientHttpError:
            If a transport error occurs, if the response content could not be decoded at all,
            if the status code is not 2xx, or if the decoded content is not a list.
    """
    if codingamer_id is None:
        await self.require_authenticate()
        codingamer_id = self.client.codingamer_id
        if codingamer_id is None:
            raise CgAuthenticationError()
    raw_ids = await self.service_request_to_list("findFollowingIds", [codingamer_id])
    return cast(list[int], raw_ids)