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.
Before diving into the code, ensure you have the following set up:
medium-api-js
package for interfacing with Medium’s API: npm install medium-api-js dotenv
.env
file: RAPIDAPI_KEY=your_rapidapi_key
dotenv
package to load environment variables securely.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.
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.
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.
Save the script as getListInfo.js
and execute it using the following command:
node getListInfo.js
Here’s the output from the script:
Key properties include:
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!