{"success":true,"name":"cap-list-endpoints-so-nobody-can-download-your-whole-databas","description":"Building list, search, or export APIs that return many records","category":"ai-brimind","path":"ai-brimind/cap-list-endpoints-so-nobody-can-download-your-whole-databas/SKILL.md","file":"SKILL.md","content":"---\nname: cap-list-endpoints-so-nobody-can-download-your-whole-databas\ndescription: \"Building list, search, or export APIs that return many records\"\n---\n\n# Cap List Endpoints So Nobody Can Download Your Whole Database\n\n## When to use\nYou are writing an endpoint that returns collections (products, users, messages) and the client can influence how many records come back.\n\n## Example request\nA limit parameter accepted with no maximum → ?limit=1000000 dumps the whole table in one call; the server must clamp page sizes (bounded pagination). Sequential numeric IDs plus a public detail endpoint → a simple loop walks every record in order; scraping becomes trivial and needs rate limits or non-guessable IDs (enumeration scraping). Search returns full records with every field → emails and internals leak inside 'harmless' lists; lists should return a minimal, chosen field set (response shaping). An export feature with no auth check or throttle → one link shares the entire customer list; exports need permissions, limits, and logging (guarded exports).\n\n## Instructions\nAct like a developer who knows that to an attacker, a list endpoint is a download button for your database — the only question is how many requests it takes. For every collection endpoint, enforce server-side bounds: a default page size, a hard maximum the client cannot exceed, and clamping of any client-sent limit. Shape the response deliberately: return only the fields the screen needs, never whole records with internal or sensitive columns riding along. Consider how easily the collection can be walked: predictable numeric IDs plus open detail routes invite full enumeration, so combine rate limiting with authorization on each record, and prefer non-guessable public identifiers where exposure matters. Treat search and export as the same risk with bigger payloads: exports require explicit permission checks, sane size limits, and a log entry of who exported what. Test yourself with a loop: write ten lines of script against your own API and measure how much data an anonymous or basic user can pull per minute — if the answer is 'everything, quickly', the endpoint is not finished. Only ship once volume, fields, and access are each bounded on purpose, and explain how the caps make mass scraping expensive instead of free.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #573\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}