How to Get Tags in Which a User is Interested

(Using Medium API Python Package)

If you want to fetch a list of tags or interests followed by a Medium user, you can accomplish this easily using the Medium API. Below, we provide a step-by-step guide on how to do this with Python.

Prerequisite

Ensure you have the medium-api library installed. You can install it via pip:

pip install medium-api

Step-by-Step Guide

1. Import Libraries

Start by importing the necessary libraries. You will need the os module to access environment variables and the Medium class from the medium_api package.

2. Retrieve API Key

Fetch the API key from your environment variables. This key is essential for authenticating your requests to the Medium API.

3. Create a `Medium` Object

Instantiate the Medium class with your API key. This object will be used to interact with the Medium API.

4. Create a User Object

Use the Medium object to create a User object. Pass the username of the Medium user whose interests you want to retrieve.

5. Print User's Interests

Loop through the interests of the user and print each one. This will display the tags or interests that the user follows.

Output

For the output of this script, refer to the following gist:

By following these steps, you can easily get a list of tags or interests followed by any Medium user. This can be particularly useful for analyzing user preferences or content trends on Medium.