# MGs - M4M API

## Signup

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/signup`

Signup process.

#### Request Body

| Name      | Type    | Description               |
| --------- | ------- | ------------------------- |
| kakao     | boolean | kakao user classification |
| nickname  | string  | nickname                  |
| email     | string  | email                     |
| password  | string  | password                  |
| birthYear | number  | birthYear                 |

{% tabs %}
{% tab title="201 Account created." %}

```
{ "message": "Thank you signing up!" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="403 The person is already a user." %}

```
{ "message": "You're already a user" }
```

{% endtab %}

{% tab title="409 Conflicting user info exists." %}

```
{ "message": "conflict: nickname" }
{ "message": "conflict: email" }
{ "message": "conflict: nickname & email" }
```

{% endtab %}

{% tab title="422 All the parameters need to be filled in." %}

```
{ "message": "Insufficient parameters supplied" }
```

{% endtab %}
{% endtabs %}

## Email Verification

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/auth`

Email verification for sign-up.

#### Request Body

| Name  | Type   | Description        |
| ----- | ------ | ------------------ |
| email | string | user email address |

{% tabs %}
{% tab title="200 Verification email has been sent." %}

```
{ 6-digit authentification number }
```

{% endtab %}

{% tab title="409 Duplicate email exists." %}

```
{ "message": "conflict: email" }
```

{% endtab %}
{% endtabs %}

## Login

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/login`

User login.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| email    | string | email       |
| password | string | password    |

{% tabs %}
{% tab title="200 Logged in successfully." %}

```
{
    accessToken,
    refreshToken,
    "message": "Logged in successfully"
}
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="403 The user is already logged in." %}

```
{  "message": "You're already logged in"}
```

{% endtab %}

{% tab title="404 Invalid user." %}

```
{ "message": "Invalid user" }
```

{% endtab %}

{% tab title="417 All the required fields need to be filled." %}

```
{ "message": "Please fill in all the required fields" }
```

{% endtab %}
{% endtabs %}

## Logout

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/logout`

Logout process.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

{% tabs %}
{% tab title="205 Logged out successfully." %}

```
{ "message": "Logged out successfully" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided" %}

```
{ "message": "You're not logged in" }
```

{% endtab %}
{% endtabs %}

## Get User Info

<mark style="color:blue;">`GET`</mark> `https://music4millennials.info/user-info`

Getting user's information.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

{% tabs %}
{% tab title="200 Successfully received user's information." %}

```
{ 
    "data": {
        "id": 1,
        "nickname": "mgs",
        "email": "mgs@gmail.com",
        "birthYear": 1990
    },
    "message": "ok"
}
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided" %}

```
{ "message": "You're not logged in" }
```

{% endtab %}
{% endtabs %}

## Edit User Info

<mark style="color:purple;">`PATCH`</mark> `https://music4millennials.info/user-info`

Edit user's information.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name      | Type   | Description     |
| --------- | ------ | --------------- |
| nickname  | string | user nickname   |
| password  | string | user password   |
| birthYear | number | user birth year |

{% tabs %}
{% tab title="200 The user's information was successfully edited." %}

```
{ "message": "Information updated" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401  Access token not provided." %}

```
{ "message": "You're not logged in." }
```

{% endtab %}
{% endtabs %}

## Withdrawal

<mark style="color:red;">`DELETE`</mark> `https://music4millennials.info/withdrawal`

User withdrawal.

#### Headers

| Name          | Type   | Description        |
| ------------- | ------ | ------------------ |
| Authorization | string | Authorization code |

{% tabs %}
{% tab title="200 Withdrawn successfully." %}

```
{ "message": "Successfully withdrawn" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided." %}

```
{ "message": "You're not logged in." }
```

{% endtab %}
{% endtabs %}

## Get My Like List

<mark style="color:blue;">`GET`</mark> `https://music4millennials.info/my-like`

Getting my like list (list of songs that the user hit the like button).

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

{% tabs %}
{% tab title="200 Got the list successfully." %}

```
{
    "data": [{
        "id": 1,
        "title": "희망사항",
        "artist": "변진섭",
        "album_art": "https://cdnimg.melon.co.kr/cm/album/images/000/03/928/3928_500.jpg/melon/resize/282/quality/80/optimize",
        "date": "1989.10",
        "hashtagLike": {
            "좋아요": 1,   
            "#인생곡인": 1,
            "#가사가재밌는": 2
        }
    }],
    "message": "ok"
}
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401  Access token not provided." %}

```
{ "message": "You're not logged in." }
```

{% endtab %}

{% tab title="404 There are no songs are in the list." %}

```
{ "message": "No songs are added to the list" }
```

{% endtab %}
{% endtabs %}

## Delete My Like

<mark style="color:red;">`DELETE`</mark> `https://music4millennials.info/my-like`

Delete songs in my like list.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| songId | number | song id     |

{% tabs %}
{% tab title="200 Successfully deleted." %}

```
{ "message": "ok" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided." %}

```
{ "message": "You're not logged in." }
```

{% endtab %}
{% endtabs %}

## Mainpage

<mark style="color:blue;">`GET`</mark> `https://music4millennials.info/mainpage`

Getting the list of all songs.

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | string | Authorization |

