Medium

FREEMIUM
Verified
От Nishu Jain | Обновлено il y a 4 jours | Data
Популярность

9.7 / 10

Задержка

1,185ms

Уровень обслуживания

100%

Health Check

N/A

Подписчики: 15
Ресурсы:
Сайт продукта Условия использования
Создатель API:
Rapid account: Nishu Jain
Nishu Jain
nishujain199719-vgIfuFHZxVZ
Войдите, чтобы оценить API
Оценки: 2.8 - Голосов: 8

ПРОЧТИ МЕНЯ

API Documentation

Getting started with Medium API

Medium API Cover Image - By the Author


Hey guys!

This is the “Getting Started” Guide for the Medium API (Unofficial Version), listed on the RapidAPI Platform.

This REST API helps you to quickly extract data from medium.com, without any hassle.

Using Medium API, you can get -

  • User’s - Info, Articles, Top Articles, Followers, Following, Interests

  • Article’s - Info, Responses, Content, Markdown

  • Publication’s - Info, Articles, Newsletter

  • Top Feeds, Latest Posts, Top Writers, Related Tags

> 💡 Checkout our swagger documentation for the details on each endpoint!


Before getting started, you must first get your API Key to authenticate your calls. You’ll need to pass it in the headers, along with the requests, to use the API smoothly.

Header -

x-rapidapi-key: [RAPIDAPI_KEY]

API’s Base URL:

> https://medium2.p.rapidapi.com

Endpoints:

