Agent Wranglers

API-22Recommended

Cap the page size

Set a default page size and a maximum. Clamp or reject anything above the maximum.

How to do it

Document both numbers in the contract, for example 50 by default and 200 at most, as default and maximum on the limit parameter. This also protects the server, as in resource limits.

How to check

Request ?limit=100000. The answer holds at most the maximum, or a 400 problem names the limit.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/lists/page-size-limit">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.