How to Resume Paginated API Imports Without Missing Records

To resume a scheduled API import without missing records, save a durable checkpoint only after the corresponding data is safely written, and make repeated writes harmless. Then account for records that change during pagination and verify completeness through counts or reconciliation. If the provider supplies no stable way to continue or detect changes, design a deliberate overlap-and-reconcile process rather than treating a saved page number as proof that the import is complete.

A checkpoint is useful only if it marks committed work

A scheduled API import should save progress only after the records represented by that progress marker have been handled safely. If the job stores the next cursor before its database writes finish, a crash can make the next run skip records that were never committed. If it saves the cursor afterward, a crash may replay a page. That is usually the safer failure mode, provided writes can be repeated without creating duplicates.

A checkpoint might be a provider-issued cursor, page token, change token, or a timestamp and stable identifier. It is not just a page number: it must represent a position the source can continue from consistently. Check the provider’s documented behavior, including token lifetime and whether the token identifies a fixed snapshot or a changing result set.

Choose a resume marker that fits the source

A stable cursor or snapshot token is generally the clearest option when the API supports one. It lets a job continue through a defined result set, rather than relying on page offsets that can shift as records are added or removed. Store the token with the import run and the source identity it belongs to; do not assume a token remains valid indefinitely.

If the API offers only timestamps, use a compound position such as the last updated time plus a unique record ID when the source supports that ordering. A timestamp alone can be ambiguous when multiple records share the same time. If records can change while pages are being read, a timestamp-based scan may need an overlap window: reread a bounded period before the last saved point and make destination writes idempotent.

Make replay safe before optimizing for speed

The import should be able to process the same source record more than once without damaging data. Commonly, the destination identifies a row by the provider’s stable record ID and performs an insert-or-update. Validate required fields and types before writing; record rejected items separately with enough context to investigate, rather than silently advancing past them.

For a page of records, use a transaction when the destination database and application design make an all-or-nothing page write appropriate. Otherwise, track item-level completion and ensure the checkpoint cannot move past failed items. Keep the checkpoint and the data writes coordinated: separate, uncoordinated commits create a gap where the job claims progress that the database does not contain.

Changing data makes pagination a consistency problem

Offset pagination can be fragile on a live dataset. If a new record is inserted near the start between requests, later page offsets may shift, causing an item to appear twice or be skipped. Cursor pagination can reduce this problem, but its guarantees depend on how the provider defines the cursor and what changes it includes.

Updates during a run need a deliberate policy. A record updated after its page has passed may not appear again in that run. Use a provider change feed or update token if available; otherwise, schedule a follow-up scan with an overlap window and a source-side ordering that can be repeated. Deletions need separate handling too: absence from one page or one scan is not proof that a destination record should be deleted.

Recover interrupted runs without guessing

Persist the run ID, starting position, current checkpoint, last successful write, and completion state. A retry should resume from the last committed position, not simply restart from the last log message. Treat an expired or rejected cursor as a defined recovery case: restart from a safe boundary or run a reconciliation, rather than silently falling back to a later timestamp.

Use bounded retries for temporary network or provider failures, with a delay that avoids hammering the service. Distinguish those errors from permanent problems such as invalid credentials, malformed data, or a changed API contract. A failed item should remain visible for review, and the job should make clear whether the run is complete, partially complete, or awaiting recovery.

Verify completeness, not just a successful status

A job that exits without an error is not necessarily complete. Track pages requested, records received, accepted, rejected, inserted, updated, and retried. Where the API provides totals or a stable inventory, compare those with destination records for the relevant scope. If totals are not reliable or available, compare stable identifiers or run a periodic reconciliation that looks for missing and changed records.

A useful test interrupts the job after a page is fetched, after some writes succeed, and just before checkpoint persistence. Then run it again and verify that no records disappear or multiply. Also test a record updated mid-run, an expired cursor, a repeated page, and a destination database error. These tests reveal whether recovery is based on durable state or hopeful assumptions.

Before you trust a resumable import

  1. Confirm whether the provider offers a stable cursor, snapshot, change token, or reliable update timestamp.
  2. Persist the checkpoint only after all records in the corresponding page are safely committed.
  3. Make record writes idempotent so replaying a page updates or recognizes the same records rather than creating duplicates.
  4. Define how updates to records during a run are captured, including the overlap window or reconciliation process.
  5. Log run IDs, page or cursor progress, record counts, retries, and errors without exposing sensitive payloads.
  6. Compare source and destination counts or identifiers after interruption and after a full reconciliation.

Questions about this approach

Can I assume an API cursor is a permanent checkpoint?

Not automatically. It is safe only if the provider defines the cursor’s meaning and validity, and your job saves it in step with committed data. If a token expires, define a safe restart or reconciliation path instead of assuming it can be reused.

How do I prevent duplicates when a page is retried?

Use a destination key based on the source’s stable record ID and an insert-or-update operation. A replay should update the same record, not create another one. If records have side effects beyond a database write, such as sending notifications, those actions need their own duplicate protection.

When is checkpointing unnecessary?

A small, bounded import from an immutable source may not need elaborate cursor recovery. A straightforward repeatable full scan can be simpler. Checkpointing and reconciliation matter when imports are long, costly, rate-limited, or read data that changes while the job runs.

For help applying this approach, explore our API Integration & Custom API Development services.

Discuss your project with Full Blown Studio

Tell us what needs to work better and what you have tried. Discuss your project, email bob@fullblown.com, or call (661) 429-0940.