Skip to main content

codingame-tools

CI PyPI version Python versions License: MIT

Solve CodinGame puzzles and author CodinGame contributions from your own editor, under version control — instead of in the browser IDE.

Highlights

  • Browser login — CodinGame has no API tokens, so cg login drives a real browser and captures the session. Works with any sign-in method, including third-party identity providers. Credentials are stored per profile; a headless --manual path exists for CI.

  • Async client with structured API wrappersCgClient exposes 22 service endpoints as typed methods, with dataclasses for every request and response, plus a helper layer that handles retries and the CDN timeouts that heavy operations provoke.

  • Puzzle manager — a local working directory for solving a puzzle: import it, edit one file, run its test cases, submit. Language switching restores your own previous code, since CodinGame stores your latest source per language.

  • Contribution manager — a local working directory for a puzzle you're writing. data/ is a real git working tree with main/server/version-data branches, so syncing with CodinGame is a genuine fetch/rebase/merge workflow — conflicts included — rather than a one-shot overwrite.

  • A CLI exposing all of it — 148 commands, from the two workflow groups down to one subcommand per raw API method. Nothing is library-only.

  • Local validation — run your solution against real test cases with no network access at all. Output comparison reproduces CodinGame's own rule exactly, measured against the live service, so a local pass predicts a remote one.

  • VS Code integration, including debugging — generated run/debug configuration, breakpoints in your solution, and a test-case picker. Compiled languages build, run and debug inside Docker, so C++ works with no local toolchain at all.

  • The protocol, documented — CodinGame publishes no API spec. Every endpoint here was reverse-engineered, wrapped in dataclasses, and documented with what it actually does — including the parts that contradict what the name suggests. Where behaviour was confirmed by probing the live service, the docstring says so.

  • Fully typedmypy clean across the package and its tests, py.typed shipped.

Installation

pip install codingame-tools

Quick start -- solve a puzzle

cg login                          # opens a browser, saves credentials
cg whoami

# pull a puzzle into ./puzzle and make it the working puzzle
cg puzzle import --language Python3 ./puzzle temperatures

# implement a solution
$EDITOR "$(cg puzzle where)/data/solution.py"

cg puzzle play                    # Test locally against downloaded test cases -- no network
cg puzzle submit                  # graded submission

Quick start -- author a contribution

# Create a new contribution and make it the working contribution
# (purely local; nothing exists server-side until pushed)
cg contribution create -t PUZZLE_INOUT --language Python3 ./contribution "My Puzzle"
cd "$(cg contribution where)"

$EDITOR data/statement.cgmd
$EDITOR data/input_description.cgmd
$EDITOR data/output_description.cgmd
$EDITOR data/constraints.cgmd
$EDITOR data/stub_generator.cgstub
cp $COVER_ART_1920x1080_PNG data/cover.png

# Create a reference solution
$EDITOR data/solution.py

# Create a suite of test cases (both local and validator)
$EDITOR data/tests/**/*

# Validate the reference solution locally against all test cases
cg contribution play

# Push the contribution to the server
cg contribution push

# now it exists on server

Quick start -- use the async client directly:

import asyncio
from codingame_tools.client import CgClient

async def main() -> None:
    async with CgClient() as client:
        for c in await client.services.contribution.get_all_pending_contributions():
            print(c.public_handle, c.title)

asyncio.run(main())

Documentation

The first link is relative in the repository and is rewritten to an absolute, tag-pinned URL when a release is cut, so it resolves both on GitHub and on PyPI, and always points at the docs as they were for that version. The other two are absolute and deliberately unpinned, so they keep tracking prod-latest and main no matter which version's page you found them on.

Caveats

This talks to a private API by imitating the web client. It will occasionally break when CodinGame changes something, usually as a clear error naming the field that moved. And some operations are irreversible or publicly visible — submitting creates a permanent graded submission, pushing updates real content, and running a server-side test durably overwrites your saved code. Commands that do any of that say so.

Supported Python versions

Python 3.10 through 3.14.

License

MIT. See LICENSE.


For development and release workflow, see CONTRIBUTING.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codingame_tools-2.0.0.tar.gz (482.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codingame_tools-2.0.0-py3-none-any.whl (462.5 kB view details)

Uploaded Python 3

File details

Details for the file codingame_tools-2.0.0.tar.gz.

File metadata

  • Download URL: codingame_tools-2.0.0.tar.gz
  • Upload date:
  • Size: 482.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for codingame_tools-2.0.0.tar.gz
Algorithm Hash digest
SHA256 e93c7f59344bd56dea05690e159cd7ba30684ead0f5011ea3eac0a19a54bbb9f
MD5 0d0980b34c177e8f0d9836623084b3da
BLAKE2b-256 f355cefbf32ff6912707eceae57e1be2f59fdcb22b10638883a4081eb03bc32d

See more details on using hashes here.

Provenance

The following attestation bundles were made for codingame_tools-2.0.0.tar.gz:

Publisher: publish.yml on mckelvie-org/codingame-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codingame_tools-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: codingame_tools-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 462.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for codingame_tools-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4088542d4e4a5640a8fe9214b6e0c9ed2de8da26f8f0f587203c15d0e5bc57
MD5 ae02ac40130e20a4e0641156d66464f1
BLAKE2b-256 d641f1597706f778598460f5397cb26e7a288a01bb553dd3600cc209fe98a8e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for codingame_tools-2.0.0-py3-none-any.whl:

Publisher: publish.yml on mckelvie-org/codingame-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.0.3

2 files

This release

2.0.0 This release

2 files

1.0.5

2 files

1.0.3

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page