How to get average stories for a user from the API?

I am trying to integrate a medium blog into the application, showing several cards with images of posts and links to the original Medium publication.

From the middle APIs, I can see how to retrieve posts and create posts, but doesn't mention receiving posts. Is receiving messages / stories for the user that is currently possible using the environment API?

+5
source share
5 answers

The API is for writing only and not for receiving messages (middle staff told me)

You can simply use the RSS feed as such:

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

You can just get the RSS feed via GET, and then if you need it in JSON format, just use an NPM module like rss-to-json and you're good to go.

+13
source

Note that you will receive all the information about your own message ........

 mediumController.getBlogs = (req, res) => { parser('https://medium.com/feed/@profileName', 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.json(200, { Data: stories }) }); } 
+4
source

Using this REST method, you will do the following: GET https://api.medium.com/v1/users/{{userId}}/publications , and this will return the title, image and URL of the element. Additional information: https://github.com/Medium/medium-api-docs#32-publications .

You can also add "? Format = json" to the end of any Medium URL and return useful data.

+3
source

I created a basic function using AWS Lambda and AWS API Gateway if anyone is interested. A detailed explanation can be found on this blog post here , and a repository for the Lambda function built with Node.js can be found here on Github . Hope someone here finds this helpful.

+1
source

(An update to the JS Fiddle function and the Clay function that explains this when we update the syntax of the function to clear)

I packaged the Github @ mark-fasel package mentioned below in the Clay microservice, which allows you to do just that:

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

I put together a little fiddle, as the user asked how to use the endpoint in HTML to get the headers for the last 3 posts: https://jsfiddle.net/h405m3ma/3/

You can call the API as follows:

 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 easily use it in your node code using the npm package for clay-client 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 this is helpful!

+1
source

Source: https://habr.com/ru/post/1245363/


All Articles