Skip to content

Solutions

arcturus5340 edited this page May 27, 2021 · 5 revisions

Solutions API

List available solutions

Get a list of available solutions in system.
GET /api/solutions

Example request:

curl "https://julia-api-server.codes/api/solutions"

Example response:

{
    "count": 5,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "author": 1,
            "task": 1,
            "status": "RE",
            "dispatch_time": 1618180411
        },
        {
            "id": 2,
            "author": 2,
            "task": 1,
            "status": "CE",
            "dispatch_time": 1618185727
        },
        {
            "id": 3,
            "author": 2,
            "task": 1,
            "status": "OK",
            "dispatch_time": 1618185752
        },
        {
            "id": 4,
            "author": 2,
            "task": 1,
            "status": "OK",
            "dispatch_time": 1618185859
        },
        {
            "id": 5,
            "author": 2,
            "task": 3,
            "status": "WA",
            "dispatch_time": 1618185933
        },
    ]
}

Get a single solution

Get a specific solution identified by the solutions id.
GET /api/solutions/:id
Parameters:

Attribute Type Required Description
id int yes The solutions ID

Example request:

curl "https://julia-api-server.codes/api/solutions/1"

Example response if the contest not passed:

{
    "id": 1,
    "author": 1,
    "task": 1,
    "status": "RE",
    "dispatch_time": 1618180411
}

Example response if the contest passed:

{
    "id": 1,
    "author": 1,
    "task": 1,
    "status": "RE",
    "dispatch_time": 1618180411,
    "details": {
        "status": {
            "0": "RE"
        },
        "input": {},
        "output": {},
        "program_output": {
            "0": "2"
        }
    },
    "lang": "python3",
    "code": "http://julia-api-server.codes/code/username_1_2021.04.11_22.33.31"
}

Create a solutions

Create a new solutions by posting a JSON payload.
POST /api/solutions
Parameters:

Attribute Type Required Description
lang string yes The programming language in which the program is written
task int yes ID of the problem that the current package is solving
code file yes Solution code file

Example request:

PAYLOAD=$(cat << 'JSON'
{
    "lang": "python3",
    "task": 1
}
JSON
)
curl --request POST --header "Authorization: JWT <access_token>" --header "Content-Type: multipart/form-data" --data "$PAYLOAD" --data "code=@code_file.py" "https://julia-api-server.codes/api/solutions/"

Example response:

{
    "id": 4,
    "title": "New solutions",
    "content": "Description for new solutions",
    "contest": 1,
    "tl": 3,
    "ml": 268435456
}
Clone this wiki locally