Fetch third party data for topic list

Hello @Discourse,

I want to render data from third party api’s under the title of the topic for each them in topic list page. Can someone guide me how can I render data using best practices?

As I am don’t know much about the customization in discourse. Any advice would be great help and be appreciated!

Please anyone help me out for solving this issue ?

If you use the plugin outlets theme component, it will show you which outlet to use to build your customization.

sounds like you want the after-topic-list-item outlet.

Links to more theme component dev topics

Beginner's guide to developing Discourse Themes

Theme Developer Quick Reference Guide

Beginner's guide to using Discourse Themes

Developing Discourse Plugins - Part 1 - Create a basic plugin

If you are looking for dev help with building this customization, I would suggest using the marketplace category. :slight_smile:

1 Like

Thanks @Lilly. Actually, I want to display some data from third party API for each topic and for that I am looking for a way to call the third party api when data load on list page.

So, when the page loads I should be calling the api and then I want to render data. At the moment I am gethering all the list data and calling third party api whatever data comes I just append that data in DOM. But I want to fetch data on lazy load of topic list page.

This is generally a bad idea. If the host serving the API is slow, your forum will be slow. If the host serving the API is down, your forum will be down. If your forum is overwhelmed, the API will be overwhelmed.

You should load the data asynchronously, for instance in a sidekiq job, and store it with the topic.

1 Like

Thanks @RGJ for messaging!

I know it’s a bad idea but I am new to discourse so didn’t know much about it. Now, I will look for the sidekiq job as you suggest.

I do have one more question. Will sidekiq job be able to figure out if there is a new data coming in for the topic list page? or do I have to do something differently to let the job know that list page loads more data?

Thank you!

The sidekiq job will not know about whether a page list loads more data. It is independent.

You will have the sidekiq job periodically load the data using the API and store it together with the topic.

Then when the topic list is loaded, the stored data will be retrieved. See it as a caching mechanism.

3 Likes

Got it.

Thank you so much @RGJ!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.