In a REST API paginated resources: what would you return when a client request a page exceeding the maximum page number?
I would go with Not Found, since the request's syntax is perfectly fine. See the status code explanations
- I don't think it is 400, because the request is valid, but there are REST APIs which use 400 by out of range errors.
- 404 is valid if we say that we don't have to bind every URL matching the pagination template to the collection resource. By range headers style pagination it won't work, because by there pages share the same URL. By query style pagination it is valid.
- The 200 with empty resource is valid. The requested page does not contain items.
- 204 should be applied with empty message body. You probably want to send back links to the first and last pages of the collection, so this might not the solution you want.
So I think any of 200, 204 and 404 can be a valid solution.
- 416 Requested Range Not Satisfiable - optionally we could use this, which has the exact meaning we want, but it should be applied only with range headers. (note: should != must, English is a hard language :D)