When interacting with the Medium API to fetch, analyze, or manage data related to Medium articles, one of the most important elements you'll come across is the Article ID.
But what exactly is an Article ID, and why is it significant?
An Article ID is a unique hash-like identifier assigned to every article on Medium. This ID is embedded within the article’s URL and is used as a reference by Medium’s systems and the Medium API to identify and interact with a specific article.
For example, in the Medium article URL below:
https://medium.com/some-article-562c5821b5f0
The Article ID is 562c5821b5f0
.
The Article ID serves as the key to accessing all article-related data via the Medium API, much like a unique key that opens the door to specific information about an article.
It allows developers to fetch detailed information, perform searches, or gather related assets and metadata for specific articles efficiently.
Without the Article ID, most API endpoints for article-related operations cannot function.
If you are working with Medium article URLs, you can easily extract the Article ID programmatically. Below is a Python function that extracts the Article ID from a given Medium article URL
import re
from urllib.parse import urlparse
def extract_article_id(article_url: str):
regex = r'(https?://[^\s]+)'
urls = re.findall(regex, article_url)
if urls:
urlpath = urlparse(urls[0]).path
if urlpath:
last_location = urlpath.split('/')[-1]
article_id = last_location.split('-')[-1]
if article_id.isalnum():
return article_id
return None
# Example Usage
url = "https://medium.com/some-article-562c5821b5f0"
article_id = extract_article_id(url)
print(f"Extracted Article ID: {article_id}")
Extracted Article ID: 562c5821b5f0
This function ensures that only valid Article IDs are extracted, making it easier to integrate with Medium API endpoints that require the Article ID.
Here is a list of endpoints that return article IDs as part of their response:
Endpoint | Description |
---|---|
GET User's Articles /user/{user_id}/articles | Returns a list of IDs for all articles written by a specific user. |
GET User's Top Articles /user/{user_id}/top_articles | Returns the top articles of a user. |
GET Publication Articles /publication/{publication_id}/articles | Retrieves the latest articles from a specific publication. |
GET Related Articles /article/{article_id}/related | Returns articles related to a specific article. |
GET Recommended Articles /article/{article_id}/recommended | Fetches articles recommended for a specific article. |
GET Recommended Feed /recommended_feed/{tag} | Returns recommended articles for a specific tag. |
GET Top Feeds /topfeeds/{tag}/{mode} | Retrieves trending or top articles based on a specific mode. |
GET Archived Articles /archived_articles/{tag} | Returns a list of archived articles for a specific tag. |
GET Latest Posts /latestposts/{topic_slug} | Fetches the latest posts under a specific topic. |
GET List Articles /list/{list_id}/articles | Returns articles present in a specific Medium List. |
Search Articles /search/articles?query={query} | Searches for articles matching the given query. |
The following endpoints require an Article ID in their path parameters to perform specific operations on the related article:
Endpoint | Description |
---|---|
GET Article Info /article/{article_id} | Fetches detailed information about an article. |
GET Article's Content /article/{article_id}/content | Retrieves the plain-text content of the article. |
GET Article's Markdown /article/{article_id}/markdown | Fetches the article content in Markdown format. |
GET Article's HTML /article/{article_id}/html | Returns the article content in HTML format. |
GET Article's Assets /article/{article_id}/assets | Retrieves the assets used in the article. |
GET Article's Responses /article/{article_id}/responses | Returns responses to the given article. |
GET Article's Fans /article/{article_id}/fans | Retrieves the list of users who clapped on the article. |
GET Related Articles /article/{article_id}/related | Fetches articles related to the given article. |
GET Recommended Articles /article/{article_id}/recommended | Returns articles recommended based on the given article. |
The Article ID is the backbone of article-related operations in the Medium API. It enables efficient retrieval of article details, such as metadata, content, or related assets, and plays a crucial role in managing and analyzing content on Medium.
Whether you’re fetching metadata, analyzing content, or building tools that interact with Medium articles, understanding how to extract and use Article IDs effectively is critical.
The combination of endpoints that return and take Article IDs allows developers to build comprehensive and powerful applications on top of Medium’s platform.