Fetching detailed information about a Medium publication can be extremely valuable for content creators, marketers, and data enthusiasts. Whether you're analyzing publication growth, studying its audience demographics, or simply exploring collaboration opportunities, accessing this data programmatically can save time and provide actionable insights.
In this guide, you'll learn how to use the medium-api-js
package to retrieve comprehensive details about a Medium publication, such as its name, tagline, number of followers, social media profiles, and more.
Before diving into the code, ensure the following prerequisites are met:
dotenv
package to manage environment variables for secure handling of your API key.medium-api-js
: The official package for interacting with Medium’s API.dotenv
: For managing environment variables.npm install medium-api-js dotenv
import Medium from 'medium-api-js';
import dotenv from 'dotenv';
dotenv.config();
Medium
: The medium-api-js
package to interact with Medium’s API.dotenv
: Loads environment variables from a .env
file into process.env
.const medium = new Medium(process.env.RAPIDAPI_KEY);
process.env.RAPIDAPI_KEY
: The API key fetched securely from the .env
file.Medium
: Initializes the API client with the provided key.const publicationId = '98111c9905da';
publicationId
: A unique identifier for the Medium publication you wish to query.medium.getPublicationInfo(publicationId)
.then(data => {
console.log('Publication Info:', data);
});
getPublicationInfo
: Fetches details about the publication with the specified ID.console.log
: Logs the fetched publication details.Save the code in a file, for example, getPublicationInfo.js
. Then, run it in the terminal with the following command:
node getPublicationInfo.js
After running the code, you’ll receive detailed information about the publication. Here’s an example output:
Name
: The publication's name, e.g., "Towards AI".Tagline
: A brief description of the publication.Followers
: Number of people following the publication.Tags
: Topics or themes associated with the publication.Social Media
: Links to Twitter, Instagram, and Facebook profiles.Editors
: A list of editor IDs associated with the publication.Retrieving detailed Medium publication information is a straightforward yet powerful way to gain insights into a publication’s audience, themes, and reach. With the medium-api-js
package, developers can seamlessly integrate this functionality into their applications or workflows.
For any questions or assistance with the Medium API, feel free to reach out to me at nishu@mediumapi.com.
Start exploring Medium publications and unlock a wealth of information today!