Retrieve Messages

Retrieving chat messages using the Nara API is simple and straightforward. This guide will take you through the necessary steps to do so. ##

Prerequisites

Before proceeding, ensure you have the following:

  • An API key provided by Nara. If you don't have one, please send a request to [email protected] to obtain it.

Retrieving Chat Messages

To retrieve chat messages, you can use the /api/v1.0/chat/messages endpoint. This endpoint allows you to fetch chat messages of a specific user.

Here is an example of how to use it:

curl --location 'https://nara-backend-50wz.zeet-nara.zeet.app/api/v1.0/chat/messages?user_id=:eq:1254321&rows_per_page=20&current_page=1&sort_by=created_at%3Adesc' \
--header 'Authorization: Bearer YOUR_API_KEY'

In this request:

  • user_id (integer): This is the ID of the user whose messages you want to retrieve. Replace :eq:1254321 with the actual user ID.
  • rows_per_page (integer): This is the number of messages you want to retrieve per page. In this case, it is set to 20.
  • current_page (integer): This represents the page number of the messages you want to retrieve. In this case, it is set to 1.
  • sort_by (string): This allows you to sort the retrieved messages. Here, created_at:desc sorts the messages by their creation time in descending order.

The response will contain the most recent 20 messages of the specified user.

Handling Pagination

If a user has more messages than your rows_per_page setting, the messages will be paginated. You can retrieve the next set of messages by incrementing the current_page value. For example, to get the next 20 messages, you would set current_page=2.

Getting Help

If you encounter any issues or have any questions while using the Nara API, feel free to contact us at [email protected]. Our team is always ready to assist you!