Case study 02 · Python · API integration

An API sync designed to rerun safely.

The demonstration moves records between mocked REST APIs while preserving progress, avoiding duplicates, recovering from temporary failures, and isolating records that cannot be written.

Public demonstration with both APIs mocked in-process. It proves the integration pattern, not compatibility with an undocumented third-party API.

5/5focused tests
9successful first-run upserts
1poison record isolated

// try the browser demo

Incremental sync · mocked APIs

Run it twice

The first run processes a ten-record synthetic batch. The second run uses the saved cursor and becomes a clean no-op.

A poison record is isolated after retries; it does not block the other nine writes.
pulled
upserted
isolated
Ready. Run the first sync, then rerun it to prove the no-op path.
Public demonstration · two mocked REST APIs · no production credentials

// system flow

Read cursorIncremental pullIdempotent upsertRetry temporary errorsAdvance or dead-letter

The failure modes

Quick sync scripts commonly repeat full pulls, duplicate records on rerun, drop rate-limited writes, or let one malformed record block the remaining batch.

Incremental state

An updated_since cursor limits each run to new or changed records. The demonstrated second run pulls zero records after the cursor advances.

Safe writes

Idempotent upserts prevent duplicate creation and refuse to overwrite a newer destination record with stale source data.

Failure isolation

Rate limits and server failures retry with exponential backoff. A record that still fails moves to a dead-letter queue so the rest of the batch completes.

// verified behaviors

10 pulled → 9 upserted + 1 dead-lettered → second run: 0 pulled

The test suite covers full-to-incremental behavior, poison-record isolation, newer-record protection, exhausted retries, and retry recovery. Real delivery still requires official API documentation, authorized credentials, field mappings, and acceptance examples.

What two systems need to agree?

Send both API documents, the update direction, and redacted example payloads.

[email protected]