Yes, you can do this using python-sdk. Checkout the Github repository for it.
Installation: pip install medium-api
If you want to fetch all the articles written by an user, use the followingcode:
# Import libraries
import os
from medium_api import Medium
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create a `Medium` Object
medium = Medium(api_key)
# Create an "User" Object using 'username'
user = medium.user(username="nishu-jain")
# Fetch user-written articles
user.fetch_articles()
# Iterate over user articles and print their title
for article in user.articles:
print(article.title)
If you want to fetch the publication’s articles, use the followingcode
# Import libraries
import os
from datetime import datetime, timedelta
from medium_api import Medium
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create a `Medium` Object
medium = Medium(api_key)
# Create a "Publication" Object
publication = medium.publication(publication_id="98111c9905da", save_info=False)
# Fetch publication articles published within last week's days
last_weeks_articles = publication.get_articles_between(
_from=datetime.now(),
_to=datetime.now() - timedelta(days=7)
)
for article in last_weeks_articles:
print(article.title, f'({article.published_at})')
If you want to fetch topfeed’s articles, use the followingcode
# Import libraries
import os
from medium_api import Medium
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create a `Medium` Object
medium = Medium(api_key)
# Create a "TopFeeds" Object with mode="new"
topfeeds = medium.topfeeds(tag="relationships", mode="new")
# Fetch all the articles information
topfeeds.fetch_articles()
# Iterate over topfeeds articles and print their title
for article in topfeeds.articles:
print(article.title)
For each article, you can access the information like this:
PS: Under the hood, this python sdk is running a for-loop for each article_id. It uses multi-threading to drastically speed up the process. You can implement the same in any language of your choice (like javascript and others).
If you need any additional assistance, please let me know 😃
sir but i code it in javascript’
Hi there,
Yes, you can do this using python-sdk. Checkout the Github repository for it.
Installation:
pip install medium-api
For each article, you can access the information like this:
PS: Under the hood, this python sdk is running a for-loop for each
article_id
. It uses multi-threading to drastically speed up the process. You can implement the same in any language of your choice (like javascript and others).If you need any additional assistance, please let me know 😃
And feel free to email me at nishu@mediumapi.com
Other Resources
https://mediumapi.com
https://apps.mediumapi.com
https://docs.mediumapi.com
https://github.com/weeping-angel/medium-api
https://github.com/weeping-angel/medium-api-examples
https://medium-api.rtfd.io
https://www.youtube.com/watch?v=oc8TKG9EQfE
https://nishu-jain.medium.com