# 채팅메시지 리스트 조회 (오래된 메시지 조회)

* RDBMS에서 가져오는 채팅메시지 리스트 데이터로 최초진입시 조회 후 스크롤을 위로 올려 오래된 메시지를 조회할 때 사용되는 API 이다.&#x20;
* 정렬 순은 최신 순이다.
* 페이지 요청은 2페이지부터 해야 최초 리스트 조회 데이터와 겹치지 않는다.

<mark style="color:purple;">`GET`</mark>   `/chat/api/v1/msg/{chatRoomId}/{page}`&#x20;

PathVariable&#x20;

* chatRoomId : 채팅방 고유번호
* page: 페이지

**Request Headers**

<table><thead><tr><th width="293">Name</th><th>Value</th></tr></thead><tbody><tr><td>Accept</td><td>application/json</td></tr><tr><td>Cookie</td><td>리프레시 토큰</td></tr><tr><td>Access</td><td>액세스 토큰</td></tr></tbody></table>

**Response**

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

```json
{
    "status": 200,
    "code": "SUCCESS REQUEST",
    "data": [
        {
            "chatRoomId": "12",
            "message": "4",
            "msgCrDateMs": "2025-01-03 21:47:14.992752",
            "msgCrDate": "2025-01-03 21:47:00",
            "read": true,
            "chatType": "TEXT",
            "nickName": "하하1"
        },
        {
            "chatRoomId": "12",
            "message": "4",
            "msgCrDateMs": "2025-01-03 21:47:14.902688",
            "msgCrDate": "2025-01-03 21:47:00",
            "read": true,
            "chatType": "TEXT",
            "nickName": "하하1"
        },
        {
            "chatRoomId": "12",
            "message": "3",
            "msgCrDateMs": "2025-01-03 21:47:12.826259",
            "msgCrDate": "2025-01-03 21:47:00",
            "read": true,
            "chatType": "TEXT",
            "nickName": "하하1"
        },
        {
            "chatRoomId": "12",
            "message": "2",
            "msgCrDateMs": "2025-01-03 21:47:11.274543",
            "msgCrDate": "2025-01-03 21:47:00",
            "read": true,
            "chatType": "TEXT",
            "nickName": "하하1"
        },
        {
            "chatRoomId": "12",
            "message": "1",
            "msgCrDateMs": "2025-01-03 21:47:08.774614",
            "msgCrDate": "2025-01-03 21:47:00",
            "read": true,
            "chatType": "TEXT",
            "nickName": "하하1"
        }
    ],
    "timestamp": "2025-01-04 01:44:03"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": 400,
    "message": "채팅방의 채팅메시지 데이터가 존재하지 않습니다.", 
    "code": "ERR-CHAT-API-04",
    "timestamp": "2024-11-16 02:00:18"
}
```

{% endtab %}
{% endtabs %}

**Response(Validation)**

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

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "status": 400,
    "message": "채팅방 고유번호는 정수, 1이상이여야 합니다.", 
    "code": "ERR-CHAT-API-VALI-01",
    "timestamp": "2024-11-16 02:00:18"
}
</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rand-chat.gitbook.io/rand_chat-docs/i-o/i-o-api/undefined-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
