Use the ably rooms messages history command to get historical messages from an Ably Chat room.
Synopsis
ably rooms messages history <room-name> [options]Arguments
room-name Required
The name of the chat room to retrieve history from.
Options
--limit | -l
The maximum number of messages to return. Defaults to 50.
--order
The order in which to return messages. Options are newestFirst or oldestFirst. Defaults to newestFirst.
--show-metadata
Display metadata attached to messages. Defaults to false.
--start
The start of the time range to query. Accepts ISO 8601, Unix timestamp, or relative time formats.
--end
The end of the time range to query. Accepts ISO 8601, Unix timestamp, or relative time formats.
--json
Output results as compact JSON. Mutually exclusive with --pretty-json.
--pretty-json
Output results in formatted JSON. Mutually exclusive with --json.
--verbose | -v
Enable verbose logging. Can be combined with --json or --pretty-json.
Examples
Get recent message history for a room:
ably rooms messages history my-roomGet history with a limit:
ably rooms messages history my-room --limit 10Get history within a time range:
ably rooms messages history my-room --start "2025-01-01T00:00:00Z" --end "2025-01-02T00:00:00Z"Get history in oldest-first order:
ably rooms messages history my-room --order oldestFirstRetrieve history starting from a specific time:
ably rooms messages history my-room --start "2025-01-01T00:00:00Z"Retrieve history from the last hour using relative time:
ably rooms messages history my-room --start 1hRetrieve room message history with metadata displayed:
ably rooms messages history --show-metadata my-roomRetrieve room message history using an API key environment variable:
ABLY_API_KEY="YOUR_API_KEY" ably rooms messages history my-roomRetrieve room message history in JSON format:
ably rooms messages history my-room --jsonRetrieve room message history in formatted JSON:
ably rooms messages history my-room --pretty-jsonSee also
- Rooms — Explore all
ably roomscommands. - CLI reference — Full list of available commands.