How to Get Recommended Feed Articles by Tag

(Using Javascript)

Medium offers a vast repository of articles across diverse topics, making it a go-to platform for readers and writers alike. Suppose you're interested in fetching recommended articles for a specific tag and page using Medium’s API. This article will guide you through a simple script to achieve that.

In this example, you’ll learn how to retrieve the recommended feed of articles tagged under a certain tag. You’ll also understand how the code works step-by-step, making it easy to adapt for your own requirements.

Prerequisites

To follow this guide, ensure you have the following:

Code Explanation

Step 1: Import Required Packages

import Medium from 'medium-api-js';
import dotenv from 'dotenv';

dotenv.config();

Step 2: Initialize the Medium Client

const medium = new Medium(process.env.RAPIDAPI_KEY);

Step 3: Define the Tag and Page Number

const tag = 'technology';
const page = 2;

Step 4: Fetch the Recommended Feed

medium.getRecommendedFeed(tag, page)
    .then(data => {
        console.log('Recommended Feed:', data);
    });

Running the Script

Save the script in a file named getRecommendedFeed.js and run the following command in your terminal:

node getRecommendedFeed.js

Output and Explanation

When you run the script, you’ll see output like this:

Potential Use Cases

Summary

Fetching recommended feed articles from Medium by tag is straightforward using the medium-api-js package. This script can be customized for various applications, from analytics to personalized recommendations.

If you have any questions about Medium’s API or the code, feel free to reach out to nishu@mediumapi.com for assistance.

nishu@mediumapi.com