(Using Medium API Python Package)
In this guide, you'll learn how to use the Medium API to retrieve and list the people a specific user is following. This involves setting up the environment, creating a Medium API client, and fetching user data. Here's a step-by-step breakdown of how to achieve this with Python.
Before you begin, ensure you have the medium-api library installed. You can install it using pip:
pip install medium-api
Start by importing the required libraries. You'll need os to access environment variables and Medium from the medium_api library.
Next, retrieve your API key from the environment variables. This key is essential for authenticating your requests with the Medium API.
With the API key, create an instance of the Medium class. This client will be used to interact with the Medium API.
Create a User object by specifying the username of the person whose followings you want to fetch. Then, call the fetch_following method to retrieve the list of users they are following.
Finally, iterate over the list of users that the specified user is following and print their full names.
This script helps you retrieve and display the list of users a Medium user is following using the Medium API. Make sure you have the medium-api library installed and your API key correctly set up in your environment variables. With these steps, you can easily access and manipulate user data on Medium.