Identifying design problems in the original endpoints and presenting corrected versions following REST best practices.
/getUsers mixes a verb with a noun; the correct form is /users — clean, predictable, and consistent with REST conventions.
?page=1&limit=20&sort=name to avoid returning unbounded result sets.
/users (plural) consistently across all endpoints for the same resource. Mixing /user and /users creates confusion.
/users already implies creation. The verb is entirely redundant.
name=Jo suggests no server-side validation minimum length, no required fields like email, and no structured payload. The request body should carry a full, validated JSON object.
/updateAllUsers should simply be /users — the PATCH method signals a partial update.
PATCH /users with a body array, and enforce authorization checks per record.
/users/{id}. Omitting it makes the scope of the operation dangerously ambiguous.
URLs identify resources. HTTP methods (GET, POST, PUT, PATCH, DELETE) express the action. Never embed verbs like "get", "create", "delete", or "update" in your paths.
Use plural nouns consistently for collections. This keeps the API predictable — /users always refers to the user collection, and /users/5 to a specific user.
Each method has a defined semantic. Respect them: GET (safe, idempotent read), POST (create), PUT (full replace), PATCH (partial update), DELETE (remove).
Return the most specific status code: 201 for creation, 204 for successful deletion, 400 for validation errors, 404 for missing resources, 409 for conflicts.
Query strings appear in logs, browser history, and Referer headers. Sensitive data (passwords, tokens, PII) must always travel in the request body over HTTPS.
Version your API from day one to avoid breaking changes. Always paginate collection endpoints — returning unbounded datasets is a reliability and performance risk.