0
0
Rest APIprogramming~15 mins

Plural vs singular resource names in Rest API - Hands-On Comparison

Choose your learning style9 modes available
Plural vs Singular Resource Names in REST API
📖 Scenario: You are building a simple REST API for a bookstore. You need to decide how to name your API endpoints correctly using plural and singular resource names.
🎯 Goal: Learn how to create REST API endpoints with proper plural and singular resource names for collections and individual items.
📋 What You'll Learn
Create a list of books as initial data
Create a variable to hold the base API path
Use plural resource name for the collection endpoint
Use singular resource name for the single item endpoint
💡 Why This Matters
🌍 Real World
Naming API endpoints correctly helps developers understand and use your API easily, making your web services clear and consistent.
💼 Career
Understanding REST API resource naming is essential for backend developers, API designers, and full-stack engineers working on web applications.
Progress0 / 4 steps
1
Create the initial data list
Create a list called books with these exact entries: 'The Hobbit', '1984', 'Pride and Prejudice'.
Rest API
Need a hint?

Use square brackets [] to create a list and separate items with commas.

2
Set the base API path
Create a variable called base_api_path and set it to the string "/api/v1".
Rest API
Need a hint?

Use double quotes "" to create the string.

3
Create plural and singular resource endpoints
Create two variables: books_endpoint by joining base_api_path and "/books", and book_endpoint by joining base_api_path and "/book".
Rest API
Need a hint?

Use the plus sign + to join strings.

4
Print the API endpoints
Print the books_endpoint and book_endpoint variables each on a new line.
Rest API
Need a hint?

Use two print() statements, one for each variable.