Retrieve channel history
Use thehistory() method to retrieve previously published messages:
History parameters
Customize your history query with the following parameters:Query by time range
Get messages in chronological order
Pagination
History results are paginated. Use thehasNext() and next() methods to iterate through pages:
Continuous history with rewind
Use the rewind channel option to get historical messages when attaching to a channel:Rewind by time
You can also rewind by time interval:History with untilAttach
Get continuous history up to the point of channel attachment:Message retention
How long messages are stored depends on your channel rules:
To enable longer retention, configure the “Persist all messages” channel rule.
Presence history
You can also retrieve historical presence events:Best practices
Use history for catch-up only
History is designed for short-term catch-up, not as a primary data store:Limit history queries
Be specific about what you need:Use integrations for long-term storage
For long-term storage and complex queries, use integrations to send data to your own database:- Store messages in your database via webhooks
- Use message queues for processing
- Enable data warehousing for analytics
Next steps
- Learn about message storage options
- Explore rewind channel option
- Set up integrations for long-term storage
- Understand connection recovery
