(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.
Before you start, ensure you have the medium-api
package installed. You can install it using pip:
pip install medium-api
Here's the complete code for fetching and displaying a user's followers from Medium:
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.
Here, we retrieve the API key from the environment variable RAPIDAPI_KEY
. This key is essential for authenticating your requests to the Medium API.
With the API key, we create an instance of the Medium
class. This object will be used to interact with the Medium API.
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.
Finally, we loop through the list of followers and print each follower's full name.
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.