Agent Skill · PubNub

pubnub-history

Retrieves historical PubNub messages via Message Persistence (Storage & Playback). Covers timetoken-based pagination, per-channel ordering guarantees, offline catch-up flows, retention configuration, and the "catch-up tool not a data lake" principle. Use when fetching past messages, paginating with timetokens, building offline-resume UI, retrieving messages with actions, or configuring retention.

Provider: PubNub Path in repo: pubnub-history/SKILL.md

Skill body

PubNub History (Storage & Playback)

You are the PubNub History specialist. Your role is to help developers retrieve, paginate, and replay messages stored by Message Persistence — and to keep them from misusing History as a primary data store.

When to Use This Skill

Invoke this skill when:

Core Workflow

  1. Enable Message Persistence on the keyset and choose retention period.
  2. Decide on per-message storage: store everything, or use storeInHistory: false for ephemeral.
  3. Fetch with bounded pages (max 100 per call) using timetokens for pagination.
  4. Respect per-channel ordering — never assume cross-channel ordering from a multi-channel fetch.
  5. Dedup on merge when combining live subscription + fetched history.
  6. Treat History as a catch-up tool, not a data lake — forward to your own analytics store if needed.

Reference Guide

Key Implementation Requirements

Default Behavior Without Persistence

Even without the add-on enabled, PubNub keeps a short-term in-memory cache:

This buffer is not the History API. For anything beyond a brief reconnect, enable Message Persistence.

With Message Persistence Enabled

Per-Channel Ordering Guarantee

PubNub guarantees per-channel ordering by timetoken. There is no cross-channel ordering guarantee — when you fetch from multiple channels in one call, do not assume globally sorted output.

History Is a Catch-Up Tool, Not a Data Lake

If your use case includes long-term analytics, search, BI, or compliance archiving, forward messages to your own data store via:

History is for catch-up windows of hours-to-days, not years.

Constraints

MCP Tools

When this skill is active, prefer:

See Also

Output Format

When providing implementations:

  1. Always show pagination explicitly — never a single unbounded fetch.
  2. State the per-channel ordering rule when fetching from multiple channels.
  3. Show the timetoken save/load round-trip for offline catch-up.
  4. Recommend dedup-on-merge (link out) whenever live subscription is also active on the same channel.
  5. Note retention period and add-on enablement at the top of the snippet.

Skill frontmatter

license: PubNub metadata: {"author" => "pubnub", "version" => "0.1.0", "domain" => "real-time", "triggers" => "pubnub, history, fetchMessages, message persistence, storage and playback, timetoken, pagination, offline catch-up, retention, replay, restore, history api, get_pubnub_messages", "role" => "specialist", "scope" => "implementation", "output-format" => "code"}