How to Search for Users on Medium

(Using Medium API Python Package)

If you're interested in finding Medium users based on specific criteria, you can easily do so using the Medium API in Python. This guide will walk you through the process step-by-step. The only prerequisite is to install the medium-api library, which you can do with the command:

pip install medium-api

Code Breakdown

Let's go through the Python code that searches for users on Medium and prints their details.

1. Import Libraries

Here, we use the os library to access environment variables and the Medium class from the medium_api library to interact with the Medium platform.

2. Retrieve API Key

Make sure you have set the RAPIDAPI_KEY environment variable with your Medium API key. This key is essential for authenticating your requests to the Medium API.

3. Create a Medium Object

This object will be used to interact with the Medium API for various operations, including searching for users.

4. Search for Users

The query parameter specifies the search term, and save_info is an optional parameter that, if set to True, will save user information. Note that enabling save_info can consume a significant number of API calls.

5. Display User Information

This loop iterates over the list of users returned by the search_users method, displaying each user's full name, username, and bio.

Summary

By following these steps, you can efficiently search for Medium users based on specific criteria and access their information programmatically. Just ensure that you manage your API calls wisely, especially if using the save_info option.