Book Image

Python API Development Fundamentals

By : Jack Chan, Ray Chung, Jack Huang
Book Image

Python API Development Fundamentals

By: Jack Chan, Ray Chung, Jack Huang

Overview of this book

Python is a flexible language that can be used for much more than just script development. By knowing the Python RESTful APIs work, you can build a powerful backend for web applications and mobile applications using Python. You'll take your first steps by building a simple API and learning how the frontend web interface can communicate with the backend. You'll also learn how to serialize and deserialize objects using the marshmallow library. Then, you'll learn how to authenticate and authorize users using Flask-JWT. You'll also learn how to enhance your APIs by adding useful features, such as email, image upload, searching, and pagination. You'll wrap up the whole book by deploying your APIs to the cloud. By the end of this book, you'll have the confidence and skill to leverage the power of RESTful APIs and Python to build efficient web applications.
Table of Contents (12 chapters)

9: Building More Features

Activity 16: Getting Cache Data after Updating Recipe Details

Solution

  1. Get all the recipe data back, click on RecipeList and send the request. The result is shown in the following screenshot:
    Figure 9.15: Get the recipe data back and send the request
  2. Log in to your account, click on the Collections tab and select the POST Token request. Then, send the request. The result is shown in the following screenshot:
    Figure 9.16: Select the POST Token request and send it
  3. Modify a recipe record using the PATCH method. First, select the PATCH Recipe request.
  4. Now select the Headers tab and modify Bearer {token}; the token should be the access token.
  5. Select the Body tab and modify num_of_servings to 5, and cook_time to 50:
    { 
        "num_of_servings": 5, 
        "cook_time": 50 
    } 
  6. Send the request. The result is shown in the following screenshot:
    Figure 9.17: Modifying a recipe record using...