Interview Q&A / Node.js

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What are good URL naming conventions for REST resources?

SHORT ANSWER

Use plural nouns for resources, let the HTTP method express the action, nest only one level for relationships, and use lowercase with hyphens. So GET /students/5/courses, not /getStudentCourses?id=5.

Explain it simply

A REST URL names a thing, not an action. The verb comes from the HTTP method. Think of a library: the shelf label says "Books", and what you do (borrow, return, add) is the request you make at the desk.

GoalPoorBetter
List studentsGET /getAllStudentsGET /students
One studentGET /student?id=5GET /students/5
CreatePOST /createStudentPOST /students
UpdatePOST /updateStudent/5PATCH /students/5
DeleteGET /deleteStudent/5DELETE /students/5
A student's coursesGET /studentCourses/5GET /students/5/courses

Example

js
router.get("/students", listStudents);
router.post("/students", createStudent);
router.get("/students/:id", getStudent);
router.patch("/students/:id", updateStudent);
router.delete("/students/:id", deleteStudent);
router.get("/students/:id/courses", listStudentCourses);

Guidelines:

  • Plural nouns: /students, not /student.
  • Lowercase and hyphens: /exam-results, not /ExamResults.
  • Do not nest deeply. /students/5/courses/9/lessons/3 is hard to maintain; after one or two levels use /lessons/3.
  • Filters go in the query string: /students?branch=cse.
  • For real actions that are not CRUD, a sub-resource verb is acceptable: POST /orders/12/cancel.

What to say in the interview

"Resources are plural nouns, the HTTP method is the verb, relationships nest one level, and filters go in the query string. This makes the API predictable without reading the docs."

Common mistakes

  • Putting verbs in URLs and using GET for deletions.
  • Mixing singular and plural names across endpoints.

#rest#api-design#naming

Related questions

Practise more Node.js questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Node.js quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.