How to Get a Medium User's Articles

(Using Medium API Python Package)

Want to fetch all the articles written by a Medium user programmatically?

You can do so using the medium-api Python library. This guide will walk you through the code.

Prerequisites

Before diving into the code, make sure you have the medium-api library installed. You can install it using pip command:

pip install medium-api

Now let's start!


Step-by-Step Guide

1. Import Required Libraries

Start by importing the necessary libraries (os and medium_api):

2. Get the API Key

I've got my API Key from RapidAPI and stored it in my environment variables. You can do the same and name the variable as "RAPIDAPI_KEY". This key is essential for authenticating your requests.

3. Create a Medium Object

Initialize the Medium object with your API key:

4. Fetch User's Articles

Create a User object by providing the Medium username of the person whose articles you want to fetch:

5. Print Article Titles

Finally, iterate over the fetched articles and print their titles:

Output

The output will list the titles of all articles written by the specified user. You can view an example of the output here:

With just a few lines of code, you can easily Get and display all articles from a Medium user using the medium-api library. Make sure to replace placeholders with actual values and manage your API keys securely.

nishu@mediumapi.com