How to Get a Medium Article in Markdown Format

(Using Medium API Python Package)

This guide will walk you through the process of using the Medium API to Get an article and display it in Markdown format. The only prerequisite for this task is to have the medium-api package installed. You can install it using pip:

pip install medium-api

Step 1: Import Required Libraries

Start by importing the necessary libraries in your Python script. You will need the os library to access environment variables and the Medium class from the medium_api package to interact with the Medium API.

Step 2: Get the API Key

You need to obtain your Medium API key from your environment variables. This key is essential for authenticating your requests to the Medium API.

Ensure that you have set up the environment variable RAPIDAPI_KEY with your actual API key. If you haven’t set it up yet, you can do so by exporting it in your shell or configuring it in your environment settings.

Step 3: Create a Medium Object

With the API key retrieved , you can now create an instance of the Medium class. This object will be used to interact with the Medium API.

Step 4: Fetch the Article and Print Markdown

Use the Medium object to fetch an article by its ID. Replace "deedea890da1" with the actual ID of the article you want to get. Once you have the article, you can access its content in Markdown format and print it out.

The article.markdown line gets the article's content in Markdown format, which you can then use as needed in your application.

Output

By following these steps, you can easily get and work with Medium articles in Markdown format using the Medium API.