# Multiple topics in single API request

**URL:** https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807
**Category:** Development
**Created:** [March 9, 2016, 12:52pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807 "2016-03-09T12:52:25Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [March 9, 2016, 12:52pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/1 "2016-03-09T12:52:26Z")

</div>

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:

`GET discourse.foo/t/topicID/1234.json`

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:

`GET discourse.foo/t/topicID/topic.json?filter=1234,5678,90123`

Not sure if this exists or a plugin is required.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 9, 2016, 2:38pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/2 "2016-03-09T14:38:15Z")

</div>

There is something like that to the latest: [https://meta.discourse.org/latest.json](https://meta.discourse.org/latest.json)

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).

---

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [March 9, 2016, 9:48pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/3 "2016-03-09T21:48:18Z")

</div>

> [@Falco](#):
>
> we query Discourse database

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!)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 9, 2016, 9:56pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/4 "2016-03-09T21:56:38Z")

</div>

We use a pretty non-standard Discourse install 😄.

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.

---

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [March 9, 2016, 9:58pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/5 "2016-03-09T21:58:52Z")

</div>

> [@mr8](#):
>
> (don’t want to accidentally open up the database to remote connections!)

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](https://meta.discourse.org/t/142537?silent=true) also and accessing the DB directly would be easy. I guess I just want to try it the “Discourse way” first 😉

---

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [March 9, 2016, 11:04pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/6 "2016-03-09T23:04:05Z")

</div>

> [@Falco](#):
>
> There is something like that to the latest:

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.

---

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [March 10, 2016, 6:27am UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/7 "2016-03-10T06:27:28Z")

</div>

Working through this whole plugin thing I have built a basic plugin and used some fine work here [Discourse Topic Voting](https://meta.discourse.org/t/discourse-feature-voting/40121) to extend my brain…

Basic requirements:

```
plugin_folder/plugin.rb (initialise) 
plugin_folder/app/controllers/plugin_name/function_controller.rb
plugin_folder/config/routes.rb
plugin_folder/lib/plugin_name/engine.rb

```

i’ll post the Repo once done.

---

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [March 11, 2016, 3:00pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/8 "2016-03-11T15:00:13Z")

</div>

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

[https://github.com/abyrnedesign/discourse-json-follow-list](https://github.com/abyrnedesign/discourse-json-follow-list)

---

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [March 11, 2016, 7:56pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/9 "2016-03-11T19:56:31Z")

</div>

That is really awesome! Thanks for sharing!

---

<div class="post-metadata">

### Author: ![adopilot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adopilot/32/105040_2.png) [@adopilot](https://meta.discourse.org/u/adopilot)
#### Post date: [November 30, 2018, 12:22pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/10 "2018-11-30T12:22:55Z")

</div>

Sorry for bumping post 2 years old.  
Does this still works,  
Can we make request only whit **tib = topic id** multiple param whitout user id param

---

<div class="post-metadata">

### Author: ![Andrew\_Byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew_byrne/32/116413_2.png) [@Andrew\_Byrne](https://meta.discourse.org/u/Andrew_Byrne)
#### Post date: [November 30, 2018, 8:07pm UTC](https://meta.discourse.org/t/multiple-topics-in-single-api-request/40807/11 "2018-11-30T20:07:57Z")

</div>

The answer to both maybe.

I’ve not tested this repo in production In a few versions now. If your looking for a fully featured plug in the ain’t it.

If you are how ever looking for the start of a dev project that you can tinker with to give you want you want your in luck!

This script is makeing a few (probably super slow) DB queries. Looking at it now it’s running a query that should work with out a uid.

But be ready to fork and hack
