(Using Medium API Python Package)
If you need to obtain the publication ID for a specific Medium publication, this
guide will walk you through the process using the Medium API. Before you begin,
ensure you have the medium-api
package installed. If not, you can install
it using the command:
pip install medium-api
To start, you need to import the required libraries. You'll be using the os
module to access environment variables and the Medium
class from the medium-api
package.
The Medium API requires an API key to authenticate your requests. In this step, you'll retrieve this key from the environment variables. Make sure that your environment variable RAPIDAPI_KEY
is set with your Medium API key.
Next, you'll create an instance of the Medium
class using the API key you retrieved. This object will allow you to interact with the Medium API.
To get the publication ID, use the publication
method of the Medium
object. You'll need to specify the publication's slug, which is a unique identifier for the publication on Medium. In this example, we use the slug "towards-data-science"
. The publication ID will be printed to the console.
Here's what you should expect as output when you run the script: