(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.
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!
Start by importing the necessary libraries (os
and medium_api
):
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.
Initialize the Medium object with your API key:
Create a User object by providing the Medium username of the person whose articles you want to fetch:
Finally, iterate over the fetched articles and print their titles:
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.