CodeBattles
Github
RU_v3
RU_v3
  • О системе V3
  • Обзор
    • Интерфейс участника
    • Интерфейс администратора
      • Задачи
      • Чекеры
      • Соревнования
  • Настройка и установка системы
    • Установка
      • Локальная установка
      • Production установка
  • Первое соревнование
    • Создать соревнование
  • Инструкции
    • Соревнование
      • Создание соревнования
      • Редактирование чекеров соревнования
      • Редактирование пользователей соревнования
      • Редактирование задач соревнования
    • Задачи
      • Добавить задачу
      • Изменить задачу
      • Удалить задачу
    • Пользователи
      • Регистрация пользователей
    • Чекеры
      • Создание чекера
      • Изменение чекера
      • Удаление чекера
  • Как работает система
    • Архитектура
    • Безопасность
  • API
    • Введение в API
    • Backend
      • Checkers
      • Competition Problems
      • Users
      • Answer
      • Competitions
      • Ping Pong
      • Problems
      • Auth
      • Checker system API
      • Models
    • Checker API
      • HealthCheck
      • Test
Powered by GitBook
On this page

Was this helpful?

  1. API
  2. Backend

Competitions

PreviousAnswerNextPing Pong

Was this helpful?

Endpoints for managing competitions

[ADMIN] Get all competitions

get

Retrieves a list of all competitions. Required admin role.

Authorizations
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
[
  {
    "id": 1,
    "checkers": [
      {
        "id": 1,
        "displayName": "Default Python3 Checker",
        "languageHighlightName": "python"
      }
    ],
    "name": "Code Battles 2023",
    "description": "A competitive coding event",
    "startedAt": "2023-01-01T10:00:00",
    "endedAt": "2023-01-01T18:00:00"
  }
]

Get competition by ID

get

Retrieves competition details by its ID. Requires access to the competition.

Authorizations
Path parameters
compIdinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/{compId} HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
{
  "id": 1,
  "checkers": [
    {
      "id": 1,
      "displayName": "Default Python3 Checker",
      "languageHighlightName": "python"
    }
  ],
  "name": "Code Battles 2023",
  "description": "A competitive coding event",
  "startedAt": "2023-01-01T10:00:00",
  "endedAt": "2023-01-01T18:00:00"
}

Get all answers

get

Retrieves all answers submitted by the authenticated user for a specific competition.

Authorizations
Path parameters
compIdinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/{compId}/sends HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
[
  {
    "id": 1,
    "user": {
      "id": 1,
      "username": "john_doe"
    },
    "status": "IN_PROGRESS",
    "score": 100,
    "code": "print('Hello, World!')",
    "result": "Success",
    "checker": {
      "id": 1,
      "displayName": "Default Python3 Checker",
      "languageHighlightName": "python"
    },
    "createdAt": "2023-01-01T12:00:00Z",
    "competitionsProblems": {
      "id": 1,
      "priority": 12,
      "problem": {
        "id": 1,
        "name": "Sum of Two Numbers",
        "description": "Calculate the sum of two integers.",
        "inData": 1,
        "outData": 3,
        "examples": "Input: 1 2, Output: 3",
        "public": true
      },
      "slug": "text"
    }
  }
]

Get competition problems

get

Retrieves all problems associated with a specific competition.

Authorizations
Path parameters
compIdinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/{compId}/problems HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
[
  {
    "id": 1,
    "priority": 12,
    "problem": {
      "id": 1,
      "name": "Sum of Two Numbers",
      "description": "Calculate the sum of two integers.",
      "inData": 1,
      "outData": 3,
      "examples": "Input: 1 2, Output: 3",
      "public": true
    },
    "slug": "text"
  }
]

Get competition problem by ID

get

Retrieves a specific problem by its ID within a competition.

Authorizations
Path parameters
compIdinteger · int64Required
idinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/{compId}/problems/{id} HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
{
  "id": 1,
  "priority": 12,
  "problem": {
    "id": 1,
    "name": "Sum of Two Numbers",
    "description": "Calculate the sum of two integers.",
    "inData": 1,
    "outData": 3,
    "examples": "Input: 1 2, Output: 3",
    "public": true
  },
  "slug": "text"
}

