How to Get Root Tags from Medium

Using the Medium API (JavaScript)

Fetching root tags from Medium can help developers, content creators, or businesses organize and categorize content effectively. Tags like "technology," "self-improvement," or "culture" act as thematic identifiers that make articles more discoverable on Medium.

This guide explains how to programmatically retrieve these root tags using the medium-api-js package, a wrapper for the Medium API.

Prerequisites

Before getting started, ensure you have the following:

To install the necessary packages, use the following commands:

npm install medium-api-js dotenv

Step-by-Step Code Explanation

Importing Required Libraries

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

dotenv.config();

Initializing the Medium API Client

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

Fetching Root Tags

medium.getRootTags()
    .then(data => {
        console.log('Root Tags:', data);
    });

Command to Run the Code

To execute the script, save it as getRootTags.js and run the following command in your terminal:

node getRootTags.js

Output Explanation

When the code runs successfully, it fetches the root tags from Medium and logs them to the console. For example:

Potential Use Cases

Summary

By fetching root tags from Medium, you can gain valuable insights into the platform’s organizational structure and enhance your application’s capabilities.

This guide covered how to use the medium-api-js package to retrieve and utilize these tags effectively. If you have any questions or need further assistance, feel free to reach out at nishu@mediumapi.com.

nishu@mediumapi.com