Ottieni solo i post di primo livello nel topic tramite l'API di Discourse

Vorrei poter ottenere i 20 post più recenti di livello superiore su un argomento senza dover rieseguire ricorsivamente il recupero e il filtraggio delle risposte ai post fino a raggiungerne 20. Esiste un filtro per questo e l’ho semplicemente mancato da qualche parte nell’API?

Al momento sembra che l’array stream nella risposta includa le risposte ai post per numero di post. Quindi, se ho 4 post [1,2,3,4] e pubblico una risposta al post 1, lo stream sarà ora [1,2,3,4,5] e l’unico modo per capire che il 5 è una risposta al 1 è esaminare il post stesso, trovare “reply_to_post_number” => 1 ed escluderlo. Sto tralasciando qualcosa?

1 Mi Piace

That is correct. There is not a filter that can be added to the topic endpoint to get what you are after. However we do have the

which you could use to write a sql query to get what you are after. You can then save that query and hit the api endpoint for the saved query and pass it a topic_id as a param.

2 Mi Piace

There isn’t a real way to get what you actually want out of this, because the metadata is messy, and people are messy and don’t really care about your analytics too much :wink:

2 Mi Piace

Thanks, I will give this a shot.

Ora abbiamo il parametro di query filter_top_level_replies=true che gestirà questo per te.

Ecco un esempio qui su meta https://meta.discourse.org/t/linkify-words-in-post/82193.json?filter_top_level_replies=true