API Endpoint for Latest Topics in Public Categories

Hi.
I need to fetch the latest topics in public categories from my forum via an API call and embed them in my parent website.

I have implemented a basic solution using /latest endpoint.
I was successful in only fetching the latest topics from public categories via the following procedure -

  1. Fetch all the categories using the /categories endpoint.
  2. Filter out the private categories via the read_restricted field.
  3. Call the endpoint - http://127.0.0.1:9292/latest?exclude_category_ids%5B%5D=<private_category_id_1>&exclude_category_ids%5B%5D=<private_category_id_1>&exclude_category_ids%5B%5D=<private_category_id_3> ......

As you can see, the length of the URL will go on increasing with the number of private categories.

Is there any better solution apart from this (and exposing a custom end-point via a plugin) ?

Note - I do not want to use “suppress from latest” feature. I want it under the latest tab in the forum but not in the API call response.

If you do the API calls with a user that doesn’t have the right to see those categories, then they won’t be returned in the responses :wink:

1 Like