# Getting Started

### Get Your API Key

Once you sign agreement with us, you will be given API Key to connect your game to Komoverse Ecosystem. Your API Key will be put into request header as `X-Api-Key`

### API Endpoint (Development Server)

During development or integration, you can use this endpoint to mess around with our API.

{% hint style="danger" %}
**<https://api.komoverse>.**<mark style="color:red;">**dev**</mark>
{% endhint %}

### API Endpoint (Live / Production Server)

After you finish integrating and testing your game to Komoverse API, you can change your endpoint to this server. Please note that development server account can not be used in production server.

{% hint style="success" %}
**<https://api.komoverse>.**<mark style="color:green;">**io**</mark>
{% endhint %}

## API Reference

Komoverse API divided into two API groups, **Player API** and **Admin / Server API**.&#x20;

**Player API** is used on your game client and require player login to authenticate API requests. This API use player's login token as Bearer Authorization.

{% content-ref url="/pages/2LbCgaaq9CHssvm22vcz" %}
[Player API Reference](/player-api-reference/introduction)
{% endcontent-ref %}

**Admin / Server API** is used on your game server as this API did not require player login. This API use Basic Authorization method with client\_id and client\_secret.

{% content-ref url="/pages/dPbIXNSOlZQg5ujSCXcj" %}
[Admin / Server API Reference](/admin-server-api-reference/introduction)
{% endcontent-ref %}


# Introduction

Welcome to the Player API documentation! This API is designed to provide a seamless gaming experience for players like you. This documentation will guide you on how to get started with the Player API, enabling you to interact with the game environment, access player-specific features, and enhance your gameplay.

## Authenticating Player API Request

Authentication is a crucial step to ensure the security of your player account and to grant you access to the Player API endpoints. In order to authenticate your requests, you will need to include the appropriate headers in your API requests.

#### API Key Authentication

For most API requests, you will need to include the `X-Api-Key` header. The value of this header should be your unique API key provided to you by the game API provider. This API key serves as a way to identify and authenticate your requests as a player.

Example:

```
X-Api-Key: YOUR_API_KEY
```

#### Bearer Token Authentication

After successfully logging in as a player, you will receive an access token. This access token is used to authorize your requests to certain protected endpoints. To include the access token in your API requests, you need to include the `Authorization` header with the value in the format "Bearer \<access\_token>".

Example:

```
Authorization: Bearer YOUR_ACCESS_TOKEN
```

Please note that the access token has an expiration time, and you may need to refresh it periodically or obtain a new one if it expires.

#### Handling Authentication Errors

If your authentication fails or the provided credentials are invalid, you will receive an appropriate error response (e.g., HTTP 401 Unauthorized). In such cases, double-check that you have included the correct API key or access token in the respective headers.

Ensure that you securely store and manage your API key and access token, as they grant access to your player account and game-related functionalities. Treat them as sensitive information and avoid exposing them to unauthorized individuals.

Remember to handle authentication errors gracefully within your application and provide appropriate feedback to the user.

## API Usage

The Player API offers a variety of endpoints to enhance your gaming experience and interact with the game environment. These endpoints allow you to perform tasks such as:

1. Player profile: Retrieve and update your player profile information, including username, avatar, and other personal details.
2. Game progress: Track and manage your game progress, including levels completed, achievements earned, and in-game currency.
3. Game content: Retrieve game content, such as NFTs, quests, items, and unlockable features, to enhance your gameplay.
4. Social features: Connect with other players, send and receive messages, and participate in multiplayer activities.


# Account & Authentication

## Authentication for Browser-Based Game

