How to retrieve Medium stories for a user from the API?

前端 未结 11 1423
再見小時候
再見小時候 2021-01-30 04:06

I\'m trying to integrate Medium blogging into an app by showing some cards with posts images and links to the original Medium publication.

From Medium API docs I can see

11条回答
  •  既然无缘
    2021-01-30 05:05

    (Updating the JS Fiddle and the Clay function that explains it as we updated the function syntax to be cleaner)

    I wrapped the Github package @mark-fasel was mentioning below into a Clay microservice that enables you to do exactly this:

    Simplified Return Format: https://www.clay.run/services/nicoslepicos/medium-get-user-posts-new/code

    I put together a little fiddle, since a user was asking how to use the endpoint in HTML to get the titles for their last 3 posts: https://jsfiddle.net/h405m3ma/3/

    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-simple
    

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

    Clay.run('nicoslepicos/medium-get-user-posts-new', {"profile":"profileValue"})
    .then((result) => {
    
      // Do what you want with returned result
      console.log(result);
    
    })
    .catch((error) => {
    
      console.log(error);
    
    });
    

    Hope that's helpful!

提交回复
热议问题