Skip to main content

apibackuper

A command-line tool to archive and backup REST APIs

Version: 3.1.0

This README describes version 3.1.0. See the changelog for release details, the 3.1 upgrade notes before upgrading from 3.0, and the 3.0 migration notes before upgrading from 2.x.

apibackuper downloads paginated REST APIs into local storage and exports the archive as JSON Lines, gzip, zstd, Parquet or WARC. It is designed for repeatable, long-running backups rather than one-off HTTP requests.

Features

  • GET and POST iterative APIs: page, skip/offset, range, cursor, next-URL and Link header pagination, with checks that fail incomplete collections
  • Full, incremental, and update work modes, with resume from checkpoints
  • ZIP, filesystem, or SQLite storage; each update in ZIP storage gets its own archive
  • Provenance for every page (exchange_N.json: request, status, headers, fetch time, SHA-256) and the original bytes of XML/HTML responses
  • Fixity manifests for every run and downloaded file, checked by apibackuper verify
  • Export to JSON Lines, gzip, Zstandard, Parquet or WARC
  • YAML configuration (INI still loaded, but deprecated)
  • Authentication: Basic, Bearer, API Key, OAuth2 (refresh token or client credentials)
  • Rate limiting, retries with Retry-After/X-RateLimit-Reset waits, response rules for error bodies, concurrency, and SSL controls
  • Follow-up requests for related objects and streamed downloads of associated files
  • Optional Python hooks for custom pipeline steps
  • Built for AI coding agents: init probes an endpoint and writes a complete project, run full --max-pages N checks real pages without touching the archive, --json gives one machine-readable result per command, and a bundled Agent Skill tells agents to configure apibackuper instead of writing a scraper

Documentation

The full documentation site (Docusaurus) lives in docs/ and is published at ruarxive.org/apibackuper.

Section What it covers
Getting started Install, quick start, positioning
Cookbook Task index by goal
CLI reference Every command
Configuration YAML sections and field reference
Examples Working projects and templates
Troubleshooting SSL, pagination, rate limits

Source pages: docs/docs/. Changelog: CHANGELOG.md.

Installation

Using pip

pip install --upgrade pip setuptools
pip install apibackuper

Using pipx or uv

pipx install apibackuper
# or
uv tool install apibackuper

Parquet export, WARC export and aria2 downloads:

pip install "apibackuper[recommended]"

Requirements

  • Python 3.10 or greater

Install from source

python -m pip install --upgrade pip setuptools wheel
python -m pip install .

Quick start

For a first run with a known result, follow the local API walkthrough: it serves five records on your machine, backs up three pages and checks the exported IDs. The server and configuration are in examples/local-demo/.

For an external POST API:

apibackuper create etrust
cd etrust
# save apibackuper.yaml with your API settings (and params.json for POST APIs)
apibackuper validate-config
apibackuper run full --dry-run
apibackuper estimate full
apibackuper run full
apibackuper export etrust.jsonl

A worked POST API example is in the E-Trust walkthrough. Starter YAML files are in examples/templates/. create currently writes a minimal apibackuper.cfg; save your complete configuration as apibackuper.yaml, which takes precedence over that INI file. The API-related create flags are accepted for compatibility but do not populate the configuration. Follow the create reference.

Using with AI coding agents

The skills/apibackuper Agent Skill teaches Claude Code, Codex, Cursor and Kimi Code to configure an apibackuper project instead of writing a custom scraper for each API. In Claude Code:

/plugin marketplace add ruarxive/apibackuper
/plugin install apibackuper@apibackuper-marketplace

For other agents, and for an AGENTS.md rule without skill support, see the AI coding agents guide.

Commands

apibackuper init <dir> --url URL [--method POST --body JSON] [-H "Name: value"] [--auth bearer]
apibackuper create <name>
apibackuper detect [--url URL] [--write-config]
apibackuper estimate full
apibackuper run full [--resume]
apibackuper run continue
apibackuper update [--resume]
apibackuper follow full|continue
apibackuper getfiles
apibackuper export output.jsonl
apibackuper info [--json]
apibackuper verify [--strict] [--json]
apibackuper validate-config [--strict] [--json]
apibackuper schema
apibackuper --json <command>

