# Wallpapers

## Create a wallpaper

<mark style="color:green;">`POST`</mark> `https://api.lolwallpapers.net/beta/wallpapers`

#### Request Body

| Name    | Type   | Description                                                                                 |
| ------- | ------ | ------------------------------------------------------------------------------------------- |
| image   | string | The image to upload.                                                                        |
| purity  | number | Either "0" (SFW) or "1" (Sketchy).                                                          |
| artists | array  | An array of artists IDs.                                                                    |
| tags    | array  | <p>An array of tags names. (3 tags at least)<br>Maximum tags name length: 20 characters</p> |
| source  | string | A valid URL that leads to the source (where the wallpaper was found).                       |

{% tabs %}
{% tab title="201 Wallpaper successfully created." %}

```
{
    "status": "success",
    "data": {
        "id": "gqOG"
    }
}
```

{% endtab %}

{% tab title="400 Validation failed." %}

```
{
    "status": "fail",
    "data": {
        "image": [
            "This value should not be blank."
        ],
        "purity": [
            "This value should not be blank."
        ],
        "tags": [
            "You must choose at least one children of the parent tag \"Artwork\"."
        ]
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Image**: Must comply to the following criteria:&#x20;

* Landscape orientation/mode.
* A minimum of 1280 width and 720 height.
* JPEG/PNG format only.
* Maximum filesize 20MB.

**Tags:** Must contain at least one child of the parent tag "Artwork" ("Official" or "Fan made") and two other tags minimum.
{% endhint %}

## Get a list of wallpapers

<mark style="color:blue;">`GET`</mark> `https://api.lolwallpapers.net/beta/wallpapers`

#### Query Parameters

| Name      | Type   | Description                                                                                      |
| --------- | ------ | ------------------------------------------------------------------------------------------------ |
| search    | string | Search through all tags name (not strict).                                                       |
| width     | number | Filter by image width.                                                                           |
| height    | number | Filter by image height.                                                                          |
| artists   | array  | Filter by the passed artists IDs.                                                                |
| tags      | array  | Filter by the passed tags names.                                                                 |
| uploaders | array  | Filter by the passed users IDs.                                                                  |
| colors    | array  | Filter by the passed colors (hex. format).                                                       |
| purity    | number | <p>Filter by the passed purity:<br>0 = SFW<br>1 = Sketchy</p>                                    |
| sort      | string | <p>Sort by:<br>- views<br>- downloads<br>- created\_at (default)<br>- updated\_at</p>            |
| order     | string | <p>Order by:<br>- desc (default)<br>- asc</p>                                                    |
| limit     | number | <p>The amount of wallpapers to display per page.<br>Default: 20<br>Minimum: 1<br>Maximum: 50</p> |
| page      | number | <p>The page to display.<br>Default: 1<br>Minimum: 1</p>                                          |

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

```
{
    "status": "success",
    "data": [
        {
            "id": "Mja9",
            "uploader": {
                "id": "Q6lB",
                "display_name": "Administrator"
            },
            "purity": 0,
            "source": null,
            "media": {
                "filesize": 1384162,
                "format": "jpeg",
                "dimensions": {
                    "width": 1680,
                    "height": 1050
                },
                "colors": [
                    "9d8d64",
                    "372111",
                    "5b391b",
                    "d6bb74",
                    "dbdbd5"
                ],
                "thumbnails": {
                    "small": "http://img.lolwallpapers.net/users/Q6lB/wallpapers/Mja9/small.jpeg",
                    "medium": "http://img.lolwallpapers.net/users/Q6lB/wallpapers/Mja9/medium.jpeg",
                    "large": "http://img.lolwallpapers.net/users/Q6lB/wallpapers/Mja9/large.jpeg",
                    "full": "http://img.lolwallpapers.net/users/Q6lB/wallpapers/Mja9/full.jpeg"
                }
            },
            "is_published": true,
            "has_liked": false,
            "created_at": 1596476517,
            "updated_at": 1596476517
        }
    ]
}
```

{% endtab %}

{% tab title="400 Validation failed." %}

```
{    "message": "Ain't no cake like that."}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
For performance reason, the response will not contain the following fields:

* artists
* tags
* stats
  {% endhint %}

## Get a wallpaper

<mark style="color:blue;">`GET`</mark> `https://api.lolwallpapers.net/beta/wallpapers/:id`

#### Path Parameters

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| id   | string | The wallpaper unique ID. |

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

```
```

{% endtab %}
{% endtabs %}

## Edit a wallpaper

<mark style="color:purple;">`PATCH`</mark> `https://api.lolwallpapers.net/beta/wallpapers/:id`

#### Path Parameters

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| id   | string | The wallpaper unique ID. |

#### Request Body

| Name    | Type   | Description                                                                                       |
| ------- | ------ | ------------------------------------------------------------------------------------------------- |
| purity  | string | Either "0" (SFW) or "1" (Sketchy).                                                                |
| artists | array  | An array of artists IDs (or an empty array if you want to unset all artists from this wallpaper). |
| tags    | array  | An array of tags names.                                                                           |
| source  | string | A valid URL that leads to the source (where the wallpaper was found).                             |

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

```
```

{% endtab %}
{% endtabs %}

## Delete a wallpaper by ID

<mark style="color:red;">`DELETE`</mark> `https://api.lolwallpapers.net/beta/wallpapers/:id`

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | string | The wallpaper ID. |

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

```
```

{% endtab %}

{% tab title="403 You're not allowed to delete this wallpaper." %}

```
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The user must be the uploader of the wallpaper to be able to delete it.
{% endhint %}

## Download a wallpaper

<mark style="color:blue;">`GET`</mark> `https://api.lolwallpapers.net/beta/wallpapers/:id/download`

This will downloads the image and use the assigned tags names as filename.

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | string | The wallpaper ID. |

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

```
```

{% endtab %}
{% endtabs %}

## Get similar wallpapers

<mark style="color:blue;">`GET`</mark> `https://api.lolwallpapers.net/beta/wallpapers/:id/similar`

Returns a minimum of 10 similar wallpapers.

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | string | The wallpaper ID. |

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

```
```

{% endtab %}
{% endtabs %}

## Like a wallpaper

<mark style="color:green;">`POST`</mark> `https://api.lolwallpapers.net/beta/wallpapers/:id/download`

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | string | The wallpaper ID. |

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

```
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If the user has already liked the wallpaper, his "like" will be removed.
{% endhint %}
