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.
- GET and POST iterative APIs: page, skip/offset, range, cursor, next-URL and
Linkheader 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-Resetwaits, 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:
initprobes an endpoint and writes a complete project,run full --max-pages Nchecks real pages without touching the archive,--jsongives one machine-readable result per command, and a bundled Agent Skill tells agents to configure apibackuper instead of writing a scraper
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.
pip install --upgrade pip setuptools
pip install apibackuperpipx install apibackuper
# or
uv tool install apibackuperParquet export, WARC export and aria2 downloads:
pip install "apibackuper[recommended]"- Python 3.10 or greater
python -m pip install --upgrade pip setuptools wheel
python -m pip install .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.jsonlA 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.
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.
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 --helpA 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 --resumeResume 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.
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.
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-configwarns when theiterate_bymode has no pagination parameter (params.page_number_paramforpage,params.count_skip_paramforskip,count_from_param/count_to_paramforrange), because such a run saves only the first page. With--strictthe warning fails the check. Set the parameter, or drop--strictfor 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-progresshides them everywhere. - Dry-run plans (
run,update,followwith--dry-run) have a newwarningslist with the configuration warnings, instead of printing them before the JSON. detectsends 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 hasfields,sample_record,records_on_first_pageandwarnings.
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
updatenow writesstorage/storage.zip.runs/<id>.zipinstead of addingruns/<id>/members tostorage.zip. All commands read both layouts. Tools that openstorage.zipdirectly no longer see new update generations; useexportor the storage API. Version 2.x does not readstorage.zip.runs/, so after rolling back, run a new full backup. - Provenance records are written by default. Every saved page gets an
exchange_N.jsonmember, and XML/HTML responses keepraw_N.<ext>. Setstorage.capture.metadata: false(andraw_body: never) for pages-only archives. Each run also writesmanifest-sha256.txtandrun.json, andgetfileswritesfiles-manifest-sha256.txt. Scripts that expect onlypage_N.jsonmembers 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. Setpage_size_limitto 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_fileorclient_secret_filefailsvalidate-configand stops requests, instead of sending them without credentials. - New defaults.
settings.checkpoint_interval_pagesdefaults 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.jsonorfiles_skipped.listinstead of stopping the command. - Deprecated:
ProjectBuilder.getfiles(be_careful=...)is ignored with a warning; usefiles.max_file_size.
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.
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()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).
MIT License — see LICENSE.