Repository navigation
Reading a live site in pages
Written against main after v0.8.9.
A migration pages through a site while editors keep working on it. This page covers how to read a whole collection, what an edit or a deletion during the read does to it, and how to re-pull only what changed since the last run.
- Request page 1 with the page size you want:
GET /posts/<type>?per_page=200. The default is 50; anything above 200 is clamped to 200 rather than refused. - Read
X-WP-TotalandX-WP-TotalPagesfrom the response headers. - Request
page=2,page=3and so on up toX-WP-TotalPages. A page past the last one returns an empty array, not an error.
Every collection is ordered by ID ascending, never by date. IDs never change, so a record edited during the run stays where it was. Date ordering would let an edited record move to another page mid-run and be read twice or skipped. Terms are ordered by term_id; forms, feeds and redirect rules by their own ID.
Pages are counted by offset, not by ID. page=3 means "skip the first 2 x per_page records", so the collection has to hold still below the current page:
- A record created during the run gets a higher ID than every record already read, so it lands at the end and is picked up by the last page or by the next incremental pull.
-
A record removed during the run from below the current page (deleted permanently, or moved out of a
statusfilter) shifts every later record back by one, and one record is skipped. Attachments skip the trash by default, so a deleted attachment is removed at once.
Warning: to catch a record skipped this way, follow a full read with an incremental pull (below), or compare the IDs you read against a second read of the same collection.
The totals are counted when each page is served, so X-WP-TotalPages can change between pages.
GET /posts/<type> takes modified_after, which returns only records whose post_modified_gmt is strictly after the value:
curl -s -H "X-UAMSWP-Migration-Key: $KEY" \
"$SITE/wp-json/uamswp-migration/v1/posts/page?modified_after=2026-11-01T00:00:00Z"-
Accepted forms:
YYYY-MM-DD;YYYY-MM-DD HH:MMorYYYY-MM-DDTHH:MM, with optional seconds and fractional seconds; an optional zone ofZor an offset such as-06:00. A value with no zone is read as GMT. -
Rejected: relative strings (
now,yesterday), a bare year, and impossible dates or times. The response is400rest_invalid_param, withuamswp_migration_api_bad_modified_afterin its details. An empty value means no filter. - Records that were never published are always included. WordPress leaves their GMT modified date zeroed, so the filter cannot place them in time; they come back on every pull rather than being lost.
- Only post routes take it. Terms and forms have no modified date in their tables, so their routes do not offer the parameter; re-read them whole.
Warning: modified_after has not yet been verified against a site being edited during the pull. See known gaps.
-
include=12,34,56returns only those IDs. Ifincludeis present and none of its values is a valid ID, the collection is empty: it never falls back to every record. -
status=publish,draftlimits the statuses. By default every registered status exceptauto-draftis served, including drafts, private posts and the trash. - On attachments only,
file=2024/05/photo.jpg(up to 100 values) finds attachments by their path relative to the uploads folder. A generated size such asphoto-750x629.jpgresolves to its original attachment.includeandfiletogether return the union.
Home | Your first read | Guides | Troubleshooting | Reference | README | Repository
Written against main after v0.8.9. Edit these pages in docs/wiki/ through a pull request; edits made in the wiki are overwritten by the next publish.
Getting started
Guides
Troubleshooting
Reference
Project