How To Find the Top Readers of a Medium Publication Using Python

Who commented the most on your publication's articles?

Image by the author

In the pre-internet era, every home had subscriptions to some kind of publication. Kids used to read comics, while grown-ups enjoyed magazines - from foodies reading recipes to techies reading about multiport modems.

We all had a place where we found "our thing."

Readers used to send the publishers' mail, criticizing and appreciating the write-ups. They would spread rumors, and most publications had segments dedicated to those readers' inputs (kinda like the older version of commenting).

Those magazines often used to mention their "Top Readers," acknowledging and recognizing their readers' feedback, which had a massive positive outcome because they felt more connected to the publishers. This also proved the publishers could provide what readers wanted.

Today, the same scenario applies to Medium publications. But unfortunately, there is no easy way to identify their "Top Readers" (yet) since the volume of monthly comments and articles is so high.

By identifying the top commenters on your publication and acknowledging their engagement in your newsletter and publication's homepage, you can motivate thousands of others and build a genuine relationship with them.

That's how communities are built. But worry not...

Now Medium publications can do the same!

How To Do It?

Let's say a publication publishes 100 articles per month, and each article gets two comments on average. That's 200 comments in total.

Two hundred comments do not mean they came from 200 unique Medium users. There will be people who commented more than a couple of times, such as those who really like the stuff on your publication and are moved by it.

Your focus should be to identify those people and give them a little recognition. Maybe contact them later and ask what more they would want on your publication.

So, how do you do this? It seems like a lot of manual work.

To simplify this process, I've created a simple tool that anyone can use to find all the top readers within a minute.

Introducing "Top Readers" Utility

"Top Readers" Utility is a single-page tool where you input two things:

In the results, you'll get all the commenters in decreasing order of their comment frequency. When you click on it, you get their exact comment and the corresponding article on which it was made.

Simple, isn't it?

Expanded view of the commenter - See each one of their comment on the corresponding articles

If you want a more in-depth analysis and are not afraid to get your hands dirty, you can do the same programmatically.

How To Do It Programmatically?

Note: I'm gonna use Python to do this, but you can use any language you want. Please see the API Documentation here.

Steps

  1. Install medium-api Python package using pip install medium-api.
  2. Create a new Python file and start coding.
  3. First, import the required libraries

4. Initialize the Medium Object using your API Key. This will give you access to all the high-level functions needed to build this program.

5. Create a publication object using publication_id. If you don't know the publication_id, you can get it from any article published under it. Use the endpoint GET article info to retrieve the publication_id.

6. Under that publication, fetch articles published within the last 30 days.

7. Filter articles that have responses so we can retrieve them later.

8. Retrieve all the comments (responses) from all the filtered articles and save their corresponding authors (or responders). Once it's done, use Counter to get the results according to their frequency.

9. (Optional) You can plot a bar chart: username vs number of comments, using matplotlib.

Matplotlib output

Full Code

References

Thanks for reading and have a nice day!


PS: We post tutorials, videos, code snippets, and insights related to Medium and Unofficial Medium API. So be sure to follow us on