# Getting Started

### API Token

To get a token you must first login to your [dashboard](https://kawaii.red/dashboard/) where you will find your personal api token.&#x20;

{% hint style="info" %}
If you don't want to log in or you think the stat functions are necessary you can use the token `anonymous` instead of your token so you can still use the api but you will miss some functions.
{% endhint %}

> If you want to know more about the token (how, why and where) you can check here:

{% content-ref url="tutorials/token" %}
[token](https://docs.kawaii.red/tutorials/token)
{% endcontent-ref %}

### API Request

For testing you can make the api requests also via the browser.

## Basic Request

<mark style="color:blue;">`GET`</mark> `https://kawaii.red/api/MAIN/SUB?token=TOKEN&type=TYPE&filter=FILTER`

The structure of the request system.

#### Path Parameters

| Name                                    | Type     | Description                                                                                          |
| --------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
| MAIN<mark style="color:red;">\*</mark>  | Endpoint | Here you make the rough choice which main endpoint you want to target.                               |
| SUB<mark style="color:red;">\*</mark>   | Endpoint | Here you make the selection of which endpoint you want to go to in the previously selected category. |
| TOKEN<mark style="color:red;">\*</mark> | String   | Here comes your api token or anonymous in (note the token information).                              |
| FILTER                                  | List     | With the filter you can filter possible unwanted responses so that the api does not return them.     |
| TYPE                                    | String   | You can specify the type of response depending on what is easier for you to implement.               |

{% tabs %}
{% tab title="200 The API returns a 200 OK response with the requested data." %}

```json
{
   "response": "Requested content"
}
```

{% endtab %}
{% endtabs %}

## Example Request

<mark style="color:blue;">`GET`</mark> `https://kawaii.red/api/gif/hug?token=anonymous`

You can open this link in your browser.

#### Path Parameters

| Name                                        | Type  | Description                                                              |
| ------------------------------------------- | ----- | ------------------------------------------------------------------------ |
| gif<mark style="color:red;">\*</mark>       | MAIN  | The category Gif Endpoints.                                              |
| hug<mark style="color:red;">\*</mark>       | SUB   | The hug endpoint.                                                        |
| anonymous<mark style="color:red;">\*</mark> | TOKEN | The token in this case is the anonymous one which has no stats function. |

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

```json
{
   "response":"https://api.kawaii.red/gif/hug/hug1.gif"
}
```

{% endtab %}
{% endtabs %}

### NEW! API Request

The new way is completely header-based, so please use an extra tool for testing.

## Basic Request

<mark style="color:blue;">`GET`</mark> `https://kawaii.red/api/main/sub`

#### Path Parameters

| Name                                   | Type     | Description                                                                                          |
| -------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
| main<mark style="color:red;">\*</mark> | Endpoint | Here you make the rough choice which main endpoint you want to target.                               |
| sub<mark style="color:red;">\*</mark>  | Endpoint | Here you make the selection of which endpoint you want to go to in the previously selected category. |

#### Headers

| Name                                    | Type   | Description                                                                                      |
| --------------------------------------- | ------ | ------------------------------------------------------------------------------------------------ |
| token<mark style="color:red;">\*</mark> | String | Here comes your api token or anonymous in (note the token information).                          |
| type                                    | String | You can specify the type of response depending on what is easier for you to implement.           |
| filter                                  | List   | With the filter you can filter possible unwanted responses so that the api does not return them. |

{% tabs %}
{% tab title="200: OK The API returns a 200 OK response with the request data." %}

```
{
   "response": "Requested content"
}
```

{% endtab %}
{% endtabs %}

## Example Request

<mark style="color:blue;">`GET`</mark> `https://kawaii.red/api/gif/hug`

#### Path Parameters

| Name                                  | Type | Description                 |
| ------------------------------------- | ---- | --------------------------- |
| gif<mark style="color:red;">\*</mark> | main | The category Gif Endpoints. |
| hug<mark style="color:red;">\*</mark> | sub  | The hug endpoint            |

#### Headers

| Name                                        | Type  | Description                                                              |
| ------------------------------------------- | ----- | ------------------------------------------------------------------------ |
| anonymous<mark style="color:red;">\*</mark> | token | The token in this case is the anonymous one which has no stats function. |

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

```
{
   "response":"https://api.kawaii.red/gif/hug/hug1.gif"
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
The api always returns a <mark style="color:green;">200: OK</mark> message even for wrong requests, however it gives an error message out with the exact reason should something be wrong.

> **Error layout:**
>
> ```
> {
>    "error": f"Error reason! For more information go to https://kawaii.red/docs/"
> }
> ```

{% endhint %}

> Here you will find a detailed explanation for all cases and with more detailed explanations of how it works:

{% content-ref url="request-structure" %}
[request-structure](https://docs.kawaii.red/request-structure)
{% endcontent-ref %}

### API Endpoints

{% content-ref url="endpoints/text" %}
[text](https://docs.kawaii.red/endpoints/text)
{% endcontent-ref %}

> Currently not yet ready. I'm sorry.

{% content-ref url="endpoints/image" %}
[image](https://docs.kawaii.red/endpoints/image)
{% endcontent-ref %}

> Currently not yet ready. I'm sorry.

{% content-ref url="endpoints/gif" %}
[gif](https://docs.kawaii.red/endpoints/gif)
{% endcontent-ref %}

> Through this endpoint you can query many different anime GIFs.

{% content-ref url="endpoints/stats" %}
[stats](https://docs.kawaii.red/endpoints/stats)
{% endcontent-ref %}

> Here you can query your stats or your complete database entry.
