Welcome to Distributed OJ

HTTP API for code submissions, job status, and worker coordination.

Available endpoints

Method Path Description
GET / Serves this HTML docs page.
GET /api/health Returns a small health payload.
POST /api/submit Validates a submission, stores it in MongoDB, and pushes its ID to Redis.
GET /api/submissions/:id Returns the current job record for a submission ID.

Endpoint details

GET /

Returns the landing page and docs as HTML.

Response

HTML document with a welcome message and endpoint reference.

GET /api/health

Use this to check that the API process is alive.

Response
{
  "status": "ok",
  "service": "distributed-oj-worker-server"
}
POST /api/submit

Creates a new job submission.

Request body
{
  "code": "int main() { return 0; }",
  "input": "",
  "expected": "",
  "language": "cpp",
  "timeLimit": 2000,
  "memoryLimit": 256
}
  • code, input, expected, and language are required strings.
  • language currently only accepts cpp.
  • timeLimit is optional and must be an integer between 100 and 8000.
  • memoryLimit is optional and must be an integer between 32 and 512.
Success response
{
  "message": "Submission accepted",
  "submissionId": "65f..."
}
GET /api/submissions/:id

Fetches the current submission record by MongoDB ID.

Response
{
  "_id": "65f...",
  "input": "",
  "expected": "",
  "language": "cpp",
  "timeLimit": 2000,
  "memoryLimit": 256,
  "status": "pending",
  "output": "",
  "verdict": "",
  "timeTaken": null,
  "memoryUsed": null,
  "error": ""
}