Skip to content

CLI

Install and use the NextJudge CLI — download problems, test locally, submit, upload ICPC packs and manage events.

The CLI lives in src/cli/. It is a Python package invoked as nextjudge. Use it for file-based practice, bulk problem import, CI smoke tests and scripting.

Add the bin directory to your PATH:

Terminal window
export PATH="/path/to/NextJudge/src/cli/bin:$PATH"

Optional dependencies (uploads, YAML, JSON Schema validation):

Terminal window
pip install -r src/cli/requirements.txt

Also requires Python 3, requests, and Docker for test / run-with-input.

Tab completion: install argcomplete (optional).


Every command accepts:

FlagEnv fallbackDefaultDescription
--hostHOSTlocalhostAPI host
--portPORT5000API port
Terminal window
nextjudge --host api.example.com --port 5000 get 42

Port quirk: get, upload-challenge, upload-challenge-suite, and test-icpc-solutions* hardcode port 5000 internally regardless of --port.


There is no working nextjudge auth command (stub). Most commands auto-authenticate as a fixed local dev user:

FieldValue
Emailnextjudge-cli@local.dev
Passwordnextjudge-cli-local-password

Flow: POST /v1/basic_login, then register on failure. Token is sent as raw Authorization (no Bearer). See Authentication.

For production instances, ensure this account exists or use the API directly with your own credentials.

~/.nextjudge.config is defined in code but not loaded (commented out).


Written by get, read by submit when --id is omitted:

[config]
problem_id=42
PathContent
promptProblem statement
.nextjudge.envProblem ID
testcases/{n}.inPublic test input
testcases/{n}.ansExpected output

For upload-challenge, test-icpc-solutions, and event create:

problem-dir/
├── problem.yaml
├── problem_statement/problem.en.tex
├── data/sample/*.in, *.ans
├── data/secret/*.in, *.ans
└── submissions/accepted/ # for test-icpc-solutions

Download a problem. No auth.

Terminal window
nextjudge get 1

API: GET /v1/problems/{id}.


Submit to the remote judge and poll for verdict.

Terminal window
nextjudge get 3
nextjudge submit solution.py
nextjudge submit solution.cpp --id 42
  1. Resolve problem ID from --id or .nextjudge.env
  2. Match file extension to GET /v1/languages
  3. POST /v1/submissions, poll GET /v1/submissions/{id}/status (up to ~32 attempts, backoff 0.3s → 3.5s)

Run against local .in/.ans pairs in Docker (same judge image as production).

Terminal window
nextjudge test solution.py
nextjudge test solution.rs --tests ./my-tests --local-image

Default image: ghcr.io/nextjudge/judge:latest. --local-image uses nextjudge/judge.


Single local run with custom stdin (no test suite). Always uses nextjudge/judge image. --local-image is ignored.

Terminal window
nextjudge run-with-input solution.py "1 2 3"

Remote custom-input run via POST /v1/input_submissions. Currently broken in source — calls undefined get_test_user_id(). Use the web Run button or the API directly until fixed.


Upload one ICPC-format folder as a public problem.

Terminal window
nextjudge upload-challenge ./problems/a-plus-b

API: POST /v1/problems with public: true. On 409 conflict, treats as success.


Upload each immediate subdirectory as a separate public problem.

Terminal window
nextjudge upload-challenge-suite ./icpc-archive/2024/

test-icpc-solutions <directory> [--choose SUBSTRING]

Section titled “test-icpc-solutions <directory> [--choose SUBSTRING]”

Upload one ICPC problem, submit all files in submissions/accepted/ (skips .java), expect ACCEPTED.

Terminal window
nextjudge test-icpc-solutions ./problems/sum --choose solution.py

Submissions always target localhost:5000.


test-icpc-solutions-suite <directory> [--skip "dir1 dir2"]

Section titled “test-icpc-solutions-suite <directory> [--skip "dir1 dir2"]”

Batch version across many directories. Java only (inverse of single-problem test).


Create an event from event.yaml in the current directory.

title: Practice Round
description: Local practice
start_time: "2025-06-01T12:00:00Z"
end_time: "2025-06-01T18:00:00Z"
teams: false
problems:
- path: ./problems/sum
type: icpc

Known limitations:

  • YAML start_time / end_time are ignored — hardcoded dates in CLI today.
  • Only path + type: icpc problems work; name / id references error out.
  • Validation expects .vscode/test.json (may be missing); schema reference: src/cli/schema/event.json.
Terminal window
nextjudge event create

Fetch event JSON from the API. pull does not download problem files locally (same as get today).

Terminal window
nextjudge event get
nextjudge event get 7

Terminal window
nextjudge get 3
# edit solution using prompt + testcases/
nextjudge test solution.py
nextjudge submit solution.py
Terminal window
nextjudge upload-challenge-suite ./kattis-export/

The web editor supports live Run (custom input), language switching and contest context. The CLI targets file-based workflows and automation.


EndpointCommands
/v1/basic_login, /v1/basic_registerAuth helper
/v1/languagesExtension → language ID
/v1/problemsget, uploads
/v1/submissionssubmit
/v1/input_submissionscustom-run (broken)
/v1/eventsevent create, event get

Full reference: API.