List Messages
Endpoints
List Messages
Retrieve messages from a chat session with pagination support
GET
List Messages
List Messages
Retrieves messages from a chat session with support for pagination, filtering, and sorting. This endpoint is essential for displaying conversation history and implementing real-time chat interfaces.Endpoint
Authentication
Your Nexus API key for authentication
Path Parameters
The session ID to retrieve messages from
Query Parameters
Number of messages to return (1-100)
Sort order for messages
asc- Oldest messages first (chronological)desc- Newest messages first (reverse chronological)
Cursor for pagination. Returns messages after this message ID.
Cursor for pagination. Returns messages before this message ID.
Response Fields
Array of message objects
Example Usage
Pagination Patterns
Forward Pagination
Backward Pagination
Real-time Polling
Message Types
User Messages
Assistant Messages
Tool Messages
System Messages
Error Responses
Best Practices
Efficient Pagination
Efficient Pagination
- Use cursors (
after/before) instead of offset-based pagination - Request only as many messages as needed
- Cache messages client-side to reduce API calls
- Use appropriate page sizes (20-50 messages)
Real-time Updates
Real-time Updates
- Implement exponential backoff for polling
- Track the latest message ID to fetch only new messages
- Handle duplicate messages gracefully
Message Rendering
Message Rendering
- Sanitize message content before displaying
- Handle different message types appropriately
- Show loading states during message fetching
- Implement virtual scrolling for large conversations
Performance
Performance
- Fetch messages in batches
- Implement lazy loading for conversation history
- Use descending order for recent messages
- Minimize API calls with smart caching
Related Endpoints
- Send Message - Send new messages to the session
- Get Session - Get session information
- Create Session - Create a new chat session