0

How does one retrieve the posts of a user using Medium API?

The documentation shows a POST endpoint to create a blog post but a GET request to the corresponding endpoint results in an error.

An SO User
  • 24,612
  • 35
  • 133
  • 221

3 Answers3

4

You get the posts of a user by using the RSS feed:

https://medium.com/feed/@user_name

Retrieving a user's or publication posts is not possible using the Medium API v1 (current). Medium staff told me it's deliberately write-only. A few things can be listed, like contributors and publications, but not posts and their content. The RSS feed is to be used in this case.

For example, a popular profile:

https://medium.com/feed/@vanschneider

You can also use it with publications:

https://medium.com/feed/desk-of-van-schneider

Here is an example using Express and the parse-rss NPM module:

var parser = require('parse-rss');

router.get('/blog', function(req, res, next) {

    parser('https://medium.com/feed/@vanschneider', function(err, rss)
    {
        if (err) {
            console.log(err);
        }

        var stories = [];

        for (var i = rss.length - 1; i >= 0; i--) {

            var new_story = {};

            new_story.title = rss[i].title;
            new_story.description = rss[i].description;
            new_story.date = rss[i].date;
            new_story.link = rss[i].link;
            new_story.author = rss[i].author;
            new_story.comments = rss[i].comments;

            stories.push(new_story);
        }

        console.log('stories:');
        console.dir(stories);

        res.render('somepage',
        {
            stories: stories,
        });
    });
});
Antonio Brandao
  • 1,353
  • 13
  • 19
  • Its work great for post content but its not get the image url.Can i get the img url. – Yash Feb 14 '17 at 10:18
1

It’s not possible to enumerate the list of existing drafts or published posts, e.g. to crosspost to another service or backup your posts to a local archive.

BUT! https://github.com/lambtron/medium-cli you can lookup for solution here :3

vovchisko
  • 2,049
  • 1
  • 22
  • 26
  • I used it just to read medium few times. Just for fun. You can try if you installed medium-cli "medium top 10". But to select article to read you should use arrow keys. – vovchisko May 24 '16 at 13:14
0

Answered this question over here. Summary below:

I created a Clay microservice that enables you to do exactly this:

https://clay.run/services/nicoslepicos/medium-get-users-posts

You can call the API as:

curl -i -H "Content-Type: application/json" -X POST -d '{"username":"nicolaerusan"}' https://clay.run/services/nicoslepicos/medium-get-users-posts

You can also use it easily in your node code using the clay-client npm package and just write:

Clay.run('nicoslepicos/medium-get-users-posts', {"username":"usernameValue"})
.then((result) => {

  // Do what you want with returned result
  console.log(result);

})

Hope that's helpful!

Community
  • 1
  • 1
nicoslepicos
  • 505
  • 1
  • 5
  • 9