Multiple topics in single API request

(Andrew Byrne) #1

Using the Discourse API is pretty cool and I’ve used it to provide a number of custom interrogations in related sites. One thing that has caused me some issues is the fact I need to make single requests on each topic via:


for most Discourse systems this is cool but I am blending results, ie requesting multiple topics and adding them to a single post feed. when the number increases the requests become… annoying.

I’m looking for a solution something along the lines of the user_actions that accepts a filter. like:


Not sure if this exists or a plugin is required.

Beginner's Guide to Creating Discourse Plugins Part 2: Plugin Outlets
(Rafael dos Santos Silva) #2

There is something like that to the latest:

I too, have a post feed on my website index, but we query Discourse database and do it ourselves (the sql is heavily based on the latest.json query).


interesting… we use the API on our site (which has its limitations sometimes).

Any suggestions on how to get started with accessing the discourse database locally on the server? (don’t want to accidentally open up the database to remote connections!)

(Rafael dos Santos Silva) #4

We use a pretty non-standard Discourse install :smile:.

But I suppose you just need to expose the 5432 port from docker to the host.

And from there block external attack vectors. pg_hba.conf, ufw, iptables and so.

It really depends on your case, maybe crafting a plugin or submitting a core PR can even be easier.

(Andrew Byrne) #5

So I’m new to the whole plugin thing, but I assuming (without looking) that using a plugin we might be able to craft what we want via the application, and use it security. Rather than bypassing whats built.

I have a pretty non standard install also and accessing the DB directly would be easy. I guess I just want to try it the “Discourse way” first :wink:

(Andrew Byrne) #6

So I have users that “microBlog” in to topics.
Other users can then follow peeps.

The feed needs to collect all the topics (user blogs) and sort them to in a time line. This is already working, but as you can imagine gets pretty cumbersome in terms of network requests.

Really need a single request for it.

(Andrew Byrne) #7

Working through this whole plugin thing I have built a basic plugin and used some fine work here Discourse Voting to extend my brain…

Basic requirements:

plugin_folder/plugin.rb (initialise) 

i’ll post the Repo once done.

(Andrew Byrne) #8

As promised the repo.
This is likely the most basic super simple functioning plugin know to man.
But heck it was built with love…


That is really awesome! Thanks for sharing!