User 👥  :
· [GET User ID]
· [GET User Info]
· [GET User's Articles]
· [GET User's Top Articles]
· [GET User's Following]
· [GET User's Followers]
· [GET User's Interests]

Article ✏️ :
· [GET Article Info]
· [GET Article's Content]
· [GET Article's Markdown]
· [GET Article's Responses]

Publication 📜  :
· [GET Publication ID]
· [GET Publication Info]
· [GET Publication Articles]
· [GET Publication's Newsletter]

Misc 🌀  :
· [GET Latest Posts]
· [GET Top Writers]
· [GET Top Feeds]
· [GET Related Tags]

GET User ID

Every Medium user has one unique hash ID associated with his/her account. Usually, we only deal with usernames that we choose while registering on Medium Platform. You can find your username in the sub-domain of your profile page URL or at the end of it. Like -

Once you get your username, like mine is **nishu-jain,**you can use the following endpoint to get your user_id.

Endpoint -

> GET /user/id_for/{username}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/user/id_for/nishu-jain

{
   "id" : "1985b61817c3"
}

Once you have the user_id, you can invoke other user-related endpoints using it.


GET User Info

Once you’ve got the user_id, you can use it to get user-related information such as -Full name, Username, Bio, Followers & Following count, Twitter username, Profile-image, top writer status, etc …

Endpoint -

> GET /user/{user_id}

If you don’t have the user_id, see the GET User ID endpoint above.

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/user/1985b61817c3

{
   "id" : "1985b61817c3",
   "username" : "nishu-jain",
   "fullname" : "Nishu Jain",
   "bio" : "Obsessed with Tech, Biz, Arts & Words; Does NOT dumb down the writing; Skilled Wordsmith; Delivers the best",
   "followers_count" : 357,
   "following_count" : 4,
   "top_writer_in" : {},
   "twitter_username" : "one_anachronism",
   "is_suspended" : false,
   "is_writer_program_enrolled" : true,
   "medium_member_at" : "",
   "allow_notes" : true,
   "image_url" : "https://miro.medium.com/1*C92Hx7k9nRM7TPlrmhgW9w.jpeg"
}

GET User’s Articles

This endpoint returns a list of articles (article_ids) written by the Medium user.

> 💡 You can then use the GET Article Info endpoint to retrieve information, such as title, subtitle, author, claps, voters, tags, topics, publication, etc…, related to your desired article.

Endpoint -

> GET /user/{user_id}/articles

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/user/1985b61817c3/articles

{
   "associated_articles" : [
      "562c5821b5f0",
      "4bb5cd293022",
      "b2076afc4930",
      "e86fd95532fd",
      "d6fbc4106675",
      .
      .
      .
      "f06086080568",
      "9e469c80585c",
      "416194c7988a"
   ]
}

GET User’s Top Articles

This endpoint returns a list of aritcle_ids of the top 10 posts/articles on the user’s profile (usually in chronological order - most recent posts), for the given user (user_id).

> 💡 You can then use the GET Article Info endpoint to retrieve information on individual articles.

Endpoint -

> GET /user/{user_id}/top_aritcles

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \ 
    https://medium2.p.rapidapi.com/user/1985b61817c3/top_articles

{
   "top_articles" : [
      "562c5821b5f0",
      "4bb5cd293022",
      "b2076afc4930",
      "e86fd95532fd",
      "d6fbc4106675",
      "cd1850bccd9d",
      "644857abeefc",
      "3ce40a280f72",
      "faf7bb349a49",
      "3134743262d9"
   ]
}

GET User’s Following

This endpoint returns a list of user_ids of the given user’s followings.

You can fetch this list and use the GET User Info endpoint to retrieve information related to the individual users.

> Note: Currently, this list does not contain the publication_ids of the publications that the user is following.

Endpoint -

> GET /user/{user_id}/following

Usage—

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/user/14d5c41e0264/following

{
   "following" : [
      "51e7eb466f57",
      "c61f93eeb8a5",
      "cb95a7d0729d",
      "b41e39525113",
      "e4d971c7eba7",
      "2c64bdb18573",
      .
      .
      .
      "bb18b13c5ef4",
      "ff086d17b40f",
      "49f48b36cb76",
      "a7b81ad5e393"
   ],
   "id" : "14d5c41e0264"
}

GET User’s Followers

This endpoint returns a list of user_ids of the followers for the given user.

> Note: The length of followers’ list might be different from what you get in the Get User Info Endpoint. It’s because, this list doesn’t include Medium Users who left the platform.

> If you really need the exact followers’ count, use this endpoint to get the followers’ list and take its length as the exact followers’ count

You can use the GET User Info endpoint to retrieve information related to the individual users.

Endpoint -

> GET /user/{user_id}/followers

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/user/1985b61817c3/followers

{
   "followers" : [
      "105e6602fb79",
      "11b0f8f91e9b",
      "11eea2a54850",
      "124e782d12ac",
      "1278ebdf3e3c",
      .
      .
      .
      "f9e148f93485",
      "fbce1f6b4823",
      "fe7a0e6b99d2",
      "ffb49f9daa5f"
   ],
   "id" : "1985b61817c3"
}

GET User’s Interests

This endpoint returns a list of tags that the given user follows on Medium.

> All tags are lowercased hyphen-separated strings.

Endpoint -

> GET /user/{user_id}/interests

Usage—

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/user/1985b61817c3/interests

{
   "tags_followed" : [
      "gadgets",
      "privacy",
      "history",
      "education",
      "freelancing",
      "software-engineering",
      "android-development",
      "travel",
      "money",
      "technology",
      "programming",
      "science"
   ]
}

GET Article Info

This endpoint returns the article-related information such as Title, Subtitle, Author, Tags, Topics (as assigned by Medium), Publication, Published date and time, Clap Count, Voter Count, Word Count, Responses Count, Reading Time, Language, etc…

For using this endpoint, you’ll need an article’s unique hash ID, called article_id.

You can find the article_id at the end of any Medium Story’s URL. Like -

Endpoint -

> GET /article/{article_id}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/article/b7d838c84f72

{
   "id" : "b7d838c84f72",
   "title" : "How to Play Music Using Mathematics in Python",
   "subtitle" : "Mathematics of Music",
   "author" : "1985b61817c3",
   "claps" : 274,
   "voters" : 51,
   "tags" : [
      "programming",
      "python",
      "mathematics",
      "music",
      "coding"
   ],
   "responses_count" : 4,
   "word_count" : 1179,
   "publication_id" : "7f60cf5620c9",
   "reading_time" : 5.1490566037736,
   "published_at" : "2020-10-07 14:18:50",
   "last_modified_at" : "2021-08-25 16:19:17",
   "topics" : [
      "math",
      "data-science",
      "programming"
   ],
   "lang" : "en",
   "is_locked" : true,
   "is_series" : false,
   "url" : "https://towardsdatascience.com/mathematics-of-music-in-python-b7d838c84f72",
   "image_url" : "https://miro.medium.com/1*aNnZHUx6H1A5QbEJtK6lmA.png"
}

GET Article’s Content

This endpoint returns the textual content of an article/story, for the corresponding article_id.

> You can get the article_id from the URL, as shown above in the GET Article Info endpoint.

Endpoint -

> GET /article/{article_id}/content

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/article/562c5821b5f0/content

{
   "content" : "Title\nSubtitle\n\nParagraph 1\nParagraph 2\nAnd so on ..."
}

GET Article’s Markdown

This endpoint returns the article content in the markdown format (.md), for the corresponsing article_id.

> You can get the article_id from the URL, as shown above in the GET Article Info endpoint.

Endpoint -

> GET /article/{article_id}/markdown

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/article/67fa62fc1971/markdown

{
   "markdown" : "#Title\n##Subtitle\n\nParagraph 1\nParagraph 2\nAnd so on ..."
}

GET Article’s Responses

This endpoint returns a list of responses (response_ids, same as article_ids) for a given article (article_id)

> Note: You can treat response_id pretty much same as aritcle_id. To see the content of the response, use the Get Article’s Content endpoint.

Endpoint -

> GET /article/{article_id}/responses

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/article/67fa62fc1971/responses

{
   "id" : "67fa62fc1971",
   "responses" : [
      "a9bbc22aa1e6",
      "3308e927204a",
      "77c3ddcfebc6",
      "b1fcf9f36d87",
      "295b0938fd49",
      "cc14e813995a",
      "649b48584efb"
   ]
}

GET Publication ID

Every Medium Publication has one unique hash ID associated with it. Usually, we only deal with publication_slug that is generated when we choose our Publication’s Name. You can find your publication_slug in the homepage URL of your publication. Like -

Once you get your publication_slug, you can use the following endpoint to get your publication_id.

Endpoint -

> GET /publication/id_for/{publication_slug}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/publication/id_for/towards-data-science

{
   "publication_id" : "7f60cf5620c9",
   "publication_slug" : "towards-data-science"
}

GET Publication Info

This endpoint returns publication-related information such as _Publication name, Tagline, Description, Tags, Followers Count, Creator, Editors, Twitter username, Instagram username, Facebook Page name, Logo, Domain, etc …_for the corresponding publication_id.

A publication_id is the unique hash ID associated with every Medium Publication. For example, publication_id of TowardsDataScience is “7f60cf5620c9”

If you don’t know the publication_id, you can get it from any article published under it. Use the endpoint GET Article Info, to retrieve the publication_id. Or, if you know the publication_slug, use the endpoint GET Publication ID.

Endpoint -

> GET /publication/{publication_id}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/publication/98111c9905da

{
   "id" : "98111c9905da",
   "name" : "Towards AI",
   "slug" : "towards-artificial-intelligence",
   "tagline" : "The leading AI community and content platform focused on making AI accessible to all",
   "description" : "The leading AI community and content platform focused on making AI accessible to all",
   "tags" : [
      "ARTIFICIAL INTELLIGENCE",
      "MACHINE LEARNING",
      "DATA SCIENCE",
      "PROGRAMMING",
      "DEEP LEARNING"
   ],
   "followers" : 27863,
   "domain" : "pub.towardsai.net",
   "creator" : "8a819983d566",
   "editors" : [
      "8a819983d566",
      "aea8a19ea239",
      "cfd55a204329",
      "dbf92a012bd3",
      "92b9872c24de",
      "f34bfe2bbaec",
      "fb93f4aae2b0",
      "d2b799b51ffa"
   ],
   "facebook_pagename" : "towardsAl",
   "instagram_username" : "towards_ai",
   "twitter_username" : "towards_AI",
   "logo" : "https://miro.medium.com/1*NIT82G_xlaooOWm_pTtb1A.png",
   "url" : "pub.towardsai.net"
}

GET Publication Articles

This endpoint returns the list of articles_ids of the latest 25 articles, posted recently in that publication.

> **Note:**Use the count query parameter to limit the number of articles to get (between 0 and 25).

You can use the GET Article Info endpoint to retrieve information on individual articles.

Endpoint -

> GET /publication/{publication_id}/articles

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/publication/98111c9905da/articles

{
   "publication_articles" : [
      "af749790e33b",
      "8c58a7c93ca",
      "b13dd00dc212",
      "763c88143560",
      "73b72c3b977a",
      "993a4acf3d97",
      .
      .
      .
      "738ab6462f0e",
      "53e6ea42e207",
      "fd81fddc0629"
   ]
}

GET Publication’s Newsletter

This endpoint returns information related to the associated newsletter for the given publication. This includes their name, description, creator’s id, subscriber’s count, unique id, image url, etc…

Endpoint -

> GET /publication/{publication_id}/newsletter

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/publication/98111c9905da/newsletter

{
   "id" : "d710a73cd042",
   "name" : "This AI newsletter is all you need",
   "slug" : "this-ai-newsletter-is-all-you-need",
   "description" : "We have moved our newsletter. Subscribe → https://ws.towardsai.net/subscribe",
   "subscribers" : 6738,
   "creator_id" : "aea8a19ea239",
   "image" : "https://miro.medium.com/1*j2OVd7j2o2FHeE7T8TzpXw.png"
}

GET Latest Posts

This endpoint returns a list of the latest posts (article_ids) under a topic/niche (as classified and distributed by the Medium platform). Examples of a topic/niche can be:

  • blockchain

  • relationships

  • mental-health, etc …

These are known as topic_slugs. (Not same as tags)

At any given moment, this endpoint will return a list of 25 articles (article_ids). You can then GET Article Info endpoint to retrieve information related to each article.

Endpoint -

> GET /latestposts/{topic_slug}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/latestposts/blockchain

{
   "latestposts" : [
      "f685c5075a52",
      "b850ac3cff72",
      "5212ce732e25",
      "9190bbd3a843",
      "7a54f7434ed2",
      .
      .
      .
      "adcbccfc46f6",
      "b76cfc88c8ec",
      "17a945a9c206",
      "e0cce016ee98"
   ]
}

GET Top Writers

This endpoint returns a list of top writers (user_ids) within a particular topic/niche (using topic_slug). Examples of topic_slug are -

  • blockchain

  • relationships

  • artificial-intelligence, etc …

You can use an optional query parameter count to specify the number of top writers you want to retrieve.

> Note: Maximum number of top writers within a topic will be 250.

After fetching the user_ids, you can use the GET User Info endpoint to extract information related to the individual users.

Endpoint -

> GET /top_writers/{topic_slug}

> GET /top_writers/{topic_slug}?count={count}

Usage—

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/top_writers/artificial-intelligence

{
   "top_writers" : [
      "5d33decdf4c4",
      "819323b399ac",
      "39db050c2ac2",
      "7ba6be8a3022",
      .
      .
      .
      "96695e08553b",
      "6839bfdfd8e2",
      "f10e9a50984a",
      "390cfc4f2130",
      "a55fe9f18283"
   ]
}

GET Top Feeds

This endpoint returns a list of article_ids (length: 25) for the given tag and mode.

Example of a tag will ‘blockchain’, ‘defi’, ‘artificial-intelligence’, etc…

Mode:

  • hot : For getting trending articles

  • new : For getting the latest articles

  • top_year : For getting the best articles of the year

  • top_month : For getting the best articles of the month

  • top_week : For getting the best articles of the week

  • top_all_time: For getting the best articles of all time

> Note: You can use the GET Article Info endpoint to retrieve information related to each article.

Endpoint -

> GET /topfeeds/{tag}/{mode}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/topfeeds/ethereum/new

{
   "mode" : "NEW",
   "tag" : "ethereum",
   "topfeeds" : [
      "b06fa4a43450",
      "eed52917813c",
      "7fdd9e0733ad",
      "12be441f94a0",
      "30d5204a1bd3",
      "e3335729d3c2",
      "d54885e6c834",
      .
      .
      .
      "f685c5075a52",
      "defdff20b1c7",
      "dc2554e14184"
   ]
}

Get Related Tags

This endpoint returns a list of related_tags for a given tag.

Example: For the tag blockchain, it will return_“cryptocurrency”, “bitcoin”, “ethereum”, “crypto”, “ico”, “technology”, “defi”, “nft”, “fintech”_.

Endpoint -

> GET /related_tags/{tag}

Usage -

curl --header "x-rapidapi-key: $RAPIDAPI_KEY" \
    https://medium2.p.rapidapi.com/related_tags/blockchain

{
   "given_tag" : "blockchain",
   "related_tags" : [
      "cryptocurrency",
      "bitcoin",
      "ethereum",
      "crypto",
      "ico",
      "technology",
      "defi",
      "nft",
      "fintech"
   ]
}

Final thoughts -

As of now, this API consists of 19 endpoints, all of which use the GET method. I’ll try to add more endpoints in the future and improve its efficiency to provide you with the best Medium API possible.

If you’ve any thoughts on it, feel free to share them. I’ll appreciate your feedback and try to improve it further.

My email ID: nishu@mediumapi.com

Thanks for reading and have a wonderful day!


PS: We post tutorials, videos, code snippets, and insights related to Medium and Medium API. So be sure to follow us on: