How to connect to the Medium API in Rails

Step 1

Generate an integration token.

https://medium.com/me/settings

Step 2

Let’s look at the docs. https://github.com/Medium/medium-api-docs

You need to put the access token in your headers like this:

curl -X GET -H “Authorization: Bearer THISTEXTSHOULDBEYOURACCESSTOKEN” -H “Content-Type: application/json” -H “Accepts: application/json” “https://api.medium.com/v1/me”

Test it out in the terminal.

If you did it right, you should see a json response like this

Step 3 — Get your posts

You can’t simply request you own posts with their api, probably because that would make too much sense. So how can I get my blog posts on my rails website?

First I read something from an actual good blogger.

Thanks dawg.

Then my nipples tingled, because I knew just what to do. Go in the the rss feed to get my data.

https://medium.com/feed/@liyicky <- Replace liyicky with your medium name.

Which looks like this:

Then getting that in a simple ruby class. Forgive the bad code, I’m very rusty.

Test it in the console.

Thank you for reading ❤.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Liyicky

Liyicky

Hey, I’m Jason Cheladyn. Going back to the coding world after 6 years of teaching English in Japan. https://www.twitter.com/liyicky https://www.liyicky.com