spn-client
A hardened Python client for archive.org's availability API and Save Page Now (SPN2) — the pieces that are easy to get wrong when you actually run this against archive.org at any volume:
- Process-wide rate pacing with a circuit breaker. archive.org throttles per IP, not per thread or per endpoint. A naive per-thread backoff (or none at all) looks fine in testing and then silently stops archiving anything the first time it's run concurrently or against a busy queue.
- Both submission modes. Anonymous
GET /save/<url>(capture runs inline, answer comes back as a redirect) and S3-key-authenticatedPOST /save(capture is queued, answer comes back as ajob_idyou poll for). - An explicit outcome vocabulary.
submittedis notarchived. This library only ever reportsarchived: Truealongside a real snapshot URL that came back from archive.org — never as a synonym for "we asked." - Staleness checking, so callers can skip re-archiving a URL that already has a recent-enough snapshot.
Every non-obvious piece of behavior in client.py is a documented response to
a specific, dated, measured incident against the real archive.org API — not
a guess.
Install
pip install spn-client
Usage
import spn_client
result = spn_client.check("https://example.com/some-page")
if result["archived"] is False or result.get("snapshot_stale"):
submission = spn_client.submit(
"https://example.com/some-page",
access_key=ACCESS_KEY, # optional — omit for anonymous, lower-rate submission
secret_key=SECRET_KEY,
)
if submission["job_id"]:
# authenticated path: poll for the real outcome
status = spn_client.check_job_status(
submission["job_id"], access_key=ACCESS_KEY, secret_key=SECRET_KEY
)
Call spn_client.reset_rate_limit_state() once at the start of each
independent run/process if you're running this as a long-lived worker —
the pacing/breaker state is process-wide and intentionally does not reset
itself, so a breaker tripped by one run would otherwise silently degrade
the next.
What this doesn't do
This is the archive.org client only — it has no opinion about:
- What staleness policy is right for your use case (
stale_daysis always a caller-supplied parameter) - How you track which URLs you've already archived (that's a caller-side ledger/cache concern)
- Batch-loop concerns like a progress heartbeat or a wall-clock budget across many submissions — those depend on your own operational needs
License
MIT
Metadata
Release files for spn-client 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spn_client-0.1.0.tar.gz | 26.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spn_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.8 kB
Release files / spn_client-0.1.0.tar.gz
| Download URL | spn_client-0.1.0.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
887728b70dfeca7e78a60450f1f113a503392d7d87368094382c5888ec08fbce
|
|
BLAKE2b-256 checksum How to use checksums |
99f861d93c24c324627faf8b44a4c1ca752144eb7f30056b96c88a90cea5c28b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / spn_client-0.1.0-py3-none-any.whl
| Download URL | spn_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd4e6427ec05f41384d22315d28b2b3bc4ae46028399968b4eb9a26549274dce
|
|
BLAKE2b-256 checksum How to use checksums |
c379eb829821f805c880c16ed2f63db34e12adb41f4386004e24485e8a1142b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|