PubNub icon

PubNub

Interact with PubNub real-time messaging platform

History → Fetch Messages

AI-generated

Summary

Fetches message history from a specified channel

Inputs

  • channel (required) — The name of the channel to fetch history from
  • count — Number of messages to return (max 100)
  • start — Timetoken to start from
  • end — Timetoken to end at
  • includeMeta — Whether to include message metadata
  • includeMessageActions — Whether to include message actions

Output shape

an array of message objects

Returns up to the requested Count (max 100); optional metadata and actions can be included based on the corresponding flags

Examples

Example 1: Get the latest 20 messages from channel "alerts" including metadata

channel = alerts, historyOptions: {count: 20, includeMeta: true}

Example 2: Retrieve messages between two timetokens from channel "support"

channel = support, historyOptions: {start: "1622548800000", end: "1622635200000"}

Example 3: Fetch up to 100 messages with both metadata and actions from channel "logs"

channel = logs, historyOptions: {count: 100, includeMeta: true, includeMessageActions: true}

Discussion