Overview
TheGetHistory request retrieves message history from a chat with flexible pagination options. You can fetch messages in chronological or reverse-chronological order, or retrieve messages around a specific message ID.
Proto Definition
Request Fields
The chat to retrieve message history from. Can be a user (DM), channel, group, or self (saved messages).
Maximum number of messages to return. Defaults to 50 if not specified.When using
around, the limit is split between messages before and after the specified message ID.Retrieve messages sent after this message ID (exclusive). Returns messages in chronological order (oldest first).Type: Snowflake ID representing a MessageNote: Only one of
since, before, or around can be specified.Retrieve messages sent before this message ID (exclusive). Returns messages in reverse-chronological order (newest first).Type: Snowflake ID representing a MessageNote: Only one of
since, before, or around can be specified.Retrieve messages around this message ID. Returns messages both before and after the specified ID, split according to the limit.Type: Snowflake ID representing a MessageFor example, with
limit=50, you’ll get approximately 25 messages before and 25 messages after the specified message.Note: Only one of since, before, or around can be specified.Response
The response includes not just messages, but also all related data needed to display them:Array of messages matching the query. Each message includes:
chat_ref- The chat referencemessage_id- Unique snowflake IDauthor_id- User ID of the sendermessage- Text contentreply_to- ID of replied-to message (optional)media- Media attachments (optional)entities- Formatting entities (optional)edited_at- Edit timestamp (optional)type- Message type (optional)forward- Forward info (optional)
Array of user objects for all users referenced in the messages (authors, mentioned users, etc.).
Array of community member data for community channels (includes roles, nicknames, etc.).
Array of reactions for the returned messages.
Examples
Get Recent Messages (Default)
Get Messages Before a Specific Message
555555555555555555.
Get Messages After a Specific Message
444444444444444444 (useful for catching up on new messages).
Get Messages Around a Specific Message
666666666666666666 (useful for jumping to a specific message with context).
Pagination Strategies
Initial Load
To load the most recent messages when opening a chat:Loading Older Messages (Scrolling Up)
To load older messages when the user scrolls up:Loading Newer Messages (Catching Up)
To load newer messages when catching up:Jump to Message
To jump to a specific message (e.g., from search results or a link):Notes
- Message IDs are snowflakes, which are chronologically sortable
- The
usersandmembersarrays in the response provide all necessary user data to render the messages - The
reactionsarray includes reaction data for all returned messages - When using
around, the specified message ID is included in the results - The default limit of 50 is a reasonable balance between performance and user experience