Use the ably channels history command to retrieve message history for an Ably Pub/Sub channel.
Synopsis
ably channels history <channel-name> [options]Arguments
channel-name Required
The name of the channel to retrieve history for.
Options
--cipher
A decryption key to use for decrypting messages in the history.
--direction
The direction to retrieve messages in. Options are backwards or forwards. Defaults to backwards.
--start
The start of the time range to retrieve messages from. Accepts ISO 8601, Unix milliseconds, or relative time formats.
--end
The end of the time range to retrieve messages from. Accepts ISO 8601, Unix milliseconds, or relative time formats.
--limit
The maximum number of messages to retrieve. Defaults to 50.
--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
Retrieve message history for a channel:
ably channels history my-channelRetrieve history within a time range:
ably channels history my-channel --start "2025-01-01T00:00:00Z" --end "2025-01-02T00:00:00Z"Retrieve a limited number of messages:
ably channels history my-channel --limit 10Retrieve history in forwards direction:
ably channels history my-channel --direction forwardsRetrieve history from the last hour using relative time:
ably channels history my-channel --start 1hRetrieve message history in JSON format:
ably channels history my-channel --jsonRetrieve message history in formatted JSON output:
ably channels history my-channel --pretty-jsonSee also
- Channels — Explore all
ably channelscommands. - CLI reference — Full list of available commands.