How to Get Medium Publication Information

(Using Medium API Python Package)

If you want to fetch detailed information about a Medium publication using Python, you can use the medium-api library. This guide will walk you through the process of obtaining various attributes of a Medium publication.

Prerequisites

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

pip install medium-api

Steps to Get Medium Publication Information

1. Import the Required Libraries

First, you need to import the necessary libraries. In this case, you will use the os module to access environment variables and the Medium class from the medium-api library.

2. Retrieve Your API Key

The Medium API requires an API key for authentication. Store this key as an environment variable named RAPIDAPI_KEY. The code below retrieves this API key from your environment:

3. Create a Medium Object

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

4. Fetch the Publication Information

To get information about a specific publication, you'll need the publication's ID. Replace "98111c9905da" with the ID of the publication you want to query. Create a Publication object to access its details.

5. Print the Publication Details

Finally, you can print various attributes of the publication, such as its name, tagline, and social media handles.

Output

To see the output of running this code, check the following gist:

Conclusion

With these steps, you can easily retrieve and display information about any Medium publication using the medium-api library in Python. Make sure to replace the publication ID with the one you’re interested in, and you’ll have the publication's details at your fingertips.