I am querying in the Wordpress API for all pages of media attachments. I am going page by page.

I have about 5800 pages and when I hit pages 50-53 they return a blank or more of a [] but it is a 200 HTTP Status.

Can this be normal with anything that's paginated? Am I possibly going to be missing data between pages 50-53?

my HTTP GET request for each page:

GET /wp-json/wp/v2/media?page=<page>&amp; per_page=100&amp; key=<test>&amp; orderby=id&amp; order=asc HTTP/1.1
Referer: http://<website>.com/wp-json/wp/v2/media?page=53&per_page=100&key=<key>&orderby=id&order=asc
Connection: keep-alive
  • How are you generating these requests, and what is the response? The REST API always gives a response, even if it's an empty array or an error message. What was the HTTP response code?
    – Tom J Nowell
    Oct 1, 2019 at 18:23
  • 200 response code , it returns an empty array, [] Oct 1, 2019 at 19:23
  • if you reduce the items per page to 20, does it get further along? How are you generating the requests? And what's the value of key?
    – Tom J Nowell
    Oct 1, 2019 at 20:09
  • @TomJNowell key is actually my API key, obstructed for a reason. Yes I updated the page actually. If I change the size of my page, then my pages aren't the same as when they are 100 from my understanding. I had to skip those pages, but I thought pagination would be calculated from my values, seems like pagination is all actually calculated prior to my calls, as in they maybe stored values? Oct 1, 2019 at 21:52
  • pagination isn't stored values, that'd require a table and cached values that don't exist. Instead it's calculated each time. Instead of counting pages though, count the number of items retrieved. Also when you say missing data between 50-53, are you suggesting that you get the data you expected for page 54?
    – Tom J Nowell
    Oct 1, 2019 at 23:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.