0
0
Rest APIprogramming~30 mins

Deprecation communication in Rest API - Mini Project: Build & Apply

Choose your learning style9 modes available
Deprecation Communication in REST API
📖 Scenario: You are building a simple REST API for a book store. You want to inform users when an API endpoint is deprecated so they can switch to the new version.
🎯 Goal: Create a REST API endpoint that returns a deprecation warning message in the response headers and body.
📋 What You'll Learn
Create a basic REST API endpoint called /books that returns a list of books.
Add a configuration variable called deprecated to indicate if the endpoint is deprecated.
Use the deprecated variable to add a Warning header and a deprecation message in the JSON response.
Print the JSON response with the deprecation message when the endpoint is called.
💡 Why This Matters
🌍 Real World
APIs often need to inform users when old endpoints will stop working so they can update their code.
💼 Career
Knowing how to communicate deprecation clearly is important for backend developers and API designers.
Progress0 / 4 steps
1
Create the initial data structure
Create a list called books with these exact entries: {"id": 1, "title": "1984"} and {"id": 2, "title": "Brave New World"}.
Rest API
Need a hint?

Use a list with two dictionaries inside, each dictionary has keys id and title.

2
Add a deprecation configuration variable
Create a boolean variable called deprecated and set it to True to indicate the endpoint is deprecated.
Rest API
Need a hint?

Use a simple boolean variable named deprecated.

3
Add deprecation warning in the response
Create a dictionary called response with keys books set to the books list, and message set to 'This endpoint is deprecated. Please use /v2/books.' only if deprecated is True. Otherwise, message should be an empty string.
Rest API
Need a hint?

Use a conditional expression to set the message key based on deprecated.

4
Print the response with deprecation warning
Print the response dictionary.
Rest API
Need a hint?

Use print(response) to show the final output.