Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
shipshitdev avatar

Incremental Fetch

  • 122 installs
  • 31 repo stars
  • Updated August 2, 2026
  • shipshitdev/library

Implement cursor, timestamp, or change-token sync so clients and agents fetch only deltas instead of full dataset refreshes on every poll or webhook.

About

Implements incremental fetch and sync patterns using cursors, timestamps, or change tokens so APIs and agents retrieve only updated records, cutting bandwidth, latency, and database load compared with full refreshes in SaaS and integration workloads.

  • Cursor-based pagination
  • Delta sync patterns
  • Timestamp watermarking
  • Reduced payload transfer
  • Idempotent replay handling

Incremental Fetch by the numbers

  • 122 all-time installs (skills.sh)
  • +3 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #2,810 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/shipshitdev/library --skill incremental-fetch

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs122
repo stars31
Last updatedAugust 2, 2026
Repositoryshipshitdev/library

What it does

Implement cursor, timestamp, or change-token sync so clients and agents fetch only deltas instead of full dataset refreshes on every poll or webhook.

Files

SKILL.mdMarkdownGitHub ↗

Incremental Fetch

Build data pipelines that never lose progress and never re-fetch existing data.

The Two Watermarks Pattern

Track TWO cursors to support both forward and backward fetching:

WatermarkPurposeAPI Parameter
newest_idFetch new data since last runsince_id
oldest_idBackfill older datauntil_id

A single watermark only fetches forward. Two watermarks enable:

  • Regular runs: fetch NEW data (since newest_id)
  • Backfill runs: fetch OLD data (until oldest_id)
  • No overlap, no gaps

Critical: Data vs Watermark Saving

These are different operations with different timing:

WhatWhen to SaveWhy
Data recordsAfter EACH pageResilience: interrupted on page 47? Keep 46 pages
WatermarksONCE at end of runCorrectness: only commit progress after full success
fetch page 1 → save records → fetch page 2 → save records → ... → update watermarks

Workflow Decision Tree

First run (no watermarks)?
├── YES → Full fetch (no since_id, no until_id)
└── NO → Backfill flag set?
    ├── YES → Backfill mode (until_id = oldest_id)
    └── NO → Update mode (since_id = newest_id)

Implementation Checklist

1. Database: Create ingestion_state table (see patterns.md) 2. Fetch loop: Insert records immediately after each API page 3. Watermark tracking: Track newest/oldest IDs seen in this run 4. Watermark update: Save watermarks ONCE at end of successful run 5. Retry: Exponential backoff with jitter 6. Rate limits: Wait for reset or skip and record for next run

Pagination Types

This pattern works best with ID-based pagination (numeric IDs that can be compared). For other pagination types:

TypeAdaptation
Cursor/tokenStore cursor string instead of ID; can't compare numerically
TimestampUse last_timestamp column; compare as dates
Offset/limitStore page number; resume from last saved page

See references/patterns.md for schemas and code examples.

Gotchas

  • Save watermarks only after full success. If the process crashes mid-run, unsaved watermarks mean the next run re-fetches and deduplicates from scratch — no data loss, but potentially slow. Saving watermarks mid-run causes permanent gaps.
  • Newest ID may not equal the highest numeric ID. Some APIs return IDs that are not monotonically increasing (e.g., snowflake IDs with clock drift). Always compare using the API's own ordering guarantees, not numeric comparison.
  • Backfill mode must not overwrite the `newest_id`. A backfill run extends history backward; it should update only oldest_id. Overwriting newest_id during backfill causes duplicate fetches on the next forward update run.
  • Rate-limit headers vary by API. Twitter uses x-rate-limit-reset; others use Retry-After. Check the specific API's response headers before implementing wait logic.

Related skills

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.