.json endpoint to receive array of arbitrary posts with a single request

AI-generated summary

.json endpoint to receive array of arbitrary posts with a single request

piipkin is looking for a .json endpoint to retrieve an arbitrary collection of posts by id, with full post bodies. pfaffman doesn’t think such an endpoint exists, but suggests reverse-engineering the Discourse API to achieve this.

piipkin shares his use case: building a proof-of-concept of a Discourse-powered shared-bookmarking system. pfaffman advises creating a plugin to add a custom endpoint or modifying a serializer to achieve this. piipkin confirms he was considering these options.

Hi,

Is there an .json endpoint that allows me to request an arbitrary collection of posts by id? I’m talking posts here, not topics.

For example posts.json?id=2,9,40,388,... etc etc.

Been looking through the code but couldn’t find it…

(It’s important that the response contains the full post bodies, so not only excerpts)

I don’t think so.

If you print a topic it will give you all of the posts. You can Reverse engineer the Discourse API to see what request that makes.

Out of curiosity, what would be your use case? :slight_smile:

Building a proof-of-concept of a Discourse-powered shared-bookmarking system.

I’d do that in a plugin so you could create your own endpoint that returned /bookmarks/user/USERNAME or whatever you want.

Or even easier might be to just add to some serializer the bookmarks you want.

I came to the exact same options! Thanks :slight_smile: