Repaso
EspaƱol
Backend & APIsCoreAPI-39

Which endpoint follows REST naming conventions?

Options

  1. POST /createUser
  2. GET /getUserById?id=42
  3. GET /users/42 (Correct option)
  4. GET /user_delete/42

Answer

GET /users/42

Why

REST URLs name RESOURCES (nouns, usually plural), and the HTTP method says the action:

  • GET /users/42 read user 42
  • POST /users create a user
  • PATCH /users/42 update
  • DELETE /users/42 delete

Putting verbs in the URL (/createUser) repeats what the method already says.

Remember

Nouns in the URL, verbs in the HTTP method.

Key terms

Practice this question in Repaso