Forum Discussion

iahiqosolutions's avatar
12 years ago

REST API. How to sort messages in a blog?

Hello folks,   I have a question: Lets consider that we have a blog with articles. How can we sort all these articles by views or publish date?   We have tried to use following REST API methods...
  • AdamN's avatar
    AdamN
    12 years ago

    Hello,

     

    If you want to go the search route, you can use "is_root:true" as the value of the q parameter, and then sort as needed. This will return "root" messages, which is the first message in a thread. For example:
    http://lithosphere.lithium.com/restapi/vc/blogs/id/lithiumblog/search/messages?q=is_root:true&sort_by=-topicViews


    There's a message_viewer.topic_sort_order parameter that can be used with the threads methods; however, the only available values are last_post_date and topic_start_date, which doesn't sound like it will help you with your particular use case. I'd suggest giving the search option a try.

     

    I hope this helps!

     

    -Adam