Reading topics in a forum with JavaScript

(Oscar Or Something) #1


I’m making a website and the guy i’m doing it for wants to use discourse as a forum.

How would i go about querying discourse for all the topics in a forum?

(Blake Erickson) #2

You will probably want to use the Discourse API

(Jeff Atwood) #3

You could get the RSS feed, or you could retrieve the json. Just add .json to the end of most URLs here on this site, for a live demo.

(Spero Koulouras) #4

It is really easy to customize Discourse with CSS, then run it in an iframe within your site. You don’t need to code anything.

If you prefer to go the API route, the first couple API’s you may want to take a look at are:

http://<discourse site>/site.json

This will return JSON describing the site. Within this JSON you will find all of the categories on the site. It is likely you will need to understand the categories before you dive into topics. Once you have the categories you can retrieve the topics within them using:

http://<discourse site>/c/<category id>.json

Once you understand those two API’s the rest of the API guide should make sense.

(Jeff Atwood) #5

Fair warning, Discourse is a heavy dependency to run in an <iframe>. I would not generally recommend this configuration unless you are in some very specialized situation where that’s your only way forward.

(Spero Koulouras) #6

Jeff - It would be helpful to me to understand your comment better. I obviously know much less about this than you do, but if a Website is built out with SquareSpace, Wix or Weebly it seems pretty easy to glue in an iframe pointed to a Discourse instance. With any of these tools there is obviously overhead - is your concern that loading Discourse within the iframe will further bloat an already bloated site?