Medium’s platform is a treasure trove of insightful content and influential creators. But what if you’re looking to discover users associated with a specific topic? Whether you're conducting research, building a recommendation engine, or simply exploring a niche, knowing how to fetch recommended Medium users by tag can be incredibly useful.
This guide walks you through the process of using the Medium API to get a list of recommended users for a specified tag. We’ll explore the code step by step, review its output, and discuss potential use cases for this functionality.
Before diving into the code, ensure the following prerequisites are met:
.env
file in your project directory to securely store your RapidAPI key.npm install medium-api-js
npm install dotenv
import Medium from 'medium-api-js';
import dotenv from 'dotenv';
dotenv.config();
Medium
: This is the Medium API wrapper that simplifies interactions with Medium’s platform.dotenv
: Used to securely load environment variables from the .env
file.dotenv.config()
: Initializes dotenv
to make the variables in .env
accessible in the script.const medium = new Medium(process.env.RAPIDAPI_KEY);
process.env.RAPIDAPI_KEY
: Retrieves the API key from the environment variables.new Medium()
: Creates an instance of the Medium API wrapper using your API key.medium.getRecommendedUsers('technology').then(data => {
console.log('Recommended Users:', data);
});
getRecommendedUsers('technology')
: Sends a request to the Medium API to fetch recommended users associated with the “technology” tag..then(data => ...)
: Handles the promise returned by the API call and logs the result to the console.Save the script as getRecommendedUsers.js
and run the following command in the terminal:
node getRecommendedUsers.js
When the script runs successfully, it fetches and logs a list of recommended users for the specified tag (“technology”) as JSON:
recommended_users
: An array of user IDs associated with the “technology” tag. These IDs can be used to fetch further details about the users.tag
: The tag used in the request (“technology” in this case).count
: Total number of recommended users returned.Fetching recommended Medium users by tag opens up a world of possibilities for discovering relevant creators and analyzing niche content trends.
This article demonstrates how to leverage the Medium API effectively, empowering you to explore and utilize Medium’s rich ecosystem.
If you have any questions or need assistance with Medium API, feel free to reach out at nishu@mediumapi.com. Happy coding!