Judge0 Client
Asynchronous Python client for the Judge0 API. Built on top of httpx2 with Pydantic models for requests and responses.
This library helps you submit code to a Judge0 instance and retrieve execution results with clear, typed models and convenient error handling.
Highlights
- Async,
httpx2-based client - Pydantic models for request/response validation
- Single-file and multi-file submissions
- Fully automated Base64 handling for text fields and additional files
- Token-based auth header support
Requirements
- Python 3.10+
- A running Judge0 instance (public or self-hosted)
Installation
From PyPI:
pip install judge0-client
or
uv add judge0-client
Quick Start (async)
import asyncio
from judge0_client import Judge0Client, SingleFileSubmission
async def main() -> None:
# On many instances, language_id=71 corresponds to Python 3
req = SingleFileSubmission(
language_id=71,
source_code='print("Hello, Judge0!")',
)
async with Judge0Client(base_url="https://YOUR_JUDGE0_URL.com") as client:
# 1) Create submission — returns token
created = await client.create_submission(req)
# 2) Poll result by token
detail = await client.get_submission(created.token)
print("STATUS:", detail.status.description)
print("STDOUT:", detail.stdout)
if __name__ == "__main__":
asyncio.run(main())
Documentation
Usage
Client parameters
Judge0Client(
base_url: str, # Base URL of your Judge0 instance (no trailing slash)
timeout: float | httpx2.Timeout = 10.0,
auth_header: str = "X-Auth-Token", # Custom auth header name if needed
auth_token: str | SecretStr | None = None, # Token value passed in the auth header
)
Notes:
- The client sets
Accept: application/jsonandContent-Type: application/jsonheaders. - If
auth_tokenis provided, it will be sent as{auth_header}: <token>.
Single-file submissions
from judge0_client import SingleFileSubmission
req = SingleFileSubmission(
language_id=71,
source_code="print('sum =', int(input()) + 2)",
stdin="40\n",
)
# Then use it with the client as shown in the Quick Start.
You can attach additional files that will be zipped and Base64-encoded automatically:
from judge0_client import SingleFileSubmission
req = SingleFileSubmission(
language_id=71,
source_code="import helper; print(helper.answer())",
additional_files={
"helper.py": "def answer():\n return 42\n",
},
)
Multi-file submissions
Use MultiFileSubmission (language id=89 on Judge0 for multi-file/script-based runs). You must provide a run script in additional_files.
from judge0_client import MultiFileSubmission
req = MultiFileSubmission(
# language_id is fixed to 89 in this model
additional_files={
# Required run script
"run": "python main.py\n",
# Your sources
"main.py": "print('Hello from multi-file!')\n",
},
)
# Then use it with the client as shown in the Quick Start.
Error handling
Network or HTTP errors raise Judge0Error with helpful context:
import asyncio
from judge0_client import Judge0Client, SingleFileSubmission, Judge0Error
async def main() -> None:
try:
async with Judge0Client(base_url="https://judge0.ce.pdn.ac.lk") as client:
req = SingleFileSubmission(language_id=71, source_code="print('hi')")
created = await client.create_submission(req)
detail = await client.get_submission(created.token)
print(detail.stdout)
except Judge0Error as e:
# Inspect message, status code, and response body (if any)
print("Submission failed:", e)
if __name__ == "__main__":
asyncio.run(main())
Tips
- Language IDs differ across Judge0 instances. Check your instance’s languages endpoint to confirm IDs.
- The client and models automatically handle Base64 encoding for text fields (
source_code,stdin,expected_output) and additional files when required by Judge0.
Contributing
Contributions are welcome! Feel free to open an issue or a pull request.
License
MIT License — see LICENSE.
Metadata
Release files for judge0-client 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| judge0_client-0.4.0.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| judge0_client-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / judge0_client-0.4.0.tar.gz
| Download URL | judge0_client-0.4.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4040c25c7e8719260e6ba7f30dde3a00d3dfedca6b1fc2d4ea6c95e93546fc00
|
|
BLAKE2b-256 checksum How to use checksums |
1c39ecbddccce6bfc6ad2ab5739c8defa11232f0606796d6f1b9c10bc848087d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency logRelease files / judge0_client-0.4.0-py3-none-any.whl
| Download URL | judge0_client-0.4.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54e0f153eb24cc618d76cc3ce1c69edacf53bcaf2c4618d96a749f7039c9cdd4
|
|
BLAKE2b-256 checksum How to use checksums |
cb90f724e7a23caeade1cfc9051e7559aef66ae6698555c09b6d87947b4c569f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency log