How to Get a Medium User's Following

(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.

Prerequisites

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

pip install medium-api

Step-by-Step Guide

1. Import Necessary Libraries

Start by importing the required libraries. You'll need os to access environment variables and Medium from the medium_api library.

2. Get API Key from Environment

Next, retrieve your API key from the environment variables. This key is essential for authenticating your requests with the Medium API.

3. Create a Medium API Client

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

4. Fetch User's Followings

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.

5. Print the List of Followings

Finally, iterate over the list of users that the specified user is following and print their full names.

Summary

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.

Output