How to Get Medium List Info

(Using Medium API Javascript Package)

When working with Medium, developers often need insights into specific lists curated on the platform. A list on Medium can represent a collection of stories grouped by themes, authors, or topics.

This tutorial explains how to use the medium-api-js package to fetch details of a specific Medium list, including its metadata like name, author, claps, and more. By the end, you'll understand how to retrieve this information programmatically and its potential applications.

Prerequisites

Before diving into the code, ensure you have the following set up:

Code Explanation

Step 1: Import Required Packages

import Medium from 'medium-api-js';
import dotenv from 'dotenv';
dotenv.config();

Medium: Imported from medium-api-js, this is the API wrapper for interacting with Medium.

dotenv: Allows you to securely manage environment variables from an .env file.

Step 2: Initialize the Medium Client

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

process.env.RAPIDAPI_KEY: Reads the RapidAPI key stored in the .env file.

Medium(): Initializes the API client with the key for authentication.

Step 3: Fetch List Details

 medium.getListInfo('3d8f744f5370').then(data => {
   console.log('List Info:', data);
});

getListInfo(): A method provided by the medium-api-js package to retrieve details of a Medium list using its ID ('3d8f744f5370').

console.log(): Outputs the fetched list information to the console for inspection.

Running the Code

Save the script as getListInfo.js and execute it using the following command:

node getListInfo.js

Output Explanation

Here’s the output from the script:

Key properties include:

Potential Use Cases

Conclusion

This script demonstrates how to retrieve detailed information about a Medium list using the medium-api-js package. Whether you're a developer, marketer, or content strategist, this approach is invaluable for harnessing Medium's data effectively.

For further assistance, feel free to contact nishu@mediumapi.com. Happy coding!

nishu@mediumapi.com