{% hint style="info" %}
If you are not making browser-based game, please skip this step and continue to [Authenticating Using KOMO Account](#authenticating-using-komo-account) API
{% endhint %}

1. User will access your game from within Komoverse website
2. Komoverse website will check if user logged in or not
3. If user not logged in, Game URL will be accessed via iframe without authorization token for example <mark style="color:red;"><https://yourgameurl.com/index.html></mark>&#x20;
4. If user logged in, Game URL will be accessed via iframe with given authorization token for example <mark style="color:red;"><https://yourgameurl.com/index.html?token=eyxxx......xxxx></mark>
5. You can use the token given in URL parameter to make Authorized Player API calls
6. Please note that token have expiry time. Don't forget to refresh the token.

## Authenticating Using KOMO Account

## Login with KOMO Account

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/login`

#### Query Parameters

| Name                                             | Type   | Description   |
| ------------------------------------------------ | ------ | ------------- |
| komo\_username<mark style="color:red;">\*</mark> | String | KOMO Username |
| password<mark style="color:red;">\*</mark>       | String | User Password |

#### Headers

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

{% tabs %}
{% tab title="200: OK Success login response" %}

```json
{
    "status": "success",
    "expires_at": {
        "unix": 1685522166,
        "utc": "2023-05-31 08:36:06"
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiODE0NzhhMWY3NzY5ZmE3YjFkYjJiNmNhNTBmYTEzZTJhN2ZiZmE5ZjY0MjFmZjE4MGIyYmQ4YzNjYjIwNDljMTJjM2U3MTE4ZGZiZTE1MzIiLCJpYXQiOjE2ODU1MTg1NjYuMjkzNTA0LCJuYmYiOjE2ODU1MTg1NjYuMjkzNTA4LCJleHAiOjE2ODU1MjIxNjYuMjUwOTM2LCJzdWIiOiIxMDAyNCIsInNjb3BlcyI6W119.Yqerxk3m5MeRLJYNL9JWuS__lPo-MFXjGpHD18o1KAO3d1yjjW_mPs5dXmggrBBT53PWa0G-WBWe18-0qQu5KrS-V8MQbhuccxJbZMZmFzmEosmdIQC6ZXh353mlmFqcCJXC1_iegaJv1VsD0JwbcF61j3-5txrbX2M_HpANW2yT15RTGgptKmjwMj04hy1AyiTFvLDm5WCDwY_ld4znxzqfoo3aTpZVhgiD9VwqhxmT9OXjki55EVWGJw5yX1Ccx-YPz26O1m0hfTaTMco1u7Lw_cnwLyqbgmTb6s3CpLnVLszXJCq0J27PeV5osTaO4lC9g4GDrS_tSd8MzYkToSGLh0Y6S9nTKQypNEcqTjZ19T_kujmA-6ovEM3H9AnXAqYBm7Wnfoa4eu5U1A_FdN6XMXxeUlyzHsbwDetCqYVRbxEUAk7qRmK8_CshytvEgWEbzj4nY9zRdwTi6JHG6bA4_FW0-CtFmSphgLqf-kKL6rxHR1tH9WpCm6Y_7J8ccqBmKnW930lQDc6CFtEQ0iHr-lvmdN0ebW0DWNdIepAqUAGFeNhTU1WPXnx0PRFw8otZ-HIuKj76yejPmxFHuuXkkbes4M3whaMs7R2IoCpEXNVXuV39wnMzhvdnUJHVjyee-VH3YWKIlP5WWrXVIFY3o6hhd4l-_VGqJYOPzYA"
}
```

{% endtab %}

{% tab title="403: Forbidden Username or password is incorrect" %}

```json
{
    "status": "error",
    "messages": {
        "unauthorizedLogin": "The username or password is incorrect."
    }
}
```

{% endtab %}

{% tab title="403: Forbidden Wrong password" %}

```json
{
    "status": "error",
    "messages": {
        "incorrectPassword": "The password you have entered is not correct."
    }
}
```

{% endtab %}
{% endtabs %}

## Authenticating Using Third Party Providers

## Login with Google or Facebook Single Sign-On

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/single-sign-on`

If your game have integrated Google / Facebook SSO, you can send SSO access token to this API. If the email associated with SSO account already registered on a KOMO Account, we will send you our access token to be used in game.

#### Headers

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

#### Request Body

| Name                                       | Type             | Description                                    |
| ------------------------------------------ | ---------------- | ---------------------------------------------- |
| token<mark style="color:red;">\*</mark>    | String           | Token from Google, Facebook, etc               |
| provider<mark style="color:red;">\*</mark> | String           | Provider name like "google, facebook, discord" |
| otp                                        | numeric, 6 digit | otp code from email                            |

{% tabs %}
{% tab title="200: OK Successfully Login" %}

```json
{
    "status": "success",
    "expires_at": {
        "unix": 1685522166,
        "utc": "2023-05-31 08:36:06"
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiODE0NzhhMWY3NzY5ZmE3YjFkYjJiNmNhNTBmYTEzZTJhN2ZiZmE5ZjY0MjFmZjE4MGIyYmQ4YzNjYjIwNDljMTJjM2U3MTE4ZGZiZTE1MzIiLCJpYXQiOjE2ODU1MTg1NjYuMjkzNTA0LCJuYmYiOjE2ODU1MTg1NjYuMjkzNTA4LCJleHAiOjE2ODU1MjIxNjYuMjUwOTM2LCJzdWIiOiIxMDAyNCIsInNjb3BlcyI6W119.Yqerxk3m5MeRLJYNL9JWuS__lPo-MFXjGpHD18o1KAO3d1yjjW_mPs5dXmggrBBT53PWa0G-WBWe18-0qQu5KrS-V8MQbhuccxJbZMZmFzmEosmdIQC6ZXh353mlmFqcCJXC1_iegaJv1VsD0JwbcF61j3-5txrbX2M_HpANW2yT15RTGgptKmjwMj04hy1AyiTFvLDm5WCDwY_ld4znxzqfoo3aTpZVhgiD9VwqhxmT9OXjki55EVWGJw5yX1Ccx-YPz26O1m0hfTaTMco1u7Lw_cnwLyqbgmTb6s3CpLnVLszXJCq0J27PeV5osTaO4lC9g4GDrS_tSd8MzYkToSGLh0Y6S9nTKQypNEcqTjZ19T_kujmA-6ovEM3H9AnXAqYBm7Wnfoa4eu5U1A_FdN6XMXxeUlyzHsbwDetCqYVRbxEUAk7qRmK8_CshytvEgWEbzj4nY9zRdwTi6JHG6bA4_FW0-CtFmSphgLqf-kKL6rxHR1tH9WpCm6Y_7J8ccqBmKnW930lQDc6CFtEQ0iHr-lvmdN0ebW0DWNdIepAqUAGFeNhTU1WPXnx0PRFw8otZ-HIuKj76yejPmxFHuuXkkbes4M3whaMs7R2IoCpEXNVXuV39wnMzhvdnUJHVjyee-VH3YWKIlP5WWrXVIFY3o6hhd4l-_VGqJYOPzYA"
}
```

{% endtab %}

{% tab title="400: Bad Request Missing token and provider" %}

```json
{
    "status": "error",
    "message": {
        "token": [
            "The token field is required."
        ],
        "provider": [
            "The provider field is required."
        ]
    }
}
```

{% endtab %}

{% tab title="404: Not Found Account Not Found" %}

```json
{
    "status": "error",
    "messages": "Account is not Found. Please Register!"
}
```

{% endtab %}
{% endtabs %}

## Linked Game Account

## Find Linked Game Account by Authorization Header

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/account/linked/get`

If your game have it's own game account, you can check whether this KOMO Account linked to your game or not with this API

#### Headers

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

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

```json
{
    "status": "success",
    "data": {
        "komo_username": "kokomo",
        "provider": "game_id",
        "provider_user_id": "1476784473869930500"
    }
}
```

{% endtab %}
{% endtabs %}

## Create KOMO Access Token by Linked Account

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/account/linked/authorize`

<mark style="color:red;">WARNING: This API only used after successful login with your own Game Account. If you use KOMO Account login, this API is not needed.</mark>

#### Headers

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

#### Request Body

| Name                  | Type   | Description          |
| --------------------- | ------ | -------------------- |
| provider\_account\_id | String | Your Game Account ID |

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

```json
{
    "status": "success",
    "expires_at": {
        "unix": 1687758196,
        "utc": "2023-06-26 05:43:16"
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiYjNkNjRlZmY3N2RmZmZjOWM5MWE1OGUxZDEwYzA4MjNiYmRhYTc1Nzc5ZDJkZGJhOGJmMzNhODM2YWZlYzg5MGM3M2IxZmNhYTFlODc5MTMiLCJpYXQiOjE2ODc3NTQ1OTYuODY5NzA5LCJuYmYiOjE2ODc3NTQ1OTYuODY5NzEyLCJleHAiOjE2ODc3NTgxOTYuODI1MjkyLCJzdWIiOiIxMDAxNyIsInNjb3BlcyI6W119.j-S77B-_SI9Ekv9mniC3M0to9XvsSzgN9wKkWNe0sgKq72HvbmOiQb9yOv-KxXLxI_5g4IWYu7AnMTbPo2mpbJoreEBQLx4N7PRkz7Mqzc5Pw_E_azoT1mQxCX5BxEabEa8IiZV8EFpQrayPMBnR5fNtSfAmsI3yFX1YzkgKudcd8x1oMWXIJFm2QCp0bPt7_zifeZRxyBvYOqWvRC1hkhCTDQt3J-y9rTL0-cUdlMbDEhsZvxhpriEm0OCIJC0CNMWLlbXPIltMbr5egZtikZ1d9c7oiMTKMgeVRbSlmcOaD2fS3iNWM2hlF8uc9Tqh0-5sPXCQ96P3Z1hdBSF5katJ-MTz0VtkvtxZpYl-VjxE9G9Hh3aPRbSvqlgy-N922-1IZxNRQY9FHkdBMnXmV_UR2m2-fYryPHnc-kxoQqTiJ7E4pcIb4e415DL_MHpvlG6K9CFEJLgCdXUDa0WMpKhK5QGGVOwBE-LvPzBkwDTSDc1jWGEJc0qLbOK4p_SXCeUTjioW55yVyD_dCVv1muhJ4uCp6OOyjgP3pleSDRpgNgo07udU0xZKpEBaVPMHrcLNaEtl3GbGRwesC1jnflmUYR8Lq-TMVxl3W9lj83aN90SicCSVhd1qfV_unCwgGar4SVajVhE0fQnzzxW2m2AaxKB_NtcJGTjTsbSukUk"
}
```

{% endtab %}

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

```json
{
    "status": "error",
    "messages": "Linked KOMO Account Not Found for This Game"
}
```

{% endtab %}
{% endtabs %}

## Managing KOMO Access Token

## Check Token Validity

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/token/check`

#### Headers

| Name                                            | Type   | Description            |
| ----------------------------------------------- | ------ | ---------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token bearer from auth |

{% tabs %}
{% tab title="200: OK Successfully check token " %}

```json
{
    "status": "success",
    "message": "Token is valid!",
    "expires_at": {
        "unix": 1685524564,
        "utc": "2023-05-31 09:16:04"
    }
}
```

{% endtab %}

{% tab title="404: Not Found Token is invalid" %}

```json
{
    "status": "error",
    "messages": "Unauthenticated."
}
```

{% endtab %}
{% endtabs %}

## Refresh Token

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/token/refresh`

Renew token expiry time by refreshing the token. New access token will be provided and further request should use new access token instead of old access token.

#### Headers

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

{% tabs %}
{% tab title="200: OK Refresh Token Successfully" %}

```json
{
    "status": "success",
    "expires_at": {
        "unix": 1685522043,
        "utc": "2023-05-31 08:34:03"
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiMTFjNzAyYzYzNDIyYWFkNDM5YmViMzc4NWIyMGMzYWQ3ZmM1MmJhNzQ5YjMwZjNjZGMxYjE4NDJjODAzMDZhODI5NDZjMTNlZTFkOGM1ODIiLCJpYXQiOjE2ODU1MTg0NDMuNzIyMjE0LCJuYmYiOjE2ODU1MTg0NDMuNzIyMjE5LCJleHAiOjE2ODU1MjIwNDMuNjY4OTk0LCJzdWIiOiIxMDAyNCIsInNjb3BlcyI6W119.jxqNunHWc7GySbV5oLtBBDWUoYQDvLVUBzqAXCaXR2qiGfUpAaK67xNuKFuiytX7fK5pEEoaFvbslBzZfM38g3-5T9gVl__U9D7dVZdcLXA70fO-tpd0mAJ4hi26P4W6QTRmTEWKLE0A634edS1kFJXM1goStzpuhDph7BudC6RfMBY0d4YPGM7tftAoLNo2PfqbZJT4zgHuShqHYb15NNCPDNxsNcjv1709FUO-xAjRzG3aR4OhIELO-QnMglNwJcdWbfQHilQWPgS1sn7g1kQtVgbGoPJ7NSelgC0h13JMMut2Il3n-DTJRcj6eTI9Cix55ZU59dGoA7rU9zmWf9QTrJ3GFckrv77T64qp_WrTyy6craVUIr59L-Yxu1S2Kt0sIQv9hq237RN_G2YfYNPeTBk4IGUgehUwx-dBDnm4IYFFwYi0PDRAl99R9Euf8gN306shBRVUIxA2-BN9lnOagiEhBbjfix8mEW6WUtwKhFB_nzjMBl6eC7cebdKXgXURi1P0QaG2vvpidNld7hSJasnaRaxP5XPcTD5Sn0NZ8kjYSiBte3Wwwah6BQOHypX4oecdhP2wvpFJhWdtwCcKZUw_MFhCmjCAjEJqHnziedu8h86SvupCLJjdPzsnTqmLEqjgt-9YX9eQeMMwFTjZiOFKXAbRCg4N_Z0KDcw"
}
```

{% endtab %}

{% tab title="403: Forbidden Error Token Required" %}

```json
{
    "status": "error",
    "messages": {
        "tokenRequired": "A login token is required to perform this request."
    }
}
```

{% endtab %}

{% tab title="403: Forbidden Error Api-key Required" %}

```json
{
    "status": "error",
    "messages": {
        "apiKeyRequired": "An API key is required to perform this request. If you wish to use the KOMO API in your application, contact the Komoverse team to reach out for an agreement."
    }
}
```

{% endtab %}
{% endtabs %}

## Using the KOMO Account

## Get Account Information from Authentication Header

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/account/me`

#### Headers

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

{% tabs %}
{% tab title="200: OK Get Account Information Successfully" %}

```json
{
    "status": "success",
    "data": {
        "id": 10024,
        "komo_username": "polycrest",
        "in_game_display_name": "polycrest",
        "profile_picture_url": "https://komo.s3.ap-southeast-1.amazonaws.com/profile-account/kokomo-XYXJ.jpg",
        "country": "IDN",
        "primary_language": "en",
        "shard": 500222
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Token Field is Required" %}

```json
{
    "status": "error",
    "message": {
        "token": [
            "The token field is required."
        ]
    }
}
```

{% endtab %}

{% tab title="403: Forbidden API-Key is Required" %}

```json
{
    "status": "error",
    "messages": {
        "apiKeyRequired": "An API key is required to perform this request. If you wish to use the KOMO API in your application, contact the Komoverse team to reach out for an agreement."
    }
}
```

{% endtab %}

{% tab title="403: Forbidden Token is Required" %}

```json
{
    "status": "error",
    "messages": {
        "tokenRequired": "A login token is required to perform this request."
    }
}
```

{% endtab %}
{% endtabs %}

## Find Other User's KOMO Account

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/account/find`

Find Other KOMO Account by its user ID, KOMO username, game display name, or wallet address

#### Query Parameters

| Name                                            | Type   | Description                                                                                                                                                             |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| exact\_match                                    | Enum   | 0 : approximate match, 1 : exact match (default 0)                                                                                                                      |
| search\_query<mark style="color:red;">\*</mark> | String | Search Query (min: 3 character)                                                                                                                                         |
| search\_column                                  | String | Column to search (support: `id, komo_username, in_game_display_name, wallet_pubkey`<mark style="color:red;">`both web3 and semi custodial`</mark>) default `all fields` |

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

```json
{
    "status": "success",
    "data": [
        {
            "id": 10073,
            "komo_username": "ty0000",
            "country": "PHL",
            "in_game_display_name": "ty0002",
            "profile_picture_url": "https://hub.komoverse.io/assets/profile_pic/6392f3de3fe95.jpg",
            "wallet_pubkey": "2aXTwjGcRh6BuDoAi4USRnG2pwj8BpJvZB6CY37ikLLS",
            "semi_custodial_wallet_pubkey": null
        },
        {
            "id": 10199,
            "komo_username": "ty0001",
            "country": "PHL",
            "in_game_display_name": "ty0001",
            "profile_picture_url": null,
            "wallet_pubkey": null,
            "semi_custodial_wallet_pubkey": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# NFT and Wallet Portfolio

## Get NFT Portfolio

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/wallet/nft`

#### Headers

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

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

```javascript
{
    "status": "success",
    "data": [
        {
            "inventory_id": 117756,
            "nft_id": null,
            "name": "Mark 14 #1",
            "image_uri": "https://cdn.alphagames.id/nft-storage/devnet/wows/torpedo-collection/mark-14.png",
            "collection": {
                "address": "BCa8Q2Co3hpceuaBJk8mYZ4ZVQnYs8Dv8iE8EJ7v2yjH",
                "name": "Torpedo Collection"
            },
            "attributes": {
                "Category": "Torpedo",
                "Usage": "Unlimited"
            }
        },
....
        {
            "inventory_id": 118214,
            "nft_id": null,
            "name": "Mark 18 #59",
            "image_uri": "https://cdn.alphagames.id/nft-storage/devnet/wows/torpedo-collection/mark-18.png",
            "collection": {
                "address": "BCa8Q2Co3hpceuaBJk8mYZ4ZVQnYs8Dv8iE8EJ7v2yjH",
                "name": "Torpedo Collection"
            },
            "attributes": {
                "Category": "Torpedo",
                "Usage": "Unlimited"
            }
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Get Item Rarity and Stock Based on Collection

<mark style="color:green;">`GET`</mark> `/v3/nft/stock`

**Headers**

| Name          | Value            |
| ------------- | ---------------- |
| X-Api-Key     | `API Key`        |
| Authorization | `Bearer <token>` |

**Query**

| Name                                                   | Type               | Description                                                                                                                                                             |
| ------------------------------------------------------ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `collection_address`<mark style="color:red;">\*</mark> | string             | Collection Address                                                                                                                                                      |
| `rarity`                                               | integer (opsional) | Integer of rarity which set on admin when creating NFT. <mark style="color:purple;">e.g. 1 for common, 2 for common, 3 for rare, 4 for legendary, 5 for mythical</mark> |

**Response**

{% tabs %}
{% tab title="200 (without rarity)" %}

```json
{
    "status": "success",
    "data": [
        {
            "stock": 800,
            "rarity": 1
        },
        {
            "stock": 200,
            "rarity": 2
        }
    ]
}
```

{% endtab %}

{% tab title="200 (with rarity)" %}

```json
{
    "status": "success",
    "data": [
        {
            "stock": 400,
            "group_item": "Mark 14"
        },
        {
            "stock": 400,
            "group_item": "Mark 18"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Assign Item NFT

<mark style="color:green;">`POST`</mark> `/v3/nft/assign`

**Headers**

| Name          | Value            |
| ------------- | ---------------- |
| X-Api-Key     | `API Key`        |
| Authorization | `Bearer <token>` |

**Body**

| Name                                                   | Type   | Description        |
| ------------------------------------------------------ | ------ | ------------------ |
| `collection_address`<mark style="color:red;">\*</mark> | string | Collection Address |
| `group_item`<mark style="color:red;">\*</mark>         | string | Group Item Name    |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "NFT Assigned to User",
    "data": {
        "inventory_id": 118214
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "error",
    "messages": {
        "assignNFTFailed": "Failed to Assign NFT. Possible Empty Stock."
    }
}
```

{% endtab %}
{% endtabs %}


# Inventory

## Get inventory item

<mark style="color:green;">`GET`</mark> `/v3/inventory`

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-Api-Key<mark style="color:red;">\*</mark>     | `API Key`        |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Inventory retrieved from database",
    "data": [
        {
            "inventory_id": "01HJ02C1TWCPEMHEWGQNZQ5TKK",
            "game_internal_id": "ship_y471_maikaze",
            "komo_item_name": "Y471 HSF Maikaze",
            "is_transferable": 0
        },
        {
            "inventory_id": "01HJ02PS54E5K1MHKK5DSAWWKF",
            "game_internal_id": "ship_y471_maikaze",
            "komo_item_name": "Y471 HSF Maikaze",
            "is_transferable": 0
        },
        {
            "inventory_id": "01HH4AAHAK8X7861JFJA5R67C9",
            "game_internal_id": "ship_y083_sarushima",
            "komo_item_name": "Y083 LCS Sarushima",
            "is_transferable": 0
        },
        {
            "inventory_id": "01J7ZMW9Q8Y20ZNN7HYQJF0VWP",
            "game_internal_id": "ship_kri_antasena",
            "komo_item_name": "KRI Antasena",
            "is_transferable": 0
        },
        {
            "inventory_id": "01HHKXM99KSD9H0B7JBH57S70Z",
            "game_internal_id": "ship_y467_harekaze",
            "komo_item_name": "Y467 HSF Harekaze",
            "is_transferable": 0
        },
        {
            "inventory_id": "01J8F2RJYZ238YF7CR5KTB5J49",
            "game_internal_id": "battle_pass_12.5",
            "komo_item_name": "Battle Pass Season 12.5",
            "is_transferable": 1
        },
        {
            "inventory_id": "01J8F2RJYZ238YF7CR5KTB5J4A",
            "game_internal_id": "battle_pass_12.5",
            "komo_item_name": "Battle Pass Season 12.5",
            "is_transferable": 0
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Disable Inventory Transfer

<mark style="color:green;">`POST`</mark> `/v3/inventory/disable-transfer`

**Headers**

| Name          | Value            |
| ------------- | ---------------- |
| X-API-Key     | `API Key`        |
| Authorization | `Bearer <token>` |

**Body**

| Name           | Type   | Description  |
| -------------- | ------ | ------------ |
| `inventory_id` | string | Inventory ID |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Inventory updated"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "error",
    "messages": {
        "updateFailed": "Failed to update inventory"
    }
}
```

{% endtab %}
{% endtabs %}

## Remove item from inventory

<mark style="color:green;">`POST`</mark> `/v3/inventory/remove`

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-Api-Key<mark style="color:red;">\*</mark>     | API Key          |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Body**

| Name                                             | Type   | Description  |
| ------------------------------------------------ | ------ | ------------ |
| `inventory_id`<mark style="color:red;">\*</mark> | string | Inventory ID |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Inventory removed"
}
```

{% endtab %}

{% tab title="400 (invalid ID)" %}

```json
{
    "status": "error",
    "messages": {
        "inventory_id": "The selected inventory id is invalid."
    }
}
```

{% endtab %}

{% tab title="400 (invalid owner)" %}

```json
{
    "status": "error",
    "messages": {
        "invalidOwner": "Invalid inventory owner"
    }
}
```

{% endtab %}

{% tab title="400 (invalid game)" %}

```json
{
    "status": "error",
    "messages": {
        "invalidGame": "This game is not authorized to remove this item"
    }
}
```

{% endtab %}
{% endtabs %}

## Inject mystery box ticket

<mark style="color:green;">`POST`</mark> `/v3/inventory/inject/mystery-box-ticket`

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-API-Key<mark style="color:red;">\*</mark>     | `API Key`        |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Body**

| Name                                    | Type   | Description               |
| --------------------------------------- | ------ | ------------------------- |
| `qty`<mark style="color:red;">\*</mark> | string | amount of ticket injected |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Mystery box ticket added"
}
```

{% endtab %}
{% endtabs %}

## Inject in-game items

<mark style="color:green;">`POST`</mark> `/v3/inventory/inject/in-game-item`

{% hint style="warning" %}
Before injecting to inventory, make sure the item is available on database alphagames `game_items` table
{% endhint %}

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-Api-Key<mark style="color:red;">\*</mark>     | `API Key`        |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Body**

| Name                                          | Type   | Description                                                   |
| --------------------------------------------- | ------ | ------------------------------------------------------------- |
| `item_list`<mark style="color:red;">\*</mark> | string | Stringified json of game\_internal\_id and qty. Example below |

**Example Payload**

{% code overflow="wrap" %}

```json
{
    "item_list": "[{\"game_internal_id\":\"life_30_minutes\",\"qty\":2},{\"game_internal_id\":\"other_internal_id\",\"qty\":3}]"
}
```

{% endcode %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Item injected successfully"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "error",
    "messages": {
        "itemNotExists": "Item with game_internal_id other_internal_id is not exist"
    }
}
```

{% endtab %}
{% endtabs %}

## Inject alfa voucher (from reward pool)

<mark style="color:green;">`POST`</mark> `/v3/inventory/inject/voucher`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name   | Type   | Description      |
| ------ | ------ | ---------------- |
| `name` | string | Name of the user |
| `age`  | number | Age of the user  |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "All voucher injected successfully"
}
```

{% endtab %}

{% tab title="400 (voucher stock below margin)" %}

```json
{
    "status": "error",
    "messages": {
        "stockBelowMargin": "Voucher stock for 25000 is below allowed margin."
    }
}
```

{% endtab %}

{% tab title="400 (invalid json data)" %}

```json
// qty is not integer or below 1
{
    "status": "error",
    "messages": {
        "invalidQty": "Invalid qty"
    }
}

// voucher_value is not available on database
{
    "status": "error",
    "messages": {
        "invalidVoucherValue": "Invalid voucher_value"
    }
}
```

{% endtab %}
{% endtabs %}


# Friend

## Friend List

## Get Friend List

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/friend/list`

`online_only` will show friends that make API activity on last 30 seconds. Currently this feature is not reliable if no game send user's activity via REST API. This will have better reliability after development of WebSocket as we will ping-pong the user every 5 seconds.

#### Headers

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

#### Request Body

| Name           | Type    | Description                                                                                                                |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| favorite\_only | Boolean | Only show favorite friends. Default <mark style="color:red;">false</mark>                                                  |
| online\_only   | Boolean | Only show online friends (<mark style="color:red;">read notes above</mark>). Default <mark style="color:red;">false</mark> |
| limit          | Integer | Limit amount of data shows. Default <mark style="color:red;">no limit</mark>                                               |
| offset         | Integer | Start showing data from number of offset. Default <mark style="color:red;">no offset</mark>                                |

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

```json
{
    "status": "success",
    "data": [
        {
            "komo_username": "kokomo",
            "in_game_display_name": "[PBR] Komodo",
            "profile_picture_url": "https://komo.s3.ap-southeast-1.amazonaws.com/profile-account/kokomo-XYXJ.jpg",
            "is_favorite": 0,
            "last_online": "2023-06-27 07:38:17"
        },
        ....
        {
            "komo_username": "dasdsa",
            "in_game_display_name": "dasdsa",
            "profile_picture_url": null,
            "is_favorite": 0,
            "last_online": "2023-06-27 07:37:51"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Friend Request

## Make a Friend Request

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/friend/request`

#### Headers

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

#### Request Body

| Name                                                     | Type   | Description                          |
| -------------------------------------------------------- | ------ | ------------------------------------ |
| target\_komo\_username<mark style="color:red;">\*</mark> | String | KOMO username to make friend request |

{% tabs %}
{% tab title="400: Bad Request Friend request to itself" %}

```json
{
    "status": "error",
    "messages": "Can not make friend request to itself"
}
```

{% endtab %}

{% tab title="200: OK " %}

```json
{
    "status": "success",
    "messages": "Friend request sent"
}
```

{% endtab %}

{% tab title="400: Bad Request Request already made" %}

```json
{
    "status": "error",
    "messages": "Friend request to this user already made"
}
```

{% endtab %}
{% endtabs %}

## Get Incoming Friend Request

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/friend/request/incoming`

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

```json
{
    "status": "success",
    "data": [
        {
            "relation_id": 1,
            "requester": "Aviabee",
            "requestee": "kokomo",
            "is_accepted": 0,
            "request_time": "2023-06-27 03:51:15",
            "accept_time": null
        },
        {
            "relation_id": 4,
            "requester": "polycrest",
            "requestee": "kokomo",
            "is_accepted": 0,
            "request_time": "2023-06-27 04:04:55",
            "accept_time": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Get Outgoing Friend Request

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/friend/request/outgoing`

#### Headers

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

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

```json
{
    "status": "success",
    "data": [
        {
            "relation_id": 1,
            "requester": "Aviabee",
            "requestee": "kokomo",
            "is_accepted": 0,
            "request_time": "2023-06-27 03:51:15",
            "accept_time": null
        },
        {
            "relation_id": 2,
            "requester": "Aviabee",
            "requestee": "dasdsa",
            "is_accepted": 0,
            "request_time": "2023-06-27 03:59:38",
            "accept_time": null
        },
        {
            "relation_id": 3,
            "requester": "Aviabee",
            "requestee": "polycrest",
            "is_accepted": 0,
            "request_time": "2023-06-27 03:59:44",
            "accept_time": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Accepting Friend Request

## Accepting a Friend Request

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/friend/request/accept`

#### Headers

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

#### Request Body

| Name                                           | Type    | Description |
| ---------------------------------------------- | ------- | ----------- |
| relation\_id<mark style="color:red;">\*</mark> | Integer | Relation ID |

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

```json
{
    "status": "success",
    "messages": "Friend request accepted"
}
```

{% endtab %}

{% tab title="400: Bad Request relation\_id is not for this user" %}

```json
{
    "status": "error",
    "messages": "You are not authorized to accept this relation"
}
```

{% endtab %}
{% endtabs %}

## Accepting All Pending Friend Request

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/friend/request/accept-all`

#### Headers

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

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

```json
{
    "status": "success",
    "messages": "All pending friend request accepted"
}
```

{% endtab %}

{% tab title="400: Bad Request No pending request" %}

```json
{
    "status": "error",
    "messages": "No pending friend request"
}
```

{% endtab %}
{% endtabs %}

## Favorite Friends

## Adding Friend to Favorites

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/friend/favorites/add`

#### Headers

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

#### Request Body

| Name                                                     | Type   | Description                    |
| -------------------------------------------------------- | ------ | ------------------------------ |
| target\_komo\_username<mark style="color:red;">\*</mark> | String | KOMO username to add favorites |

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

```json
{
    "status": "success",
    "messages": "Friend added to favorites"
}
```

{% endtab %}

{% tab title="400: Bad Request already favorited" %}

```json
{
    "status": "error",
    "messages": "Already added to favorites"
}
```

{% endtab %}
{% endtabs %}

## Removing Friend from Favorites

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/friend/favorites/remove`

#### Headers

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

#### Request Body

| Name                                                     | Type   | Description                       |
| -------------------------------------------------------- | ------ | --------------------------------- |
| target\_komo\_username<mark style="color:red;">\*</mark> | String | KOMO username to remove favorites |

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

```json
{
    "status": "success",
    "messages": "Friend removed from favorites"
}
```

{% endtab %}

{% tab title="400: Bad Request friend not in fav list" %}

```json
{
    "status": "error",
    "messages": "Friend is not on favorite list"
}
```

{% endtab %}
{% endtabs %}

## Removing Friend

## Removing a Friend from Friend List

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/friend/remove`

<mark style="color:red;">**WARNING!!! This will remove friend relation from both friend list**</mark>

#### Headers

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

#### Request Body

| Name                                                     | Type   | Description                        |
| -------------------------------------------------------- | ------ | ---------------------------------- |
| target\_komo\_username<mark style="color:red;">\*</mark> | String | KOMO username of friends to remove |

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

```json
{
    "status": "success",
    "messages": "Friend removed successfully"
}
```

{% endtab %}

{% tab title="400: Bad Request User not friend with target" %}

```json
{
    "status": "error",
    "messages": "Friend relation not found"
}
```

{% endtab %}
{% endtabs %}


# Tournament

## Read Tournament Result

## Read Tournament Result

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/tournament/read/[tournament_id]`

#### Path Parameters

| Name                                             | Type   | Description   |
| ------------------------------------------------ | ------ | ------------- |
| tournament\_id<mark style="color:red;">\*</mark> | String | Tournament ID |

#### Headers

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

{% tabs %}
{% tab title="200: OK Single Elimination" %}

```javascript
{
    "status": "success",
    "tournament_data": {
        "tournament_id": "6360e665edf88",
        "game_id": "DJAKSFNJSA",
        "tournament_name": "Test Tournament",
        "description": "lorem ipsum dolor sit amet",
        "start_time": "2022-11-03 00:00:00",
        "end_time": "2022-12-03 00:00:00",
        "tournament_type": "single_elim",
        "participant_limit": 8
    },
    "tournament_result": [
        {
            "id": 1,
            "round_no": 1,
            "match_no": 1,
            "komo_username": "leoleo",
            "status": "W",
            "placeholder": "Player Slot 1"
        },
        {
            "id": 2,
            "round_no": 1,
            "match_no": 1,
            "komo_username": "maymay",
            "status": "L",
            "placeholder": "Player Slot 2"
        },
        {
            "id": 3,
            "round_no": 1,
            "match_no": 2,
            "komo_username": "Aviabee",
            "status": "W",
            "placeholder": "Player Slot 3"
        },
        {
            "id": 4,
            "round_no": 1,
            "match_no": 2,
            "komo_username": "Kazky",
            "status": "L",
            "placeholder": "Player Slot 4"
        },
        {
            "id": 5,
            "round_no": 1,
            "match_no": 3,
            "komo_username": "bogei",
            "status": "L",
            "placeholder": "Player Slot 5"
        },
        {
            "id": 6,
            "round_no": 1,
            "match_no": 3,
            "komo_username": "bambang",
            "status": "W",
            "placeholder": "Player Slot 6"
        },
        {
            "id": 7,
            "round_no": 1,
            "match_no": 4,
            "komo_username": "yrdna",
            "status": "L",
            "placeholder": "Player Slot 7"
        },
        {
            "id": 8,
            "round_no": 1,
            "match_no": 4,
            "komo_username": "komochess",
            "status": "W",
            "placeholder": "Player Slot 8"
        },
        {
            "id": 9,
            "round_no": 2,
            "match_no": 5,
            "komo_username": "leoleo",
            "status": "L",
            "placeholder": "Winner Match #1"
        },
        {
            "id": 10,
            "round_no": 2,
            "match_no": 5,
            "komo_username": "Aviabee",
            "status": "W",
            "placeholder": "Winner Match #2"
        },
        {
            "id": 11,
            "round_no": 2,
            "match_no": 6,
            "komo_username": "bambang",
            "status": "L",
            "placeholder": "Winner Match #3"
        },
        {
            "id": 12,
            "round_no": 2,
            "match_no": 6,
            "komo_username": "komochess",
            "status": "W",
            "placeholder": "Winner Match #4"
        },
        {
            "id": 13,
            "round_no": 3,
            "match_no": 7,
            "komo_username": "Aviabee",
            "status": "W",
            "placeholder": "Winner Match #5"
        },
        {
            "id": 14,
            "round_no": 3,
            "match_no": 7,
            "komo_username": "komochess",
            "status": "L",
            "placeholder": "Winner Match #6"
        }
    ]
}
```

{% endtab %}

{% tab title="200: OK Round Robin" %}

```javascript
{
    "status": "success",
    "tournament_data": {
        "tournament_id": "63843297e5bbf",
        "game_id": "komowars",
        "tournament_name": "Round Robin Tournament",
        "description": "lorem ipsum dolor sit amet",
        "start_time": "2022-12-03 00:00:00",
        "end_time": "2023-12-13 00:00:00",
        "tournament_type": "round_robin",
        "participant_limit": 10
    },
    "tournament_result": [
        {
            "id": 1,
            "round_no": 1,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "pigroast",
            "komo_username_B": "bambang",
            "match_winner": "pigroast"
        },
        {
            "id": 2,
            "round_no": 1,
            "match_no": 2,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "Aviabee"
        },
        {
            "id": 3,
            "round_no": 1,
            "match_no": 3,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "kazky"
        },
        {
            "id": 4,
            "round_no": 1,
            "match_no": 4,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "Eful"
        },
        {
            "id": 5,
            "round_no": 1,
            "match_no": 5,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "polycrest"
        },
        {
            "id": 6,
            "round_no": 2,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "pigroast",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 7,
            "round_no": 2,
            "match_no": 2,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 8,
            "round_no": 2,
            "match_no": 3,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "X"
        },
        {
            "id": 9,
            "round_no": 2,
            "match_no": 4,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 10,
            "round_no": 2,
            "match_no": 5,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 11,
            "round_no": 3,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "pigroast",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 12,
            "round_no": 3,
            "match_no": 2,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "X"
        },
        {
            "id": 13,
            "round_no": 3,
            "match_no": 3,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 14,
            "round_no": 3,
            "match_no": 4,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 15,
            "round_no": 3,
            "match_no": 5,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 16,
            "round_no": 4,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "pigroast",
            "komo_username_B": "Eful",
            "match_winner": "X"
        },
        {
            "id": 17,
            "round_no": 4,
            "match_no": 2,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 18,
            "round_no": 4,
            "match_no": 3,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 19,
            "round_no": 4,
            "match_no": 4,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 20,
            "round_no": 4,
            "match_no": 5,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 21,
            "round_no": 5,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "pigroast",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 22,
            "round_no": 5,
            "match_no": 2,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 23,
            "round_no": 5,
            "match_no": 3,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 24,
            "round_no": 5,
            "match_no": 4,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 25,
            "round_no": 5,
            "match_no": 5,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 26,
            "round_no": 6,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "pigroast",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 27,
            "round_no": 6,
            "match_no": 2,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 28,
            "round_no": 6,
            "match_no": 3,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 29,
            "round_no": 6,
            "match_no": 4,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 30,
            "round_no": 6,
            "match_no": 5,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 31,
            "round_no": 7,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "pigroast",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 32,
            "round_no": 7,
            "match_no": 2,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 33,
            "round_no": 7,
            "match_no": 3,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 34,
            "round_no": 7,
            "match_no": 4,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 35,
            "round_no": 7,
            "match_no": 5,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 36,
            "round_no": 8,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "pigroast",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 37,
            "round_no": 8,
            "match_no": 2,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 38,
            "round_no": 8,
            "match_no": 3,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 39,
            "round_no": 8,
            "match_no": 4,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 40,
            "round_no": 8,
            "match_no": 5,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 41,
            "round_no": 9,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "pigroast",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 42,
            "round_no": 9,
            "match_no": 2,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 43,
            "round_no": 9,
            "match_no": 3,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 44,
            "round_no": 9,
            "match_no": 4,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 45,
            "round_no": 9,
            "match_no": 5,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "X"
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# 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 %}


# Ads

### Stream Ads

<mark style="color:blue;">`GET`</mark> `http://api.komoverse.dev/v2/stream-ads`

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| x-api-key<mark style="color:red;">\*</mark>     | String | Api key      |
| Authorization<mark style="color:red;">\*</mark> | Bearer | Token bearer |

{% tabs %}
{% tab title="200: OK Successfull Showing List Ads" %}

```json
{
    "status": "Success",
    "data": [
        {
            "title_ads": "One Heart",
            "business_name": "Honda",
            "website_ads": "https://www.astra-honda.com/",
            "target_country_ads": [
                "AFG",
                "ARG",
                "AUS"
            ],
            "id_ads": "3a80a5792c584ec1a1016019de33957b",
            "cloudflare_watch_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/3a80a5792c584ec1a1016019de33957b/watch",
            "cloudflare_hls_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/3a80a5792c584ec1a1016019de33957b/manifest/video.m3u8",
            "cloudflare_dash_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/3a80a5792c584ec1a1016019de33957b/manifest/video.mpd",
            "cloudflare_mp4_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/3a80a5792c584ec1a1016019de33957b/downloads/default.mp4"
        },
        {
            "title_ads": "Iphone 14 Pro",
            "business_name": "Apple",
            "website_ads": "https://www.apple.com/",
            "target_country_ads": [
                "AFG",
                "ARG",
                "AUS",
                "IDN",
                "PHL"
            ],
            "id_ads": "035831e9a68b42629d57e0f18ed35d3c",
            "cloudflare_watch_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/035831e9a68b42629d57e0f18ed35d3c/watch",
            "cloudflare_hls_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/035831e9a68b42629d57e0f18ed35d3c/manifest/video.m3u8",
            "cloudflare_dash_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/035831e9a68b42629d57e0f18ed35d3c/manifest/video.mpd",
            "cloudflare_mp4_api": "https://customer-0of4q484a82jyq4e.cloudflarestream.com/035831e9a68b42629d57e0f18ed35d3c/downloads/default.mp4"
        }
    ]
}
```

{% endtab %}

{% tab title="403: Forbidden Error not fill x-api-key" %}

```json
{
    "status": "error",
    "messages": {
        "apiKeyRequired": "An API key is required to perform this request. If you wish to use the KOMO API in your application, contact the Komoverse team to reach out for an agreement."
    }
}
```

{% endtab %}

{% tab title="403: Forbidden Error not fill authorization bearer token" %}

```json
{
    "status": "error",
    "messages": {
        "tokenRequired": "A login token is required to perform this request."
    }
}
```

{% endtab %}
{% endtabs %}

### Update Click and Views Ads

<mark style="color:orange;">`PUT`</mark> `http://api.komoverse.dev/v2/stream-ads/{id_ads}`

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| x-api-key<mark style="color:red;">\*</mark>     | String | API key      |
| Authorization<mark style="color:red;">\*</mark> | Bearer | Bearer Token |

#### Request Body

| Name                                    | Type    | Description  |
| --------------------------------------- | ------- | ------------ |
| views<mark style="color:red;">\*</mark> | Integer | Number views |
| click<mark style="color:red;">\*</mark> | Integer | Number click |

{% tabs %}
{% tab title="201: Created Successfully update click and views" %}

```json
{
    "message": "Update Ads Successfully!",
    "status": "success"
}
```

{% endtab %}

{% tab title="400: Bad Request Missing a body request" %}

```json
{
    "status": "error",
    "message": {
        "views": [
            "The views field is required."
        ],
        "click": [
            "The click field is required."
        ]
    }
}
```

{% endtab %}
{% endtabs %}


# Purchasing In-Game Items

## Direct Purchase with SHARD

* This API limited to 100,000 SHARD per transaction
* This API does not need user interaction to confirm the purchase, if you want to have user confirmation, you will need to do it from the game

## Pay Transaction with SHARD

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/transaction/pay-with-shard`

#### Headers

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

#### Request Body

| Name                                           | Type    | Description                                                             |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------- |
| description<mark style="color:red;">\*</mark>  | String  | Description of purchase, can be transaction ID generated from your game |
| shard\_price<mark style="color:red;">\*</mark> | Integer | Price to purchase in SHARD                                              |

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

```json
{
    "status": "success",
    "message": "Payment with SHARD Success",
    "data": {
        "KOMO_TX_ID": "48CBD65AC89E4D62260DD95A0A5680F7",
        "shard_price": "100",
        "description": "TEST1"
    }
}
```

{% endtab %}

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

```json
{
    "status": "error",
    "messages": "Insufficient SHARD"
}
```

{% endtab %}
{% endtabs %}

## Create Item Purchase Transaction

Another method to purchase game item with SHARD is using this API

1. Create transaction using `/v3/cashier/create` API. Notes: when you set callback\_url to your own server, you will receive webhook notification when user completed the payment. Otherwise, you will need to check if the payment has been done via `/v3/cashier/check` API.
2. After creating the transaction, you will be given URL to KOMO Cashier
3. Your game need to open this URL either with webview or open on the browser
4. If the user does not have enough SHARD to pay, then user can use other payment method to fulfill the transaction

## Create Transaction

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

#### Request Body

| Name                                                    | Type   | Description                                                                               |
| ------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| game\_transaction\_id<mark style="color:red;">\*</mark> | String | Transaction ID for your own purpose                                                       |
| list\_items<mark style="color:red;">\*</mark>           | JSON   | JSON array for list of purchased items [see below format](#example-of-list_items-payload) |
| callback\_url                                           | String | Your own webhook URL to receive confirmation callback                                     |

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

```json
{
    "status": "success",
    "messages": "Transaction created. Please open the URL below.",
    "data": {
        "game_tx_id": "KC-XXXXXX",
        "komo_tx_id": "A5B08BC5A5EA2645AE506E34DF56B03A",
        "webview_url": "https://cashier.komoverse.io?tx_id=A5B08BC5A5EA2645AE506E34DF56B03A"
    }
}
```

{% endtab %}
{% endtabs %}

## Check Transaction Status

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/cashier/check`

#### Query Parameters

| Name                                           | Type   | Description              |
| ---------------------------------------------- | ------ | ------------------------ |
| komo\_tx\_id<mark style="color:red;">\*</mark> | String | Komoverse Transaction ID |

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

```json
{
    "status": "success",
    "data": {
        "komo_tx_id": "A5B08BC5A5EA2645AE506E34DF56B03A",
        "game_tx_id": "KC-XXXXXX",
        "total_price": 40000,
        "payment_status": "pending"
    }
}
```

{% endtab %}
{% endtabs %}

#### Example of list\_items payload

```json
[
  {
    "item_image_url": "https://via.placeholder.com/200",
    "item_name": "Booster Item",
    "quantity": 2,
    "price": 5000
  },
  {
    "item_image_url": "https://via.placeholder.com/200",
    "item_name": "Booster XP",
    "quantity": 3,
    "price": 10000
  }
]
```

{% hint style="warning" %}
Please serialize / stringify the JSON array if you are sending payload as json instead of form-data
{% endhint %}


# Introduction

Welcome to the Admin / Server API documentation! This API is designed to provide comprehensive functionalities for managing and administering your game environment. It is important to note that this API does not require player login for authentication, making it specifically tailored for administrative purposes.

## Authenticating Admin / Server API Request

As mentioned earlier, authentication through player login is not required for accessing the Admin / Server API endpoints. This means that you can freely perform administrative tasks without the need for player credentials.

To ensure secure access to the Admin / Server API, we utilize Basic authorization. The authentication process involves including your client credentials as part of the authorization header when making API requests.

#### Step 1: Obtain Client Credentials

Before you can authenticate your requests, you need to obtain your client credentials, which consist of a `client_id` and a `client_secret`. These credentials are provided to you from Developer Dashboard.

#### Step 2: Include Authorization Header

When sending API requests, include the `Authorization` header in the following format:

```
Authorization: Basic <base64_encoded_credentials>
```

Replace `<base64_encoded_credentials>` with the Base64-encoded string of your client credentials in the format `client_id:client_secret`. For example, if your `client_id` is "my\_client" and your `client_secret` is "my\_secret", the header would look like:

```
Authorization: Basic bXlfY2xpZW50Om15X3NlY3JldA==
```

#### Step 3: Send API Requests

Send your API requests with the included `Authorization` header. The server will validate your credentials and grant access to the requested endpoints.

#### Handling Authentication Errors

If your authentication fails or the provided credentials are invalid, you will receive an appropriate error response (e.g., HTTP 401 Unauthorized). In such cases, verify that you have correctly included the `Authorization` header with the valid client credentials.

{% hint style="warning" %}
Ensure that you securely store and manage your client credentials, as they grant administrative access to your game environment. Treat them as sensitive information and avoid exposing them to unauthorized individuals.
{% endhint %}

## API Usage

The Admin / Server API offers a wide range of endpoints to assist you in managing your game environment efficiently. These endpoints enable you to perform tasks such as:

1. Managing tournaments: create tournament for your game, assign players to the tournament slot, set the winner of tournament matches
2. Item shop: create your own in-game shop, add or remove items from the shop, view shop transactions


# Player Account

## Link KOMO Account with Existing Game Account

<mark style="color:green;">`POST`</mark> `[endpoint]/api/server/account/linked/link`

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | String | Base64 Basic Auth |

#### Request Body

| Name                                                 | Type   | Description               |
| ---------------------------------------------------- | ------ | ------------------------- |
| komo\_username<mark style="color:red;">\*</mark>     | String | KOMO Username             |
| provider\_user\_id<mark style="color:red;">\*</mark> | String | Account ID from Your Game |

{% tabs %}
{% tab title="200: OK Link Success" %}

```json
{
    "status": "success",
    "message": "Link Account Success",
    "data": {
        "komo_username": "kokomo",
        "provider": "komochess",
        "provider_user_id": "28654165468846165"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Link Already Exists" %}

```json
{
    "status": "error",
    "messages": "KOMO Account Already Have Linked Account"
}
```

{% endtab %}
{% endtabs %}


# Tournament

## Creating a Tournament

## Create Tournament

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

#### Query Parameters

| Name                                                 | Type     | Description                                           |
| ---------------------------------------------------- | -------- | ----------------------------------------------------- |
| game\_id<mark style="color:red;">\*</mark>           | String   | Game ID                                               |
| 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>        | Datetime | Tournament Start Time                                 |
| end\_time<mark style="color:red;">\*</mark>          | Datetime | Tournament End Time                                   |
| participant\_limit<mark style="color:red;">\*</mark> | Integer  | Limit No. of Participant, see hint below              |
| tournament\_type<mark style="color:red;">\*</mark>   | String   | leaderboard, single\_elim, double\_elim, round\_robin |

#### Headers

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

{% tabs %}
{% tab title="200: OK Tournament Created" %}

```javascript
{
    "status": "success",
    "message": "Tournament 63804c7ede700 Created "
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
For `single_elim` and `double_elim` tournament type, `participant_limit` currently only support power of two numbers (2, 4, 8, 16, etc)

For `leaderboard` tournament type, use 0 for unlimited.

For `round_robin` tournament type,`participant_limit` must be even number.&#x20;
{% endhint %}

## Read Tournament Result

{% hint style="success" %}
Also available as Player API
{% endhint %}

## Read Tournament Result

<mark style="color:blue;">`GET`</mark> `[endpoint]/v3/tournament/read/[tournament_id]`

#### Path Parameters

| Name                                             | Type   | Description   |
| ------------------------------------------------ | ------ | ------------- |
| tournament\_id<mark style="color:red;">\*</mark> | String | Tournament ID |

#### Headers

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

{% tabs %}
{% tab title="200: OK Single Elimination" %}

```javascript
{
    "status": "success",
    "tournament_data": {
        "tournament_id": "6360e665edf88",
        "game_id": "DJAKSFNJSA",
        "tournament_name": "Test Tournament",
        "description": "lorem ipsum dolor sit amet",
        "start_time": "2022-11-03 00:00:00",
        "end_time": "2022-12-03 00:00:00",
        "tournament_type": "single_elim",
        "participant_limit": 8
    },
    "tournament_result": [
        {
            "id": 1,
            "round_no": 1,
            "match_no": 1,
            "komo_username": "leoleo",
            "status": "W",
            "placeholder": "Player Slot 1"
        },
        {
            "id": 2,
            "round_no": 1,
            "match_no": 1,
            "komo_username": "maymay",
            "status": "L",
            "placeholder": "Player Slot 2"
        },
        {
            "id": 3,
            "round_no": 1,
            "match_no": 2,
            "komo_username": "Aviabee",
            "status": "W",
            "placeholder": "Player Slot 3"
        },
        {
            "id": 4,
            "round_no": 1,
            "match_no": 2,
            "komo_username": "Kazky",
            "status": "L",
            "placeholder": "Player Slot 4"
        },
        {
            "id": 5,
            "round_no": 1,
            "match_no": 3,
            "komo_username": "bogei",
            "status": "L",
            "placeholder": "Player Slot 5"
        },
        {
            "id": 6,
            "round_no": 1,
            "match_no": 3,
            "komo_username": "bambang",
            "status": "W",
            "placeholder": "Player Slot 6"
        },
        {
            "id": 7,
            "round_no": 1,
            "match_no": 4,
            "komo_username": "yrdna",
            "status": "L",
            "placeholder": "Player Slot 7"
        },
        {
            "id": 8,
            "round_no": 1,
            "match_no": 4,
            "komo_username": "komochess",
            "status": "W",
            "placeholder": "Player Slot 8"
        },
        {
            "id": 9,
            "round_no": 2,
            "match_no": 5,
            "komo_username": "leoleo",
            "status": "L",
            "placeholder": "Winner Match #1"
        },
        {
            "id": 10,
            "round_no": 2,
            "match_no": 5,
            "komo_username": "Aviabee",
            "status": "W",
            "placeholder": "Winner Match #2"
        },
        {
            "id": 11,
            "round_no": 2,
            "match_no": 6,
            "komo_username": "bambang",
            "status": "L",
            "placeholder": "Winner Match #3"
        },
        {
            "id": 12,
            "round_no": 2,
            "match_no": 6,
            "komo_username": "komochess",
            "status": "W",
            "placeholder": "Winner Match #4"
        },
        {
            "id": 13,
            "round_no": 3,
            "match_no": 7,
            "komo_username": "Aviabee",
            "status": "W",
            "placeholder": "Winner Match #5"
        },
        {
            "id": 14,
            "round_no": 3,
            "match_no": 7,
            "komo_username": "komochess",
            "status": "L",
            "placeholder": "Winner Match #6"
        }
    ]
}
```

{% endtab %}

{% tab title="200: OK Round Robin" %}

```javascript
{
    "status": "success",
    "tournament_data": {
        "tournament_id": "63843297e5bbf",
        "game_id": "komowars",
        "tournament_name": "Round Robin Tournament",
        "description": "lorem ipsum dolor sit amet",
        "start_time": "2022-12-03 00:00:00",
        "end_time": "2023-12-13 00:00:00",
        "tournament_type": "round_robin",
        "participant_limit": 10
    },
    "tournament_result": [
        {
            "id": 1,
            "round_no": 1,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "pigroast",
            "komo_username_B": "bambang",
            "match_winner": "pigroast"
        },
        {
            "id": 2,
            "round_no": 1,
            "match_no": 2,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "Aviabee"
        },
        {
            "id": 3,
            "round_no": 1,
            "match_no": 3,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "kazky"
        },
        {
            "id": 4,
            "round_no": 1,
            "match_no": 4,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "Eful"
        },
        {
            "id": 5,
            "round_no": 1,
            "match_no": 5,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "polycrest"
        },
        {
            "id": 6,
            "round_no": 2,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "pigroast",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 7,
            "round_no": 2,
            "match_no": 2,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 8,
            "round_no": 2,
            "match_no": 3,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "X"
        },
        {
            "id": 9,
            "round_no": 2,
            "match_no": 4,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 10,
            "round_no": 2,
            "match_no": 5,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 11,
            "round_no": 3,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "pigroast",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 12,
            "round_no": 3,
            "match_no": 2,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "X"
        },
        {
            "id": 13,
            "round_no": 3,
            "match_no": 3,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 14,
            "round_no": 3,
            "match_no": 4,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 15,
            "round_no": 3,
            "match_no": 5,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 16,
            "round_no": 4,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "pigroast",
            "komo_username_B": "Eful",
            "match_winner": "X"
        },
        {
            "id": 17,
            "round_no": 4,
            "match_no": 2,
            "placeholder_A": "Player Slot #5",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "b0gei",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 18,
            "round_no": 4,
            "match_no": 3,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 19,
            "round_no": 4,
            "match_no": 4,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 20,
            "round_no": 4,
            "match_no": 5,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 21,
            "round_no": 5,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #10",
            "komo_username_A": "pigroast",
            "komo_username_B": "polycrest",
            "match_winner": "X"
        },
        {
            "id": 22,
            "round_no": 5,
            "match_no": 2,
            "placeholder_A": "Player Slot #6",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "bambang",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 23,
            "round_no": 5,
            "match_no": 3,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 24,
            "round_no": 5,
            "match_no": 4,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 25,
            "round_no": 5,
            "match_no": 5,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 26,
            "round_no": 6,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #2",
            "komo_username_A": "pigroast",
            "komo_username_B": "Aviabee",
            "match_winner": "X"
        },
        {
            "id": 27,
            "round_no": 6,
            "match_no": 2,
            "placeholder_A": "Player Slot #7",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "maymay",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 28,
            "round_no": 6,
            "match_no": 3,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 29,
            "round_no": 6,
            "match_no": 4,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 30,
            "round_no": 6,
            "match_no": 5,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 31,
            "round_no": 7,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #3",
            "komo_username_A": "pigroast",
            "komo_username_B": "kazky",
            "match_winner": "X"
        },
        {
            "id": 32,
            "round_no": 7,
            "match_no": 2,
            "placeholder_A": "Player Slot #8",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "ainuka",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 33,
            "round_no": 7,
            "match_no": 3,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 34,
            "round_no": 7,
            "match_no": 4,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 35,
            "round_no": 7,
            "match_no": 5,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 36,
            "round_no": 8,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #4",
            "komo_username_A": "pigroast",
            "komo_username_B": "leoleole",
            "match_winner": "X"
        },
        {
            "id": 37,
            "round_no": 8,
            "match_no": 2,
            "placeholder_A": "Player Slot #9",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "Eful",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 38,
            "round_no": 8,
            "match_no": 3,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 39,
            "round_no": 8,
            "match_no": 4,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 40,
            "round_no": 8,
            "match_no": 5,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 41,
            "round_no": 9,
            "match_no": 1,
            "placeholder_A": "Player Slot #1",
            "placeholder_B": "Player Slot #5",
            "komo_username_A": "pigroast",
            "komo_username_B": "b0gei",
            "match_winner": "X"
        },
        {
            "id": 42,
            "round_no": 9,
            "match_no": 2,
            "placeholder_A": "Player Slot #10",
            "placeholder_B": "Player Slot #6",
            "komo_username_A": "polycrest",
            "komo_username_B": "bambang",
            "match_winner": "X"
        },
        {
            "id": 43,
            "round_no": 9,
            "match_no": 3,
            "placeholder_A": "Player Slot #2",
            "placeholder_B": "Player Slot #7",
            "komo_username_A": "Aviabee",
            "komo_username_B": "maymay",
            "match_winner": "X"
        },
        {
            "id": 44,
            "round_no": 9,
            "match_no": 4,
            "placeholder_A": "Player Slot #3",
            "placeholder_B": "Player Slot #8",
            "komo_username_A": "kazky",
            "komo_username_B": "ainuka",
            "match_winner": "X"
        },
        {
            "id": 45,
            "round_no": 9,
            "match_no": 5,
            "placeholder_A": "Player Slot #4",
            "placeholder_B": "Player Slot #9",
            "komo_username_A": "leoleole",
            "komo_username_B": "Eful",
            "match_winner": "X"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Managing Single Elimination Type Tournament

After creating tournament with tournament\_type `single_elim`, we automatically create a bracket.

We also provide preview of the bracket here:

{% hint style="info" %}
\[endpoint]/view-tournament/\[tournament\_id]&#x20;

Preview: [Tournament #6360e665edf88](https://api.komoverse.io/view-tournament/6360e665edf88)
{% endhint %}

## Asigning Player Into Player Slot

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/tournament/bracket/assign`

To see availability of player slot in the bracket, find the **null** value on `komo_username` after getting `/v2/tournament/read/[tournament_id]`

#### Query Parameters

| Name                                             | Type    | Description            |
| ------------------------------------------------ | ------- | ---------------------- |
| tournament\_id<mark style="color:red;">\*</mark> | String  | Tournament ID          |
| komo\_username<mark style="color:red;">\*</mark> | String  | KOMO Username          |
| player\_slot<mark style="color:red;">\*</mark>   | Integer | Player Slot in Bracket |

#### Headers

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

{% tabs %}
{% tab title="403: Forbidden Slot already used" %}

```javascript
{
    "status": "error",
    "message": "Slot Already Occupied by komochess"
}
```

{% endtab %}

{% tab title="200: OK Slot assigned" %}

```javascript
{
    "status": "success",
    "message": "Player Slot 1 Assigned to Aviabee"
}
```

{% endtab %}
{% endtabs %}

## Update Bracket Winner

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/tournament/bracket/update`

Use this API to update match winner from a bracket match. It will also automatically move the winner into next bracket.

#### Query Parameters

| Name                                             | Type    | Description                   |
| ------------------------------------------------ | ------- | ----------------------------- |
| tournament\_id<mark style="color:red;">\*</mark> | String  | Tournament ID                 |
| match\_no<mark style="color:red;">\*</mark>      | Integer | Match Number in Bracket       |
| match\_winner<mark style="color:red;">\*</mark>  | String  | KOMO Username of Match Winner |

#### Headers

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

{% tabs %}
{% tab title="200: OK Bracket Updated" %}

```javascript
{
    "status": "success",
    "message": "Tournament Bracket Successfully Updated"
}
```

{% endtab %}
{% endtabs %}

## Managing Round Robin Type Tournament

After creating tournament with tournament\_type `round_robin`, we automatically create a match schedule.

We also provide preview of the schedule here:

{% hint style="info" %}
\[endpoint]/view-round-robin/\[tournament\_id]&#x20;

Preview: [Tournament #63843297e5bbf](https://api.komoverse.io/view-round-robin/63843297e5bbf)
{% endhint %}

## Asigning Player Into Player Slot

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/tournament/robin/assign`

To see availability of player slot in the bracket, find the **null** value on `komo_username_A` after getting `/v2/tournament/read/[tournament_id]`

#### Query Parameters

| Name                                             | Type    | Description                         |
| ------------------------------------------------ | ------- | ----------------------------------- |
| tournament\_id<mark style="color:red;">\*</mark> | String  | Tournament ID                       |
| komo\_username<mark style="color:red;">\*</mark> | String  | KOMO Username                       |
| player\_slot<mark style="color:red;">\*</mark>   | Integer | Player Slot in Round Robin Schedule |

#### Headers

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

{% tabs %}
{% tab title="403: Forbidden Slot already used" %}

```javascript
{
    "status": "error",
    "message": "Slot Already Occupied by Aviabee"
}
```

{% endtab %}

{% tab title="200: OK Slot assigned" %}

```javascript
{
    "status": "success",
    "message": "Player Slot #2 Assigned to Aviabee"
}
```

{% endtab %}
{% endtabs %}

## Update Match Winner

<mark style="color:green;">`POST`</mark> `[endpoint]/v3/tournament/robin/update`

Use this API to update match winner from a round robin match

#### Query Parameters

| Name                                             | Type    | Description                   |
| ------------------------------------------------ | ------- | ----------------------------- |
| tournament\_id<mark style="color:red;">\*</mark> | String  | Tournament ID                 |
| match\_id<mark style="color:red;">\*</mark>      | Integer | Match ID                      |
| match\_winner<mark style="color:red;">\*</mark>  | String  | KOMO Username of Match Winner |

#### Headers

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

{% tabs %}
{% tab title="200: OK Winner Updated" %}

```javascript
{
    "status": "success",
    "message": "Match Winner Updated"
}
```

{% endtab %}

{% tab title="403: Forbidden Winner is not on the match" %}

```javascript
{
    "status": "error",
    "message": "match_winner is Not On This match_id"
}
```

{% endtab %}
{% endtabs %}


# 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 %}


