0
0
Rest APIprogramming~20 mins

Plural vs singular resource names in Rest API - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
REST API Naming Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Choosing resource names for REST API endpoints

Which of the following is the best practice for naming a REST API endpoint that returns a list of users?

A/user
B/users
C/userlist
D/getUsers
Attempts:
2 left
💡 Hint

Think about how REST APIs usually represent collections.

Predict Output
intermediate
2:00remaining
Output of REST API endpoint for singular resource

Given a REST API endpoint /users/123 that returns the user with ID 123, what is the expected resource name in the URL?

A/users/123
B/user/123
C/userses/123
D/userlist/123
Attempts:
2 left
💡 Hint

Remember that the collection is plural, and the ID identifies a single resource inside it.

Predict Output
advanced
2:00remaining
Identify the correct REST API endpoint for creating a new book

Which endpoint should be used to create a new book resource in a REST API?

APOST /book
BGET /books/create
CPOST /books
DPUT /books/new
Attempts:
2 left
💡 Hint

Creating a new resource usually uses POST on the collection endpoint.

🧠 Conceptual
advanced
2:00remaining
Why avoid singular resource names for collections?

Why is it generally discouraged to use singular resource names like /user to represent a collection in REST APIs?

ABecause singular names are harder to type
BBecause singular names are reserved keywords in HTTP
CBecause singular names require special headers
DBecause singular names confuse clients about whether the endpoint returns one or many resources
Attempts:
2 left
💡 Hint

Think about clarity and expectations for API users.

🚀 Application
expert
2:00remaining
Determine the number of items returned by the endpoint

A REST API endpoint /products returns a JSON array of product objects. If the endpoint returns the following JSON:

[{"id":1,"name":"Pen"},{"id":2,"name":"Notebook"},{"id":3,"name":"Eraser"}]

How many product items does this endpoint return?

A3
B2
C1
D4
Attempts:
2 left
💡 Hint

Count the objects inside the JSON array.