init probes an endpoint and writes a complete project; run full --max-pages 2 checks two real pages in a temporary archive without touching the project. --json before any command prints one JSON object with the result or an error code; progress bars are hidden when output is not a terminal.

run full --dry-run (alias --profile), update --dry-run, and follow full --dry-run print a JSON plan without making HTTP requests. estimate full contacts the API to measure a sample response.

See HTTP request files for custom headers, query filters and POST bodies, and export filters for the --where/--fields contract. Malformed filters fail instead of silently producing unfiltered output.

getfiles currently reads ZIP backups. Its downloaded files can be stored in ZIP or filesystem storage; see file configuration.

apibackuper --help
apibackuper run --help

Backup safety and recovery

A fresh apibackuper run full writes to a staging path ending in .partial (for example, storage.zip.partial). It replaces the previous complete archive only after every required page has been saved successfully. A failed full backup keeps the previous archive and retains its staging data and checkpoint for recovery:

apibackuper run full --resume

Resume reuses saved pages and starts at the first unresolved page. Checkpoints advance only through pages that have been saved durably. Failed or incomplete backup runs exit with a nonzero status and preserve the last successful backup state, so an update cannot advance its timestamp or change key past missing data.

Each apibackuper update retains its pages under a unique runs/<id>/page_N.json generation. Use apibackuper update --resume to continue an interrupted update within the same generation. Export reads the original pages and every retained generation: it represents the retained archive history, and does not deduplicate objects into a current snapshot. An object returned in several updates can therefore appear several times in the export.

Existing archives with flat page_N.json members remain readable. Legacy checkpoints without next_page are also accepted; resume safely replays their last recorded page.

For ZIP storage, saved pages may also live in a .journal sidecar directory until they are compacted into the archive. Keep storage.zip.partial.journal beside storage.zip.partial, or storage.zip.journal beside storage.zip, along with the checkpoint and state files, until recovery is complete. Resume can finish an interrupted publication from saved data without downloading again.

run continue (alias run incremental) fills pages from the first missing page in the published archive. To recover a staged full backup, use run full --resume. See the recovery guide.

Contributing

See the development docs.

For embedding, see the Python API guide. Before scheduling backups, read backup completeness for source consistency, deletion handling, verification and rotation.

Migration notes

Upgrading to 3.1

Version 3.1 adds commands and options for agent workflows (init, schema, run full --max-pages, global --json and --no-progress). Archives and configurations from 3.0 work unchanged. Check these points in scripts and scheduled jobs:

  • New validation warning. validate-config warns when the iterate_by mode has no pagination parameter (params.page_number_param for page, params.count_skip_param for skip, count_from_param/count_to_param for range), because such a run saves only the first page. With --strict the warning fails the check. Set the parameter, or drop --strict for an endpoint that really returns everything in one response. The old warning "Neither data_key nor total_number_key specified" is gone.
  • Missing configuration. Commands run in a directory without a configuration now fail with "Configuration file not found" instead of "Invalid project configuration". The exit status is still 1.
  • Progress bars. They are drawn only when stderr is a terminal, so cron and CI logs no longer contain them. --no-progress hides them everywhere.
  • Dry-run plans (run, update, follow with --dry-run) have a new warnings list with the configuration warnings, instead of printing them before the JSON.
  • detect sends more requests. Unless the project already sets its pagination parameter, it probes page, offset and page-size parameters with a few extra requests. In Python, ProjectBuilder.detect(probe=False) keeps the single request; its result now also has fields, sample_record, records_on_first_page and warnings.

Upgrading to 3.0

