How can I call third party apis in discourse

Hi,
I am wondering that is there any way by which we can call third-party custom API created in node.js in discourse?

feedback appreciated

Thanks

Shouldn’t matter what the API is written in, if all interaction happens over http.

You will probably need to write some javascript ajax calls in a Theme Component, or if appropriate, make http calls in some new Plugin code you write in Ruby using a suitable Ruby gem like Excon or Httparty.

1 Like

Thanks for the reply @merefield I appreciate your feedback.
I am new to discourse development. Previously, I have done work on nodebb community CMS belongs to Nodejs. There, I have done a lot of customization ( created custom API to call Zoho tickets data, fetching the list of Vimeo videos a lot more). So I want to perform the same or need to create the same API(s) in it and render response data in some static pages to the user.

Thanks

Use the backend to make the call:

  • if you need this to be secure,
  • if you need the backend to process the result
  • if the call(s) may be long running

If long running put it in a Job.

That will require some Ruby in a Plugin and one of the above mentioned gems.

It’s not necessarily all that easy to get into Discourse plugin development, it’s a big complex, opinionated platform, but there are good official guides on here and LOTS of existing open source plugins to look through (see plugin and links to github). Try to find one that does something similar and look at how it is solved in code.

If it’s superficial consider a Theme Component. Look at the Theme Development guides on here.

Look at examples, like this one: discourse-tc-quote-of-the-day/get-quote.js.es6 at master · merefield/discourse-tc-quote-of-the-day (github.com)

3 Likes

okay @merefield I am looking into it. Appreciate your feedback.

1 Like