Get competition leaderboard

get

Retrieves the leaderboard for a specific competition.

Authorizations
Path parameters
compIdinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/{compId}/leaderboard HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
{
  "score": [
    {
      "userId": 1,
      "userX": "text",
      "score": 1,
      "time": "2025-05-24T08:59:29.935Z"
    }
  ],
  "data": {
    "ANY_ADDITIONAL_PROPERTY": [
      {
        "userId": 1,
        "competitionproblemId": 1,
        "maxScore": 1
      }
    ]
  }
}

Get competitions available for user

get

Retrieves all competitions accessible to the authenticated user.

Authorizations
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/me HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
[
  {
    "id": 1,
    "checkers": [
      {
        "id": 1,
        "displayName": "Default Python3 Checker",
        "languageHighlightName": "python"
      }
    ],
    "name": "Code Battles 2023",
    "description": "A competitive coding event",
    "startedAt": "2023-01-01T10:00:00",
    "endedAt": "2023-01-01T18:00:00"
  }
]
  • GET[ADMIN] Get competition users
  • PUT[ADMIN] Edit competition users
  • PUT[ADMIN] Edit competition checkers
  • GET[ADMIN] Get all competitions
  • POST[ADMIN] Create a new competition
  • POSTSubmit an answer
  • GETGet competition by ID
  • GETGet all answers
  • GETGet competition problems
  • GETGet competition problem by ID
  • GETGet competition leaderboard
  • GETGet competitions available for user

[ADMIN] Get competition users

get

Retrieves the list of users participating in a specific competition. Required admin role.

Authorizations
Path parameters
compIdinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/competitions/{compId}/users HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
[
  {
    "id": 1,
    "username": "john_doe"
  }
]

[ADMIN] Edit competition users

put

Updates the list of users participating in a specific competition. Required admin role.

Authorizations
Path parameters
compIdinteger · int64Required
Body

Request to edit users

usersIdsinteger · int64[]Required

Set of user IDs to be edited

Example: 1,2,3
Responses
202
Accepted
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
put
PUT /api/competitions/{compId}/users HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 20

{
  "usersIds": "1,2,3"
}

No content

[ADMIN] Edit competition checkers

put

Updates the list of checkers for a specific competition. Required admin role.

Authorizations
Path parameters
compIdinteger · int64Required
Body

Request to edit users

usersIdsinteger · int64[]Required

Set of user IDs to be edited

Example: 1,2,3
Responses
202
Accepted
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
put
PUT /api/competitions/{compId}/checkers HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 20

{
  "usersIds": "1,2,3"
}

No content

[ADMIN] Create a new competition

post

Creates a new competition object. Required admin role.

Authorizations
Body
namestringRequired

Name of the competition

Example: Code Battles 2023
descriptionstringRequired

Description of the competition

Example: A competitive coding event
startedAtstring · date-timeOptional

Start time of the competition

Example: 2023-01-01T10:00:00
endedAtstring · date-timeOptional

End time of the competition

Example: 2023-01-01T18:00:00
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
post
POST /api/competitions HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 137

{
  "name": "Code Battles 2023",
  "description": "A competitive coding event",
  "startedAt": "2023-01-01T10:00:00",
  "endedAt": "2023-01-01T18:00:00"
}
{
  "id": 1,
  "checkers": [
    {
      "id": 1,
      "displayName": "Default Python3 Checker",
      "languageHighlightName": "python"
    }
  ],
  "name": "Code Battles 2023",
  "description": "A competitive coding event",
  "startedAt": "2023-01-01T10:00:00",
  "endedAt": "2023-01-01T18:00:00"
}

Submit an answer

post

Allows a user to submit an answer for a specific competition problem.

Authorizations
Path parameters
compIdinteger · int64Required
Body

Request to send an answer

checkerinteger · int64Required

ID of the checker

Example: 1
srcstringRequired

Source code submitted as the answer

Example: print(input())
idinteger · int64Required

ID of the answer

Example: 1001
Responses
200
OK
*/*
Responsestring
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
post
POST /api/competitions/{compId}/send HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 46

{
  "checker": 1,
  "src": "print(input())",
  "id": 1001
}
text