Version 3.0 changes the archive layout and several defaults. Backups made by 2.x remain readable; read these points before upgrading scheduled jobs.

  • ZIP update generations live in their own archives. Each update now writes storage/storage.zip.runs/<id>.zip instead of adding runs/<id>/ members to storage.zip. All commands read both layouts. Tools that open storage.zip directly no longer see new update generations; use export or the storage API. Version 2.x does not read storage.zip.runs/, so after rolling back, run a new full backup.
  • Provenance records are written by default. Every saved page gets an exchange_N.json member, and XML/HTML responses keep raw_N.<ext>. Set storage.capture.metadata: false (and raw_body: never) for pages-only archives. Each run also writes manifest-sha256.txt and run.json, and getfiles writes files-manifest-sha256.txt. Scripts that expect only page_N.json members must ignore these names.
  • Incomplete collections fail instead of "succeeding". A short or empty page before the end implied by total_number_key/pages_number_key (for example, an API that caps the page size) now fails the run, and the previous backup stays published. Set page_size_limit to the size the API returns, or remove an inexact count key. Without count metadata there is no 20,000-page cap any more; a page that repeats the previous one fails the run.
  • Missing credential files are errors. An absent or empty token_file, password_file or client_secret_file fails validate-config and stops requests, instead of sending them without credentials.
  • New defaults. settings.checkpoint_interval_pages defaults to 1 (checkpoint after every page; set 0 for the previous behaviour). Without an explicit list, HTTP 429 and 504 are retried along with 500, 502 and 503.
  • Follow and file downloads continue past missing objects. HTTP 404/410 responses are recorded in details.missing.json or files_skipped.list instead of stopping the command.
  • Deprecated: ProjectBuilder.getfiles(be_careful=...) is ignored with a warning; use files.max_file_size.

Python support

The minimum supported Python version is now 3.10, declared by requires-python in the package metadata. This is a breaking compatibility change for Python 3.8 and 3.9 users; upgrade Python before installing this version. CI covers Python 3.10–3.13 on Ubuntu and macOS.

Storage backends (since v1.0.15)

The legacy FileStorage, ZipFileStorage, and FilesystemStorage API in apibackuper.storage is deprecated. New code should use the unified StorageBackend implementations from apibackuper.storage.backends:

Legacy class Replacement
FileStorage StorageBackend (base class)
ZipFileStorage ZipStorageBackend
FilesystemStorage FilesystemStorageBackend

The legacy concrete classes still work but emit DeprecationWarning on instantiation. Importing alone is silent. Mapping the legacy API to the new backend API:

# Before (deprecated)
from apibackuper.storage import ZipFileStorage

storage = ZipFileStorage("pages.zip", mode="w")
storage.exists("page_1.json")           # -> bool
storage.store("page_1.json", b'{"id": 1}')
storage.close()

# After (preferred)
from apibackuper.storage import ZipStorageBackend

storage = ZipStorageBackend("pages.zip", mode="w")
"page_1.json" in storage.list_objects("page")   # -> bool
storage.save_page("page_1.json", b'{"id": 1}')
storage.close()

YAML configuration

The INI config format is deprecated; YAML is the canonical format. A YAML config supports ${VAR} and ${VAR:-default} placeholders for sensitive credentials (see SECURITY.md).

License

MIT License — see LICENSE.

Metadata

Release files for apibackuper 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apibackuper 3.1.0
File Size Uploaded Provenance Actions
apibackuper-3.1.0.tar.gz 186.6 kB With provenance Details for apibackuper-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for apibackuper 3.1.0
File Interpreter ABI Platform Actions
apibackuper-3.1.0-py3-none-any.whl Python 3 none any Details for apibackuper-3.1.0-py3-none-any.whl

Total release size: 301.1 kB

Release files / apibackuper-3.1.0.tar.gz

Download URL apibackuper-3.1.0.tar.gz
Size 186.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d877c74a0c6359eafe12ccf1366a0b3315d56fb40a52057ecba461a64fc0d3c2
BLAKE2b-256 checksum
How to use checksums
d1830b97aad9be07dd878d6e64e41aab19f25a00c2c9de92d53fb0a60d43d2e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / apibackuper-3.1.0-py3-none-any.whl

Download URL apibackuper-3.1.0-py3-none-any.whl
Size 114.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6aa3e52e2385f513a5cbb080ed17d74e2b60ea6bf5a2e2c1712f1ca73bebb0a
BLAKE2b-256 checksum
How to use checksums
ad84baf5250f2f1ad12631689daa7d11a5974983cb750961bbdf35bdb75eb0d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for apibackuper 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for apibackuper-3.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page