Forum Discussion

jordanepotter's avatar
12 years ago
Solved

Rest call to get most active forum topics across community

Is there a REST call that will let me get the most commented on forum topics for a time period, that only pulls from forums, but can pull from all the forums in a community? We need "the most active" topics pulled into a widget. We are doing something similar with getting most replies to any posts, but it only pulls from a certain category, and pulls from all types of posts. We did that using this:

 

categories/id/[id]/search/messages?q=is_root:true&sort_by=-replies&rangeTime=1M&restapi.response_style=view&restapi.format_detail=full_list_element

 

If we could get the same stuff back, but for only topics and across the whole community, that would be great.

 

Thanks in advance for any help.

6 Replies

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    There's a search context for the community level too, so if you remove the category context you get something like:

    /search/messages?q=is_root:true&sort_by=-replies&rangeTime=1M&restapi.response_style=view&restapi.format_detail=full_list_element

     

    To get only results from forums, you can use the "include_forums" query string parameter and set the value to true:

    /search/messages?q=is_root:true&sort_by=-replies&rangeTime=1M&restapi.response_style=view&restapi.format_detail=full_list_element&include_forums=true

     

    For example:

    http://lithosphere.lithium.com/restapi/vc/search/messages?q=is_root:true&sort_by=-replies&rangeTime=1M&restapi.response_style=view&restapi.format_detail=full_list_element&include_forums=true

  • irach15's avatar
    irach15
    Maven
    9 years ago

    AdamN,

    can you please help me to get a json respond from a specific board and only tkb articles?

    something like:

    /restapi/vc/boards/id/someBoard/search/messages?q=is_root:true&sort_by=-replies&restapi.response_style=view&restapi.format_detail=full_list_element&xslt=json.xsl

     

    But I need only tkb articles, and even better if I can narrow it to show only id, url, subject, body, tags,  author...

    Using a search not to create a custom component (that one I know how to ;-) )

    Thanks

  • AdamN's avatar
    AdamN
    Khoros Oracle
    9 years ago

    Hi irach15,

     

    Sounds like you're on the right track. What issues are you running into?

     

    If you're only searching a single board and that board is a TKB, then that should satisfy your requirement for TKB articles only.

     

    If you've never used our API v2, I'd definitely suggest checking it out:

    http://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2

    You have a lot more powerful querying capabilities than v1, including the ability to select which fields you get back in the response.

     

    I hope this helps!

  • sam2's avatar
    sam2
    Guide
    9 years ago

    Hi AdamN

     

    Could you suggest me a way to only include tkb articles in my search results? I tried something like "include_tkb=true" already, but it did'nt worked out for me.

  • irach15's avatar
    irach15
    Maven
    9 years ago

    Hi sam2,

    this is how I search only 'tkb' articles for specific boards in a custom component

    <#assign apiVersion = "2.0"/>
    <#assign x= rest(apiVersion,"/search?q=" + "SELECT id, subject, post_time, conversation.last_post_time, board, board.id, board.view_href, board.title, view_href, body FROM messages WHERE category.id IN('someBoard1','someBoard2', 'someBoard3') AND conversation.style = 'tkb' AND depth=0 ORDER BY post_time DESC LIMIT 5"?url) />
  • sam2's avatar
    sam2
    Guide
    9 years ago

    Hi irach15

    I meant that question for V1 rest api in lithium.

     

    But thank you for your time too.