Can I send an external URL to the Discourse API for it to return topics linking to that URL?

Would it be possible, on an external non-Discourse website, to have a “Forum topics that discuss this page” section containing links to the relevant Discourse forum topics?

If the API can take a URL and return a list of topic IDs/URLs that would be perfect.

Do you know about Embed Discourse comments on another website via Javascript?

But if you think that multiple topics link to a page then you might be able to use the TopicLink table to do a search of topics that link that URL (probably with the Data Explorer plugin) and then you’d have the topic and post IDs so you could link to them.

I don’t think there’s an endpoint to get them. A plugin could make one available, I think. Also, Discourse GitHub doess something sort-of similar, so that might help.

1 Like

Do you think I could create a query with a URL parameter and run it via the API using this? Run Data Explorer queries with the Discourse API.

2 Likes

Yes I think so, kinda.

Try this, e.g.:

https://meta.discourse.org/search.json?q=https%3A%2F%2Fnews.bbc.co.uk

Tidy results in JavaScript.

If anon can use search you perhaps don’t need an API key even (then you can put this client side)

However you might want to cache the results on the external server for best results and avoid poor Discourse get overwhelmed with search queries.

So this probably involves writing server side code on your external website for best outcome.

2 Likes

Wow, thanks Robert, this does work, I just tried on my own server.

This sounds really similar to something I was trying to do earlier. My other server uses PHP and I figured out how to use Curl commands in a PHP module to hit the API and return json results to an ajax call from the client. Here is that topic

1 Like

Oh! Of course. A regular search will find the URL! :person_facepalming:

1 Like