Bird
0
0

Which of the following endpoint designs correctly follows the plural vs singular resource naming best practices for retrieving a single book and all books?

hard📝 Application Q15 of 15
Rest API - URL and Resource Design
You are designing an API for a library system. Which of the following endpoint designs correctly follows the plural vs singular resource naming best practices for retrieving a single book and all books?
A<code>GET /book</code> for all books and <code>GET /books/{id}</code> for a single book
B<code>GET /books</code> for all books and <code>GET /book/{id}</code> for a single book
C<code>GET /books/{id}</code> for all books and <code>GET /book</code> for a single book
D<code>GET /book/{id}</code> for all books and <code>GET /books</code> for a single book
Step-by-Step Solution
Solution:
  1. Step 1: Recall naming rules for collections and single items

    Use plural resource names for collections (all books) and singular for single items by ID.
  2. Step 2: Match options to rules

    GET /books correctly retrieves all books (plural). GET /book/{id} correctly retrieves a single book (singular with ID).
  3. Final Answer:

    GET /books for all books and GET /book/{id} for a single book -> Option B
  4. Quick Check:

    Plural for list, singular + ID for single [OK]
Quick Trick: Plural for lists, singular + ID for single items [OK]
Common Mistakes:
  • Swapping singular and plural for list vs single
  • Using singular without ID for list
  • Using plural with ID for single item

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes