# Tournament Leaderboard

### Create Tournament Leaderboard

<mark style="color:green;">`POST`</mark> `[endpoint]/v2/tournament/create`

API to Create Tournament Leaderboard

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-Api-Key<mark style="color:red;">\*</mark> | String | API Key     |

#### Request Body

| Name                                                 | Type   | Description                                                                                                             |
| ---------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------- |
| game\_id<mark style="color:red;">\*</mark>           | String | Game Id                                                                                                                 |
| tournament\_type<mark style="color:red;">\*</mark>   | String | Tournament Type Option : leaderboard, single\_elim, double\_elim, round\_robin                                          |
| tournament\_name<mark style="color:red;">\*</mark>   | String | Tournament Name                                                                                                         |
| description<mark style="color:red;">\*</mark>        | String | Tournament Description                                                                                                  |
| start\_time<mark style="color:red;">\*</mark>        | String | Start Time Tournament                                                                                                   |
| end\_time<mark style="color:red;">\*</mark>          | String | End Time Tournament                                                                                                     |
| participant\_limit<mark style="color:red;">\*</mark> | Number | Participant Limit Tournament                                                                                            |
| listLeaderboard<mark style="color:red;">\*</mark>    | Array  | Array Object. The Object field is komo\_username(String Required), score\_type(String Required), value(Double Required) |

{% tabs %}
{% tab title="200: OK Create Tournament Leaderboard is successfull" %}

```json
{
    "message": "Create Game Successfully!",
    "status": "Success"
}
```

{% endtab %}
{% endtabs %}

### Get Leaderboard Tournament

## Get List Leaderboard Tournament

<mark style="color:blue;">`GET`</mark> `[endpoint]/v2/leaderboard/{tournament_id}`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-Api-Key<mark style="color:red;">\*</mark> | String | API Key     |

#### Request Body

| Name                                      | Type    | Description                                        |
| ----------------------------------------- | ------- | -------------------------------------------------- |
| sortBy<mark style="color:red;">\*</mark>  | String  | Sort By Score Type like kill, assist, death, etc.  |
| sortAsc<mark style="color:red;">\*</mark> | Boolean | True will sorting ascending, False will Descending |

{% tabs %}
{% tab title="200: OK Get Tournament Leaderboard Successfully" %}

```json
{
    "status": "success",
    "data": {
        "scoreType": [
            "kill",
            "assist",
            "death"
        ],
        "rank": [
            {
                "komo_username": "Aviabee",
                "scores": [
                    {
                        "kill": 10
                    },
                    {
                        "assist": 4
                    },
                    {
                        "death": 7
                    }
                ]
            },
            {
                "komo_username": "komochess",
                "scores": [
                    {
                        "kill": 11
                    },
                    {
                        "assist": 4
                    },
                    {
                        "death": 0
                    }
                ]
            }
        ]
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request Response" %}

```json
{
    "status": "error",
    "message": {
        "sortBy": [
            "The sort by field is required."
        ],
        "sortAsc": [
            "The sort asc field is required."
        ]
    }
}
```

{% endtab %}
{% endtabs %}

## Update Tournament Leaderboard

<mark style="color:orange;">`PUT`</mark> `[endpoint]/v2/leaderboard/{tournament_id}`

This request will type in body with **JSON** format. The format is **Array of Object**.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-Api-Key<mark style="color:red;">\*</mark> | String | API Key     |

#### Request Body

| Name                                             | Type   | Description            |
| ------------------------------------------------ | ------ | ---------------------- |
| komo\_username<mark style="color:red;">\*</mark> | String | Komo Username          |
| score\_type<mark style="color:red;">\*</mark>    | String | Score Type Tournament  |
| value<mark style="color:red;">\*</mark>          | Number | Value Score Tournament |

{% tabs %}
{% tab title="200: OK Update Tournament Leaderboard Is Successfully" %}

```json
{
    "message": "Update Tournament Leaderboard Successfully!",
    "status": "Success"
}
```

{% endtab %}

{% tab title="400: Bad Request Wrong Request" %}

```json
{
    "status": "error",
    "message": "Update Tournament Leaderboard Failed! Wrong Request!"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.komoverse.io/admin-server-api-reference/tournament-leaderboard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
