Resource-based Design Thinking with REST API
📖 Scenario: You are building a simple REST API for a library system. The system manages books as resources. Each book has a unique ID, a title, and an author.We will create the data structure for books, configure a filter for books by author, implement the core logic to select books by that author, and finally output the filtered list.
🎯 Goal: Build a REST API endpoint that returns a list of books filtered by a given author using resource-based design thinking.
📋 What You'll Learn
Create a dictionary called
books with book IDs as keys and dictionaries with title and author as valuesCreate a variable called
filter_author to hold the author name to filter byUse a dictionary comprehension to create
filtered_books containing only books by filter_authorPrint the
filtered_books dictionary as the output💡 Why This Matters
🌍 Real World
Filtering resources by attributes is a common task in REST APIs, such as listing books by author or products by category.
💼 Career
Understanding resource-based design thinking and filtering is essential for backend developers building APIs that serve dynamic data based on client requests.
Progress0 / 4 steps