Forum Discussion

Ashish_Rai's avatar
6 years ago

Popular Topics and Labels

I am interested in pulling Trending Topics from the community forum. Now I understand there there 'getPopularTopics' function. But I am interested in getting trending/popular labels and related topics for these labels

Whats the best way to approach this?

  • luk's avatar
    luk
    6 years ago

    Ashish_Rai nope, unfortunately still not possible to get multiple labels with API v2, see here, the only operator allowed in the constraint is "=", not "IN()", you would need to resort back to API v1 =/: 

    /restapi/v1/categories/id/<category.id>/labels?page_size=100&restapi.response_format=json

    the problem with v1 is, that it does not give you any context-information whatsoever, e.g. once you got your labels from API v1, you'll need to loop trough ALL of them and issue a s***load of v2 queries (min 1 for each label, possibly more) to get the information you need (e.g. messages with that label, how many views, kudos etc. those messages have and so on)... it is certainly possible from a technical standpoint somehow, but Khoros definitely does not make it easy for us to do so and we have to keep an eye on possible performance implications as well when doing such things...

  • Ashish_Rai,

    There is no directly way to get popular labels.

    You can do something with modify and use custom in place like.

    Count the number of most views, kudos, solution and replies and then check message labels attached to it.

    with below query by passing its message id.

    SELECT id FROM labels WHERE messages.id='176' 
    • Ashish_Rai's avatar
      Ashish_Rai
      Helper

      Parshant , Thanks! And I believe we can get the multiple (as in top 5) using multiple message Id?

      • luk's avatar
        luk
        Boss

        Ashish_Rai nope, unfortunately still not possible to get multiple labels with API v2, see here, the only operator allowed in the constraint is "=", not "IN()", you would need to resort back to API v1 =/: 

        /restapi/v1/categories/id/<category.id>/labels?page_size=100&restapi.response_format=json

        the problem with v1 is, that it does not give you any context-information whatsoever, e.g. once you got your labels from API v1, you'll need to loop trough ALL of them and issue a s***load of v2 queries (min 1 for each label, possibly more) to get the information you need (e.g. messages with that label, how many views, kudos etc. those messages have and so on)... it is certainly possible from a technical standpoint somehow, but Khoros definitely does not make it easy for us to do so and we have to keep an eye on possible performance implications as well when doing such things...