0
0
Rest APIprogramming~15 mins

Resource identifiers in URLs in Rest API - Mini Project: Build & Apply

Choose your learning style9 modes available
Resource Identifiers in URLs
📖 Scenario: You are building a simple REST API for a bookstore. Each book has a unique ID. You want to create URLs that identify each book resource clearly and simply.
🎯 Goal: Build a list of book URLs using resource identifiers (book IDs) in the URL path.
📋 What You'll Learn
Create a list of book IDs
Create a base URL string
Use a loop to build full URLs for each book by adding the book ID to the base URL
Print the list of full book URLs
💡 Why This Matters
🌍 Real World
APIs use resource identifiers in URLs to let users and programs find specific items like books, users, or orders easily.
💼 Career
Understanding how to build and use resource URLs is essential for backend developers, API designers, and anyone working with web services.
Progress0 / 4 steps
1
Create the list of book IDs
Create a list called book_ids with these exact values: 101, 102, 103, 104, 105
Rest API
Need a hint?

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

2
Create the base URL string
Create a string variable called base_url and set it to "https://api.bookstore.com/books/"
Rest API
Need a hint?

Use double quotes "" to create the string.

3
Build full URLs for each book
Create an empty list called book_urls. Then use a for loop with variable book_id to iterate over book_ids. Inside the loop, append the full URL string formed by joining base_url and the string version of book_id to book_urls.
Rest API
Need a hint?

Remember to convert the number book_id to a string before joining it with base_url.

4
Print the list of full book URLs
Write a print statement to display the book_urls list.
Rest API
Need a hint?

Use print(book_urls) to show the list.