In today's digital world, understanding audience engagement is key to content success. If you're looking to analyze a Medium user's followers for networking, marketing, or content analysis, this guide will help you achieve that using the Medium API.
By leveraging the Medium API, you can programmatically fetch follower details for any user, enabling data-driven decisions.
To get started, ensure you have the following:
npm install medium-api-js dotenv
Let’s break down the process of fetching a Medium user’s followers step-by-step.
import Medium from 'medium-api-js';
import dotenv from 'dotenv';
dotenv.config();
medium-api-js
: This package acts as a wrapper for the Medium API, simplifying API requests.dotenv
: Allows us to securely manage sensitive credentials (like API keys) through environment variables.const medium = new Medium(process.env.RAPIDAPI_KEY);
process.env.RAPIDAPI_KEY
: Fetches the API key stored in the .env
file, ensuring security.new Medium()
: Initializes the Medium API client with the provided API key.const userId = '14d5c41e0264';
const count = 20;
let after = "";
userId
: The unique identifier of the Medium user whose followers you want to fetch.count
: Specifies the number of followers to retrieve in one request (default here is 20).after
: Used for pagination to fetch the next batch of followers (initially empty).medium.getUserFollowers(userId, count, after)
.then(data => {
console.log('User Followers:', data);
});
getUserFollowers()
: Fetches follower data based on the provided userId
, count
, and after
.then()
: Handles the successful response, logging the follower data to the console.data
: Contains details about the user's followers, such as their IDs and pagination information.Save the script as getUserFollowers.js
. Execute it using the following command:
node getUserFollowers.js
On running the script, you will see the following output:
id
: The user ID of the queried Medium account.followers
: An array containing the unique IDs of the user's followers.count
: Number of followers retrieved in the current request (20 in this case).next
: A token to fetch the next set of followers via pagination.total_followers
: Total number of followers the user has.Networking
: Identify potential collaborators or readers by analyzing followers of influential writers.Data Analytics
: Use follower data for insights into audience growth and trends.Marketing
: Create targeted campaigns by understanding a user's follower demographics.Retrieving a Medium user's followers is an essential step in understanding audience engagement and improving content strategies. By leveraging the Medium API, you can efficiently fetch and analyze follower data for various use cases.
If you have any questions about the Medium API or need further assistance, feel free to reach out to me at nishu@mediumapi.com.
Best of luck with your projects!