Fetching responses of a Medium article is a powerful way to analyze audience engagement. Using the Medium API JS package, developers can easily retrieve data about article responses, helping authors and analysts understand their readers' perspectives.
In this guide, you'll learn how to set up and use code that fetches the responses for a specific Medium article, step by step.
Ensure the following are in place:
medium-api-js
Installed: Install the Medium API JS package using:npm install medium-api-js dotenv
(.env)
: Create a .env
file in the root directory of your project and include your RapidAPI key as:RAPIDAPI_KEY=your_medium_api_key
import Medium from 'medium-api-js';
import dotenv from 'dotenv';
dotenv.config();
This function loads the .env file content into the environment variables. It ensures the API key is securely accessed in the code.
const medium = new Medium(process.env.RAPIDAPI_KEY);
Here, the Medium
object is instantiated, enabling API operations by passing your API key stored in process.env.RAPIDAPI_KEY
.
const articleId = '67fa62fc1971';
The articleId
identifies the Medium article for which responses need to be fetched. Replace this with the ID of the article you want to analyze.
medium.getArticleResponses(articleId).then(data => {
console.log('Article Responses:', data);
});
medium.getArticleResponses(articleId)
: This method fetches the responses for the specified article ID..then(data => { ... })
: Handles the API response, logging the fetched data to the console.Execute the script using the following command:
node getArticleResponses.js
The Medium API makes it simple to fetch article responses, offering developers a direct way to analyze audience engagement and feedback.
By using the getArticleResponses
method, you can gather actionable insights to refine your content strategy or enhance user interaction.
Whether you're building analytics tools or moderating responses, this API integration provides the foundation for meaningful insights.
For further support or inquiries, contact nishu@mediumapi.com.
Keep coding and exploring! 🚀