How to Get Responses or Comments on a Medium List

(Using Medium API Python Package)

In this guide, we will walk you through how to retrieve responses or comments on a Medium list using the Medium API in Python. Follow these steps to get started:

Prerequisite

Before diving into the code, ensure you have installed the medium-api package. You can install it via pip:

pip install medium-api

Step-by-Step Guide

1. Import Libraries

First, you need to import the required libraries. The medium-api package provides the necessary tools to interact with Medium's API, and os is used to access environment variables.

2. Get API Key from Environment

Medium API requires an API key for authentication. Store this key as an environment variable named RAPIDAPI_KEY and retrieve it using os.getenv.

3. Create a Medium Object

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

4. Get the Medium List

Fetch the Medium list using its ID. Replace "38f9e0f9bea6" with the ID of the list you want to access. This returns a MediumList object containing the list details and associated responses.

5. Iterate Over Responses

The MediumList object contains responses or comments. Iterate over these responses and print their content to see the feedback on the list.

Output

To see the output of the script, you can check the following gist: