TTWrite API: Messaging Endpoints

The TTWrite messaging API provides a robust set of endpoints to facilitate seamless communication between users. These endpoints allow developers to implement features like sending messages, retrieving chat histories, searching messages, and managing conversations. With support for multimedia attachments and efficient pagination, the messaging API ensures a smooth user experience for real-time and asynchronous messaging.

Key Features

  • Send Messages: Allows users to send text and multimedia messages to other users.
  • Retrieve Chats and Messages: Fetch chat threads and message histories with pagination support.
  • Manage Conversations: Clear chat histories, delete specific messages, or search messages based on keywords.
  • Scalable Design: Designed to handle large volumes of messages with efficient query support.

Authentication

All messaging endpoints require the user to be authenticated. Ensure that valid session tokens are included in API requests to maintain security and user data integrity.

Use Cases

  • Building a real-time chat interface for TTWrite users.
  • Enabling users to search past conversations for specific keywords.
  • Allowing users to manage their chat histories, including clearing old conversations or deleting unwanted messages.

1. Send Message

Endpoint URL

//ttwrite.4up.eu/mobile_api/send_message

Description

Allows a user to send a message or image to another user.

Parameters

FieldValueRemarks
receiver_idintegerThe ID of the user to receive the message.
contentstringThe text content of the message.
attachmentfileOptional. File (e.g., image) to attach to the message.

Example Usage

httpCopy codePOST //ttwrite.4up.eu/mobile_api/send_message
Content-Type: application/json

{
  "receiver_id": 123,
  "content": "Hello!",
  "attachment": null
}

2. Get Chats

Endpoint URL

//ttwrite.4up.eu/mobile_api/get_chats

Description

Fetches the list of chat threads for the authenticated user.

Parameters

FieldValueRemarks
limitintegerOptional. Number of chat threads to return.
offsetintegerOptional. Pagination starting point.

Example Usage

httpCopy codeGET //ttwrite.4up.eu/mobile_api/get_chats?limit=10&offset=0

3. Get Messages

Endpoint URL

//ttwrite.4up.eu/mobile_api/get_messages

Description

Retrieves the list of messages within a specific chat thread.

Parameters

FieldValueRemarks
chat_idintegerThe ID of the chat thread to fetch messages from.
limitintegerOptional. Number of messages to return.
offsetintegerOptional. Pagination starting point.

Example Usage

httpCopy codeGET //ttwrite.4up.eu/mobile_api/get_messages?chat_id=456&limit=10&offset=0

4. Delete Message

Endpoint URL

//ttwrite.4up.eu/mobile_api/delete_message

Description

Deletes a specific message from a chat thread.

Parameters

FieldValueRemarks
message_idintegerThe ID of the message to delete.

Example Usage

httpCopy codePOST //ttwrite.4up.eu/mobile_api/delete_message
Content-Type: application/json

{
  "message_id": 789
}

5. Clear Chat

Endpoint URL

//ttwrite.4up.eu/mobile_api/clear_chat

Description

Clears the entire chat history for a specific chat thread.

Parameters

FieldValueRemarks
chat_idintegerThe ID of the chat thread to clear.

Example Usage

httpCopy codePOST //ttwrite.4up.eu/mobile_api/clear_chat
Content-Type: application/json

{
  "chat_id": 456
}

6. Search Messages

Endpoint URL

//ttwrite.4up.eu/mobile_api/search_messages

Description

Searches for messages in a chat thread based on a query.

Parameters

FieldValueRemarks
chat_idintegerThe ID of the chat thread to search within.
querystringThe search term or keyword.
limitintegerOptional. Number of results to return.
offsetintegerOptional. Pagination starting point.

Example Usage

httpCopy codeGET //ttwrite.4up.eu/mobile_api/search_messages?chat_id=456&query=hello&limit=10&offset=0

Notes for All Endpoints

  • All endpoints require user authentication.
  • Ensure valid receiver_id, chat_id, or message_id parameters as applicable.
  • Use pagination (limit and offset) where supported to handle large result sets efficiently.