docs(api): document the limit constraints on paginated endpoints - #925
docs(api): document the limit constraints on paginated endpoints#925jeherve wants to merge 1 commit into
Conversation
The pagination guide gives every paginated method a default of 10 items per page, and the reference pages inherit neither a default nor a maximum from this schema. Neither matches the API today. Sending no limit returns 100 items on history, trending, popular, anticipated, watchlist and lists, 50 on search, and 10 on comments. The maximum has been 250 since June 15, and a larger limit is clamped to it rather than refused, so a request for 1000 comes back with 250 items and nothing to say the rest was dropped. This schema is shared by endpoints whose defaults disagree, so it cannot name one. Say instead that the default varies, that an explicit value is the safe thing to send, and where the ceiling is. Refs trakt#924
kevincador
left a comment
There was a problem hiding this comment.
Thanks for opening this! The pagination wording definitely needed some clarification.
I’ve proposed slightly different wording, mostly to avoid presenting 10 and 250 as fixed rules since those values can vary depending on the endpoint.
I also went ahead and updated the online pagination docs. They were indeed outdated and a bit misleading about the defaults and limits, so thanks for bringing attention to this.
| limit: z.number().int().nullish().openapi({ | ||
| description: 'The number of items per page', | ||
| description: | ||
| 'The number of items per page. The default varies per endpoint, so send an explicit value rather than relying on it. The maximum is 250; a larger value is clamped to it rather than rejected.', |
There was a problem hiding this comment.
I’d avoid making 250 sound like a fixed maximum, since both the default and maximum can vary by endpoint.
Maybe something like:
The number of items per page. Defaults and maximums vary by endpoint. When pagination parameters are omitted, a low default limit is applied (often 10). When a limit is provided, it is capped at the endpoint maximum (often 250); higher values are clamped rather than rejected.
Fixes #924.
The pagination guide tells readers that every paginated method defaults to 10 items per page, and the reference pages generated from this repo mention no default and no maximum at all, because
pageQuerySchemadescribeslimitas just "The number of items per page".Neither matches the API. Sending no
limitand readingX-Pagination-Limitback:X-Pagination-Limit/users/{id}/history/movies/trending,/movies/popular,/movies/anticipated/shows/trending,/shows/popular/users/{id}/watchlist,/users/{id}/lists/movies/{id}/lists,/shows/{id}/lists/search/{type}/movies/{id}/comments,/shows/{id}/commentsThe maximum has been 250 since June 15, and a larger value is clamped to it rather than rejected:
limitX-Pagination-LimitI hit this in a plugin of mine. It asked for the page count without a
limit, got a count back for 100-item pages, then walked those pages atlimit=10, and imported a tenth of my history.pageQuerySchemais shared by endpoints whose defaults disagree, so this does not name a default. It says that the default varies, that sending an explicit value is the safe thing to do, and where the ceiling is.What this deliberately leaves alone
recommendationsQuerySchema, which has its own separatelimit.limitlessQuerySchema, wherelimitcan also be the valueall..max(250)off on purpose, since ‼️ Upcoming API Changes: Watched Endpoints Pagination & Extended Defaults #775 notes the effective page size can be lower for heavierextendedmodes, and a hard schema constraint would claim more than I can verify.Pull Request Checklist
docs(api)