How to Get Medium Lists Created by a User

Using Medium API JS Package

Fetching data from Medium can provide valuable insights for developers building content-driven applications or analytics tools. A common requirement is retrieving the lists (collections or series of articles) associated with a specific Medium user.

This guide explains how to use the medium-api-js package to fetch these lists by leveraging a user’s unique Medium ID.

By the end of this tutorial, you’ll understand how to set up your environment, write code to fetch Medium lists, and interpret the output.

Let’s dive in!

Prerequisites

Before we start, ensure you have the following set up:

Code Explanation

Let’s break down the code into small, easy-to-understand parts:

1. Importing Required Modules

import Medium from 'medium-api-js';
import dotenv from 'dotenv';

dotenv.config();

2. Initializing the Medium API Instance

const medium = new Medium(process.env.RAPIDAPI_KEY);

3. Specifying the User ID

const userId = '5142451174a3';

4. Fetching Lists Associated with the User

medium.getUserListsById(userId)
    .then(data => console.log('User Lists:', data));

Running the Code

To execute the code, run the following command in your terminal:

node getUserListsById.js

Output Explanation

When the code runs successfully, it fetches and displays the lists associated with the specified user ID. For example:

Potential Use Cases

Summary

By following this guide, you’ve successfully learned how to fetch lists created by a Medium user using their unique ID. This functionality can enhance applications that rely on Medium’s content ecosystem, providing a seamless way to manage and analyze user-generated collections.

If you have any questions about the Medium API or this implementation, feel free to reach out at nishu@mediumapi.com.

Happy coding! 🚀

nishu@mediumapi.com