{% tabs %}
{% tab title="200 Successfully got the song list." %}

```
{
    "data": [{
        "id": 1,
        "title": "희망사항",
        "artist": "변진섭",
        "genre": "발라드",
        "album_art": "https://cdnimg.melon.co.kr/cm/album/images/000/03/928/3928_500.jpg/melon/resize/282/quality/80/optimize",
        "date": "1989.10",
        "year": 1990,
        "hashtagLike": {
            "좋아요": 3,
            "#인생곡인": 1,
            "#가사가재밌는": 2,     
        }
    }],
    "message": "ok"
}
```

{% endtab %}

{% tab title="400 " %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="404 No songs are on the list." %}

```
{ "message": "No songs are on the list" }
```

{% endtab %}
{% endtabs %}

## Get Song Info

<mark style="color:blue;">`GET`</mark> `https://music4millennials.info/song?query=`

Get song information.

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| songId | number | song id     |

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

{% tabs %}
{% tab title="200 Successfully got the song information." %}

```
{
    "data": [{
        "id": 1,
        "title": "희망사항",
        "artist": "변진섭",
        "genre": "발라드",
        "album:: "너에게로 또 다시",
        "album_art": "https://cdnimg.melon.co.kr/cm/album/images/000/03/928/3928_500.jpg/melon/resize/282/quality/80/optimize",
        "date": "1989.10",
        "year": 1990,
        "lyrics": "...",
        "hashtagLike": {
            "좋아요": 10,
            "#인생곡인": 1,
            "#가사가재밌는": 2
        },
        "comments": [[
            "mgs#1",
            "인생곡입니다!",
            "2021-09-02 17:48:15"
        ], [
            "m4m#2",
            "청바지가 잘 어울려요",
            "2021-09-02 17:48:15"
        ]]
    }],
    "message": "ok"
}E
```

{% endtab %}

{% tab title="400 Error." %}

```

{ "message": "error" }
```

{% endtab %}

{% tab title="404 No results." %}

```
{ "message": "No songs are found" }
```

{% endtab %}
{% endtabs %}

## Hit Hashtag / Like

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/hashtag-like`

Hit the hashtag.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name   | Type   | Description     |
| ------ | ------ | --------------- |
| name   | number | name of the tag |
| songId | number | song id         |

{% tabs %}
{% tab title="200 Successfully hit the hashtag." %}

```
{ "message": "ok" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided." %}

```
{ "message": "You're not logged in" }
```

{% endtab %}

{% tab title="403 The user already hit three hashtags." %}

```
{ "message": "You cannot choose over 3 hashtags" }
```

{% endtab %}

{% tab title="409 Conflict occurred." %}

```
{ "message": "already hit the hashtag" }
```

{% endtab %}
{% endtabs %}

## Delete Hashtag / Like

<mark style="color:red;">`DELETE`</mark> `https://music4millennials.info/hashtag-like`

Remove the hashtag.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name   | Type   | Description     |
| ------ | ------ | --------------- |
| name   | string | name of the tag |
| songId | number | song id         |

{% tabs %}
{% tab title="200 Hashtag successfully removed." %}

```
{ "message": "ok" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided" %}

```
{ "message": "You're not logged in" }
```

{% endtab %}

{% tab title="409 Conflict occurred." %}

```
{ "message": "already deleted hashtag" }
```

{% endtab %}
{% endtabs %}

## Post Comment

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/comment`

Write a comment.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name    | Type   | Description     |
| ------- | ------ | --------------- |
| content | string | comment content |
| songId  | number | song id         |

{% tabs %}
{% tab title="201 Comment created." %}

```
{ "message": "ok" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided." %}

```
{ "message": "You're not logged in" }
```

{% endtab %}

{% tab title="403 The user already wrote 50 comments." %}

```
{ "message": "already reached the limit" }
```

{% endtab %}

{% tab title="409 When the user tries to post duplicate comments." %}

```
{ "message": "You cannot write the same comment" }
```

{% endtab %}
{% endtabs %}

## Delete Comment

<mark style="color:red;">`DELETE`</mark> `https://music4millennials.info/comment`

Delete the comment.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name    | Type   | Description        |
| ------- | ------ | ------------------ |
| content | string | content of comment |
| songId  | number | song id            |

{% tabs %}
{% tab title="200 Comment deleted." %}

```
{ "message": "ok" }
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}

{% tab title="401 Access token not provided." %}

```
{ "message": "You're not logged in" }
```

{% endtab %}

{% tab title="409 Conflict occurred." %}

```
{ "message": "already deleted" }
```

{% endtab %}
{% endtabs %}

## Song Recommendation

<mark style="color:green;">`POST`</mark> `https://music4millennials.info/recommendation`

Recommend songs for the user.

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| Type | string | User type   |

{% tabs %}
{% tab title="200 Song recommendation." %}

```
{
  "data": [
    "244,가시나무 by 조성모(2000)",
    "347,그땐 미처 알지 못했지 by 이적(2003)",
    "473,사랑의 인사 by 씨야(2007)"
  ],
  "message": "ok"
}
```

{% endtab %}

{% tab title="400 Error." %}

```
{ "message": "error" }
```

{% endtab %}
{% endtabs %}
