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
Field | Value | Remarks |
---|---|---|
receiver_id | integer | The ID of the user to receive the message. |
content | string | The text content of the message. |
attachment | file | Optional. 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
Field | Value | Remarks |
---|---|---|
limit | integer | Optional. Number of chat threads to return. |
offset | integer | Optional. 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
Field | Value | Remarks |
---|---|---|
chat_id | integer | The ID of the chat thread to fetch messages from. |
limit | integer | Optional. Number of messages to return. |
offset | integer | Optional. 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
Field | Value | Remarks |
---|---|---|
message_id | integer | The 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
Field | Value | Remarks |
---|---|---|
chat_id | integer | The 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
Field | Value | Remarks |
---|---|---|
chat_id | integer | The ID of the chat thread to search within. |
query | string | The search term or keyword. |
limit | integer | Optional. Number of results to return. |
offset | integer | Optional. 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
, ormessage_id
parameters as applicable. - Use pagination (
limit
andoffset
) where supported to handle large result sets efficiently.