How to Get a Medium User's Followers

(Using Medium API Python Package)

In this guide, we will walk you through the process of retrieving a user's followers using the Medium API with Python. The provided code will help you understand how to connect to Medium's API, fetch follower data, and display it.

Prerequisite

Before you start, ensure you have the medium-api package installed. You can install it using pip:

pip install medium-api

Code Overview

Here's the complete code for fetching and displaying a user's followers from Medium:

1. Import Libraries

This segment imports the necessary libraries. os is used to access environment variables, and Medium is the class provided by the medium-api package for interacting with Medium's API.

2. Retrieve the API Key

Here, we retrieve the API key from the environment variable RAPIDAPI_KEY. This key is essential for authenticating your requests to the Medium API.

3. Create a Medium Object

With the API key, we create an instance of the Medium class. This object will be used to interact with the Medium API.

4. Fetch User's Followers

In this part, we create a User object for a specific username (nishu-jain) and call the fetch_all_followers method to retrieve all followers of the user.

5. Display Followers

Finally, we loop through the list of followers and print each follower's full name.

Output

To see the output of the code, you can refer to the following gist:

This guide demonstrates how to use the Medium API to fetch and display a user's followers using Python. By following these steps, you can easily integrate Medium's follower data into your applications.