Get Post from Medium API in 2022 using JavaScript
Sorry for the hiatus but I’m back with more articles and crazy experiences as a Software Engineer. But let’s start with something light.
You know the drill but first;
Note: I’ll not be doing this with React but the methods are easily applicable given that we will be using Axios.
A BRIEF INTRODUCTION
Medium is a blogging platform, like WordPress or Blogger. Medium is the new project from the guys who brought you Twitter. Medium is chaotically, arrhythmically produced by a combination of top-notch editors, paid writers, PR flacks, startup bros, and hacks. (Thank you, Google)
PREREQUISITES:
- Basic knowledge of how to use AXIOS. If you haven’t used Axios before, I have a quick Article with an easy API that will get you up to speed in <2min! CLICK HERE
- Understanding Asynchronous JavaScript. Read my article here.
- Understanding Promises, Objects and Arrays in JavaScript.
(Knowledge of these would help improve your understanding but is not necessary)
Step 1: Creating the API
Firstly go to, https://app.nocodeapi.com/ and sign up(Google makes it faster), choose a username and go to your Dashboard:
Go to the marketplace and choose Medium, and create your API:
In the second input field after the feed, put your Medium Username.
Step 2: Testing the API on the platform
Click on “Use this API”
Tip: If you want to access data other than your feed, like your personal “information” then in the feed URL, remove the “feed” and just put your username.
Step 3: Writing the Code
The good thing about this platform is that they actually give you the code snippet and there’s not a lot of brain energy you have to expend. But they use fetch API so let’s tweak it a little bit for Axios.
(In the image ABOVE click on code snippet)
- Request Headers
- The Function and its callback
And just like that, we are done! Check your console for the results.
Side Note: I am sure there is a way to do this Medium’s API and your Integration Token, and I’m working on it because there aren’t a lot of resources on it. Until then, if like me you would like to display your posts in a seemingly easy and fast way, then this should suffice. Once I figure out the API, I’ll put up an article. P.S If you know how to (with JavaScript) Let me know in the comments
Unyime.