Skip to content

docs(api): document the limit constraints on paginated endpoints - #925

Open
jeherve wants to merge 1 commit into
trakt:masterfrom
jeherve:docs/pagination-limit-constraints
Open

docs(api): document the limit constraints on paginated endpoints#925
jeherve wants to merge 1 commit into
trakt:masterfrom
jeherve:docs/pagination-limit-constraints

Conversation

@jeherve

@jeherve jeherve commented Sep 3, 2026

Copy link
Copy Markdown

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 pageQuerySchema describes limit as just "The number of items per page".

Neither matches the API. Sending no limit and reading X-Pagination-Limit back:

Endpoint X-Pagination-Limit
/users/{id}/history 100
/movies/trending, /movies/popular, /movies/anticipated 100
/shows/trending, /shows/popular 100
/users/{id}/watchlist, /users/{id}/lists 100
/movies/{id}/lists, /shows/{id}/lists 100
/search/{type} 50
/movies/{id}/comments, /shows/{id}/comments 10

The maximum has been 250 since June 15, and a larger value is clamped to it rather than rejected:

requested limit X-Pagination-Limit items returned
250 250 250
500 250 250
1000 250 250

I 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 at limit=10, and imported a tenth of my history.

pageQuerySchema is 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

  • The prose guide on docs.trakt.tv, which does not appear to live in this repo.
  • recommendationsQuerySchema, which has its own separate limit.
  • limitlessQuerySchema, where limit can also be the value all.
  • Validation behaviour. This is a description change only, so nothing that used to be accepted is now rejected. I left .max(250) off on purpose, since ‼️ Upcoming API Changes: Watched Endpoints Pagination & Extended Defaults #775 notes the effective page size can be lower for heavier extended modes, and a hard schema constraint would claim more than I can verify.

Pull Request Checklist

  • Clear and Concise Title
  • Detailed Description
  • Tests: description-only change, no behaviour to test. The generated spec was checked by hand for the new text.
  • Coding Standards
  • Commit Messages: Conventional Commits, docs(api)
  • Documentation: this is the documentation change
  • Code Review

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 kevincador left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pagination: the documented default limit of 10 no longer matches the API

2 participants