How to Get Fans (people who clapped) of a Medium Article

(Using Medium API Python Package)

If you're looking to find out who has clapped for your Medium article, you can easily do this using the Medium API and a bit of Python code. Here's a step-by-step guide on how to achieve this.

Prerequisites

Before you start, ensure you have the medium-api library installed. You can do this by running:

pip install medium-api

Code Breakdown

Here's a Python script that demonstrates how to get a list of users who have clapped for a Medium article.

Import Libraries

This part of the code imports the necessary libraries. os is used to access environment variables, and Medium is a class from the medium-api library that allows interaction with Medium’s API.

Get API Key from Environment

Here, we retrieve the Medium API key from an environment variable named RAPIDAPI_KEY. Make sure this key is set in your environment variables before running the script.

Create a Medium Object

We create an instance of the Medium class using the API key we obtained. This object will be used to interact with the Medium API.

Fetch Article Fans

Replace "67fa62fc1971" with the ID of the Medium article you want to analyze. The fetch_fans() method retrieves the list of users who have clapped for the article.

Print Fan Details

Finally, this loop goes through the list of fans and prints their full names and usernames.

Output

By following these steps, you can easily retrieve and display the fans of any Medium article using Python. Just ensure your API key is correctly set and the article ID is accurate. Happy coding!