> For the complete documentation index, see [llms.txt](https://davins-project.gitbook.io/nodebird-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davins-project.gitbook.io/nodebird-api/reference/api-reference/v2.md). Agents can also search and read this documentation through its [MCP server](https://davins-project.gitbook.io/nodebird-api/~gitbook/mcp).

# v2

nodebird-api version2

{% hint style="success" %}
새로운 버전입니다.
{% endhint %}

## v2 actions

## 토큰 발급하기

<mark style="color:green;">`POST`</mark> `http://localhost:8002/v2/token`

유효 기간이 1분인 토큰을 발급합니다.

도메인이 등록되지 않은 경우, 도메인 등록을 요청합니다.

#### Request Body

| Name                                           | Type   | Description        |
| ---------------------------------------------- | ------ | ------------------ |
| clientSecret<mark style="color:red;">\*</mark> | String | 키도메인 등록시 발급받은 비밀 키 |

{% tabs %}
{% tab title="401: Unauthorized 등록되지 않은 도메인" %}

```json
{
       "code":401,
       "message":"등록되지 않은 도메인입니다. 먼저 도메인을 등록하세요"
}
```

{% endtab %}

{% tab title="200: OK 토큰 발급 성공" %}

<pre class="language-json"><code class="lang-json">{
    "code":200,
<strong>    "message":"토큰이 발급되었습니다",
</strong>    "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTMsIm5pY2siOiJ0ZXN0MTAiLCJpYXQiOjE2OTQ3Mzk4ODUsImV4cCI6MTY5NDc0MTY4NSwiaXNzIjoibm9kZWJpcmQifQ.kWpV7q5fz6b_QV-Uz_Yt-jn9yk3I-RFvRgFBNxJHShc"
}
</code></pre>

{% endtab %}

{% tab title="500: Internal Server Error 서버 에러" %}

```json
{
"code":500,
"message":"서버 에러"
}
```

{% endtab %}
{% endtabs %}

## 토큰 인증하기

<mark style="color:blue;">`GET`</mark> `http://localhost:8002/v2/test`

If token authentication is successful, the details of the token are returned.

{% tabs %}
{% tab title="200: OK 토큰 인증 성공" %}

```json
{
    "id": 13,
    "nick": "test10",
    "iat": 1694741784,
    "exp": 1694743584,
    "iss": "nodebird"
}
```

{% endtab %}

{% tab title="429: Too Many Requests " %}

```json
{
    "code": 429,
    "message": "1분에 열 번만 요청할 수 있습니다."
}
```

{% endtab %}

{% tab title="401: Unauthorized 토큰 인증 실패" %}

```json
{
     "code": 401,
     "message": "유효하지 않은 토큰입니다.",
}
```

{% endtab %}

{% tab title="419 토큰 인증 실패 (유효기간 만료)" %}

```json
{
    "code": 419,
    "message": "토큰이 만료되었습니다."
}
```

{% endtab %}
{% endtabs %}

## Posts

## 나의 모든 게시물 정보를 가져오기

<mark style="color:blue;">`GET`</mark> `http://localhost:8002/v2/posts/my`

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

```json
{
    "code": 200,
    "payload": [
        {
            "id": 10,
            "content": "안녕하세요. test10 입니다.",
            "img": "/img/0011152200391694085170677.jpg",
            "createdAt": "2023-09-07T11:12:52.000Z",
            "updatedAt": "2023-09-07T11:12:52.000Z",
            "UserId": 13
        },
        {
            "id": 11,
            "content": "test 10입니다. 태그 사용 테스트입니다. #test #태그",
            "img": "",
            "createdAt": "2023-09-11T06:58:46.000Z",
            "updatedAt": "2023-09-11T06:58:46.000Z",
            "UserId": 13
        }
    ]
}
```

{% endtab %}

{% tab title="401: Unauthorized 토큰 인증 실패" %}

```json
{
     "code": 401,
     "message": "유효하지 않은 토큰입니다.",
}
```

{% endtab %}

{% tab title="419 토큰 인증 실패 (유효기간 만료)" %}

```json
{
    "code": 419,
    "message": "토큰이 만료되었습니다."
}
```

{% endtab %}

{% tab title="429: Too Many Requests " %}

```json
{
    "code": 429,
    "message": "1분에 열 번만 요청할 수 있습니다."
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버 에러" %}

```json
{
       "code": 500,
       "message": "서버 에러"
}
```

{% endtab %}
{% endtabs %}

## 해당 title 태그를 사용한 게시물들을 가져오기

<mark style="color:blue;">`GET`</mark> `http://localhost:8002/v2/hashtag/:title`

#### Path Parameters

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| title<mark style="color:red;">\*</mark> | String | 검색하고자 하는 단어 |

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

```json
// http://localhost:4000/search/태그
{
    "code": 200,
    "payload": [
        {
            "id": 11,
            "content": "test 10입니다. 태그 사용 테스트입니다. #test #태그",
            "img": "",
            "createdAt": "2023-09-11T06:58:46.000Z",
            "updatedAt": "2023-09-11T06:58:46.000Z",
            "UserId": 13,
            "PostHashtag": {
                "createdAt": "2023-09-11T06:58:46.000Z",
                "updatedAt": "2023-09-11T06:58:46.000Z",
                "HashtagId": 6,
                "PostId": 11
            }
        }
    ]
}
```

{% endtab %}

{% tab title="404: Not Found 검색 결과 없음" %}

```json
{
       "code": 404,
       "message": "검색 결과가 없습니다."
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```json
{
    "code": 500,
    "message": "서버 에러"
}
```

{% endtab %}
{% endtabs %}

## Follower/Following

## 팔로워 목록 가져오기

<mark style="color:blue;">`GET`</mark> `http://localhost:8002/v2/users.follower`

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

```json
{
    "code": 200,
    "followers": [
        {
            "id": 3,
            "email": "test2@test.com",
            "nick": "test22",
            "password": "$2b$12$CBMbGGXWltLO2JZeRuOHWeUr8AyVCKe2XUzjgEQnT1vRXVLz8KHTy",
            "provider": "local",
            "snsId": null,
            "createdAt": "2023-09-04T09:50:53.000Z",
            "updatedAt": "2023-09-05T10:54:13.000Z",
            "deletedAt": null,
            "Follow": {
                "createdAt": "2023-09-14T11:48:49.000Z",
                "updatedAt": "2023-09-14T11:48:49.000Z",
                "followingId": 13,
                "follwerId": 3
            }
        }
    ]
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버 에러" %}

```json
{
    "code": 500,
    "message": "서버 에러"
}
```

{% endtab %}
{% endtabs %}

## 팔로잉 목록 가져오기

<mark style="color:blue;">`GET`</mark> `http://localhost:8002/v2/users/following`

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

```json
{
    "code": 200,
    "followings": [
        {
            "id": 3,
            "email": "test2@test.com",
            "nick": "test22",
            "password": "$2b$12$CBMbGGXWltLO2JZeRuOHWeUr8AyVCKe2XUzjgEQnT1vRXVLz8KHTy",
            "provider": "local",
            "snsId": null,
            "createdAt": "2023-09-04T09:50:53.000Z",
            "updatedAt": "2023-09-05T10:54:13.000Z",
            "deletedAt": null,
            "Follow": {
                "createdAt": "2023-09-14T11:48:33.000Z",
                "updatedAt": "2023-09-14T11:48:33.000Z",
                "followingId": 3,
                "follwerId": 13
            }
        },
        {
            "id": 9,
            "email": "test7@test.com",
            "nick": "test7",
            "password": "$2b$12$mrBauNX3GxzKMn70bddLheVLruxMB1GVlEzJ0J1ebhretKyXAdrIy",
            "provider": "local",
            "snsId": null,
            "createdAt": "2023-09-04T14:29:13.000Z",
            "updatedAt": "2023-09-04T14:29:13.000Z",
            "deletedAt": null,
            "Follow": {
                "createdAt": "2023-09-07T11:12:28.000Z",
                "updatedAt": "2023-09-07T11:12:28.000Z",
                "followingId": 9,
                "follwerId": 13
            }
        }
    ]
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버 에러" %}

```json
{
    "code": 500,
    "message": "서버 에러"
}
```

{% endtab %}
{% endtabs %}
