# Contests

{% hint style="danger" %}
**Under construction.**
{% endhint %}

## Get contest by ID

<mark style="color:blue;">`GET`</mark> `https://api.sort-me.org/contests/getByID`

:sa: [Localization applies](https://docs.sort-me.org/tricky/localization).

#### Query Parameters

| Name                                 | Type   | Description                                                                                                                 |
| ------------------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | int    | ID of the contest                                                                                                           |
| code                                 | string | <p>Secret code to access contest.<br>Required only for link-access contests, if you are not registered and not an admin</p> |

{% tabs %}
{% tab title="200: OK Contest found" %}
{% tabs %}
{% tab title="Running" %}

<pre class="language-javascript"><code class="lang-javascript">{
    "id": 54,
    "name": "Sort Me Round №8",
    "description": "What an interesting contest it will be, you can't imagine!",
    "organizer": "Sort Me Team",

    "timings": {
        "now": 1671382401,
        "start": 1673382400,
        "end": 1673384800,
        "registration_start": 1671380000,
        "registration_end": 1673382400
    },

    "features": {
        <a data-footnote-ref href="#user-content-fn-1">"practice"</a>: false,
        <a data-footnote-ref href="#user-content-fn-2">"table_visible"</a>: true,
        <a data-footnote-ref href="#user-content-fn-3">"jury_chat"</a>: false,
    },

    "rules": "icpc",

    "participants_count": 541,
    "task_count": 1,

    "registered": true,

    <a data-footnote-ref href="#user-content-fn-4">"problems"</a>: [
        {
            "id": 1,
            "name": "A+B",
            "statement": {
                "legend": "Your mission is to add two integers $A$ and $B$.",
                "input": "The only line of input contains two space-separated integers. The values of the numbers do not exceed $$10^9$$.",
                "output": "Print a single integer - the sum of the numbers $$A$$ and $$B$$.",
                "scoring": "We will run your solution on two subtasks.\nIn the first subtask, you will only receive points for passing all tests.\nThe second subtask has 10 tests, for each of which your solution will receive 5 points.",
                "note": "Adding is not subtracting..."
            },
            "samples": [
                {"stdin": "2 3", "stdout": "5"},
                {"stdin": "8 1", "stdout": "9"}
            ],
            "subtasks": [
                {
                    "points": 50,
                    "depends": [],
                    "description": "$$A, B \\le 1000$$"
                },
                {
                    "points": 50,
                    "depends": [1],
                    "description": "$$A, B \\le 10^9$$"
                }
            ],
            "limits": {
                "time": 1000,
                "memory": 256
            },
            "can_edit": false
        }
    ]

    <a data-footnote-ref href="#user-content-fn-5">"languages"</a>: [
        {
            "name": "Python 3.11",
            "highlight": "python",
            "api": "python",
            "ext": "py"
        },
        {
            "name": "PyPy 3.9",
            "highlight": "python",
            "api": "pypy",
            "ext": "py"
        },
        {
            "name": "GNU C++20",
            "highlight": "cpp",
            "api": "c++",
            "ext": "cpp:cc:C"
        }
    ]
}
</code></pre>

{% endtab %}

{% tab title="Not started" %}

```javascript
{
    "id": 54,
    "name": "Sort Me Round №8",
    "description": "What an interesting contest it will be, you can't imagine!",
    "organizer": "Sort Me Team",

    "timings": {
        "now": 1671382335,
        "start": 1673382400,
        "end": 1673384800,
        "registration_start": 1671380000,
        "registration_end": 1673382400
    },

    "features": {
        "practice": false,
        "table_visible": true,
        "jury_chat": false
    },

    "rules": "icpc",

    "participants_count": 541,
    "task_count": 1,

    "registered": false,
}
```

{% endtab %}

{% tab title="Admin of contest" %}

<pre class="language-javascript"><code class="lang-javascript">{
    "id": 54,
    "name": "Sort Me Round №8",
    "description": "What an interesting contest it will be, you can't imagine!",
    "organizer": "Sort Me Team",

    "timings": {
        "now": 1671382355,
        "start": 1673382400,
        "end": 1673384800,
        "registration_start": 1671380000,
        "registration_end": 1673382400
    },

    "features": {
        "practice": false,
        "table_visible": true,
        "jury_chat": false
    },

    "rules": "icpc",

    "participants_count": 541,
    "task_count": 1,

    "registered": false,
    
    <a data-footnote-ref href="#user-content-fn-6">"admin_scope"</a>: [
        <a data-footnote-ref href="#user-content-fn-7">"read"</a>, 
        <a data-footnote-ref href="#user-content-fn-8">"write"</a>, 
        <a data-footnote-ref href="#user-content-fn-9">"registrations"</a>, 
        <a data-footnote-ref href="#user-content-fn-10">"runs"</a>, 
        <a data-footnote-ref href="#user-content-fn-11">"chat"</a>, 
        <a data-footnote-ref href="#user-content-fn-12">"antiplag"</a>,
        <a data-footnote-ref href="#user-content-fn-13">"admins"</a>,
        <a data-footnote-ref href="#user-content-fn-14">"creator"</a>
    ],

    <a data-footnote-ref href="#user-content-fn-15">"problems"</a>: [
        {
            "id": 1,
            "name": "A+B",
            "statement": {
                "legend": "Your mission is to add two integers $A$ and $B$.",
                "input": "The only line of input contains two space-separated integers. The values of the numbers do not exceed $$10^9$$.",
                "output": "Print a single integer - the sum of the numbers $$A$$ and $$B$$.",
                "scoring": "We will run your solution on two subtasks.\nIn the first subtask, you will only receive points for passing all tests.\nThe second subtask has 10 tests, for each of which your solution will receive 5 points.",
                "note": "Adding is not subtracting..."
            },
            "samples": [
                {"stdin": "2 3", "stdout": "5"},
                {"stdin": "8 1", "stdout": "9"}
            ],
            "subtasks": [
                {
                    "points": 50,
                    "depends": [],
                    "description": "$$A, B \\le 1000$$"
                },
                {
                    "points": 50,
                    "depends": [1],
                    "description": "$$A, B \\le 10^9$$"
                }
            ],
            "limits": {
                "time": 1000,
                "memory": 256
            },
            "category": 6,
            "difficulty": 2,
            "can_edit": false
        }
    ]

        
    "languages": [
        {
            "name": "Python 3.11",
            "highlight": "python",
            "api": "python",
            "ext": "py"
        },
        {
            "name": "PyPy 3.9",
            "highlight": "python",
            "api": "pypy",
            "ext": "py"
        },
        {
            "name": "GNU C++20",
            "highlight": "cpp",
            "api": "c++",
            "ext": "cpp:cc:C"
        }
    ]
}
</code></pre>

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Register to contest

<mark style="color:green;">`POST`</mark> `https://api.sort-me.org/contests/register`

Register to contest as participant.

This method is idempotent: if you are already registered, it will return status OK.

#### Query Parameters

| Name                                          | Type   | Description                                                                     |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------- |
| contest\_id<mark style="color:red;">\*</mark> | int    | ID of the contest                                                               |
| code                                          | string | <p>Secret code to access contest.<br>Required only for link-access contests</p> |

{% tabs %}
{% tab title="200: OK Registered successfully" %}

```javascript
{
    "status": "ok"
}
```

{% endtab %}
{% endtabs %}

## Get available

<mark style="color:blue;">`GET`</mark> `https://api.sort-me.org/contests/getAvailable`

:sa: [Localization applies](https://docs.sort-me.org/tricky/localization).

Returns previews of contests, which is shown on top on "Contests" tab. These are contests to which you are registered and contests for which any Sort Me user can register.

{% tabs %}
{% tab title="200: OK List of contests" %}

```javascript
[
    {
        "id": 54,
        "name": "Sort Me Round №8",
        "description": "What an interesting contest it will be, you can't imagine!",
        "organizer": "Sort Me Team",

        "timings": {
            "now": 1671382401,
            "start": 1673382400,
            "end": 1673384800,
            "registration_start": 1671380000,
            "registration_end": 1673382400
        },

        "rules": "icpc",

        "participants_count": 541,
        "task_count": 1,

        "registered": false,
    }
]
```

{% endtab %}
{% endtabs %}

## Get history of contests participation

<mark style="color:blue;">`GET`</mark> `https://api.sort-me.org/contests/getParticipated`

:key: [<mark style="color:orange;">Authorization required</mark>](https://docs.sort-me.org/tricky/authorization)<mark style="color:orange;">.</mark>

:sa: [Localization applies](https://docs.sort-me.org/tricky/localization).

:card\_box: [Pagination applies](https://docs.sort-me.org/tricky/pagination) with *N* = 24.

Get contests in which you participated and which are already finished.

#### Query Parameters

| Name   | Type | Description                                                                 |
| ------ | ---- | --------------------------------------------------------------------------- |
| offset | int  | <p>Pagination parameter.<br>Use <strong><code>id</code></strong> field.</p> |

{% tabs %}
{% tab title="200: OK List of contests" %}

```javascript
{
    "count": 4
    "contests": [
        {
            "id": 54,
            "name": "Sort Me Round №8",
            "description": "What an interesting contest it will be, you can't imagine!",
            "organizer": "Sort Me Team",

            "timings": {
            "now": 1671382401,
            "start": 1673382400,
            "end": 1673384800,
            "registration_start": 1671380000,
            "registration_end": 1673382400
            },

            "rules": "acm",
    
            "participants_count": 541,
            "task_count": 1,

            "registered": false,
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Get contests you are admin in

<mark style="color:blue;">`GET`</mark> `https://api.sort-me.org/contests/getManaged`

:key: [<mark style="color:orange;">Authorization required</mark>](https://docs.sort-me.org/tricky/authorization)<mark style="color:orange;">.</mark>

:sa: [Localization applies](https://docs.sort-me.org/tricky/localization).

:card\_box: [Pagination applies](https://docs.sort-me.org/tricky/pagination) with *N* = 24.

#### Query Parameters

| Name   | Type | Description                                                                 |
| ------ | ---- | --------------------------------------------------------------------------- |
| offset | int  | <p>Pagination parameter.<br>Use <strong><code>id</code></strong> field.</p> |

{% tabs %}
{% tab title="200: OK List of contests" %}

```javascript
{
    "remaining_quota": 10,
    
    "count": 4,
    "contests": [
        {
            "id": 54,
            "name": "Sort Me Round №8",
            "description": "What an interesting contest it will be, you can't imagine!",
            "organizer": "Sort Me Team",

            "timings": {
                "now": 1671382401,
                "start": 1673382400,
                "end": 1673384800,
                "registration_start": 1671380000,
                "registration_end": 1673382400
            },

            "rules": "acm",
    
            "participants_count": 541,
            "task_count": 1,

            "registered": false,
        }
    ]
}
```

{% endtab %}
{% endtabs %}

[^1]: Can user send submissions after contest end, without changing score in table?

[^2]: Can registered participants see table during competition?

[^3]: Is messenger with jury enabled?

[^4]: Format is the same as in [/problems/getByID](https://docs.sort-me.org/problems#get-problem-by-id), but without `difficulty` and `category` fields.

[^5]: Submissions in this contest are allowed only in this languages. \
    Format is the same as in [/submissions/getAvailableLanguages](https://docs.sort-me.org/submissions#get-avaliable-languages).\
    \
    Please note that in rare cases this might not be a subset of globally available languages.

[^6]: This field is presented if you are admin./ It contains your scopes.

[^7]: Read problems and submit solutions before contest start.

[^8]: Change problems presented in contest

[^9]: Manage invite links and groups, rename and disqualify participants.

[^10]: See logs of user solutions runs.

[^11]: Respond to messages in jury chat.

[^12]: Decide if user's solution is plagiarism on (on antiplagiarism tab)

[^13]: Can add or delete admins with any scopes, except for creator.

[^14]: Can delete or copy entire contest.

[^15]: Presented if you have `read` scope.
