User Operations on the Category

Overview

In this lesson, we'll learn about a few user-related operations on a category:

  • Check if a user follows a specific category
  • Allow a user to follow a specific category
  • Allow a user to unfollow a specific category
  • Get all the categories that a user follows

We’ll use the following endpoints to perform these operations:

  • We’ll use the {base_url}/users/{USER_ID}/categories/{category_name} endpoint to check, follow, and unfollow a category.
  • We’ll use the {base_url}/users/{USER_ID}/categories endpoint to get all categories followed by a user.

Check, follow, and unfollow a category

In this section, we'll go over operations that we perform with the users/{USER_ID}/categories/{category_name} endpoint. This endpoint supports three functionalities which are specified by the type of HTTP method. Here USER_ID is the unique identifier of the authenticated user, which is your ID.

Make a GET request

When we make an HTTPS GET request to this endpoint, it checks if the user associated with USER_ID has followed the category defined by category_name. It doesn’t take body or query parameters, but USER_ID and category_name are required path parameters.

Let's see the functionality of the GET request in the code widget below.

Get hands-on with 1400+ tech skills courses.