Forum Discussion

Claudius's avatar
13 years ago

"Realtime" metric & for a certain period via REST API

We are currently trying to plug in Lithium metrics into another monitoring solution and would like to get daily/hourly/minutely metrics on views/posts per board.   Question 1: I can't find a wa...
  • AdamN's avatar
    13 years ago

    Hi Claudius,

     

    Question 1

     

    Unfortunately the method you're working with doesn't have a way to bound the search results. However, you could use search instead. For example:

    http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/search/messages/count

     

    For your query, you can search on the date field. You specify the date field as a range with the endpoint values specified in seconds since epoch, like so:

    date:[1341341612 TO 1341946412]

     It's a good ideal to URL encode your query string parameter values:

    date%3A%5B1341341612%20TO%201341946412%5D

     

    Putting it all together:

    http://skypec.lithium.com/skypec/restapi/vc/boards/id/Windows/search/messages/count?q=date%3A%5B1341341612%20TO%201341946412%5D&collapse_discussion=false
    

     

    You may have noticed the extra collapse_discussion parameter at the end. That disabled collapsing of search results, which essentially combines multiple results from the same topic into a single result, like how it's shown in the UI. This way, you're getting all of the messages.

     

    Question 2

     

    I'd suggest specifying the date_start and/or date_end parameters for your query. They're listed as optional in the JavaDocs, but if you don't specify the parameters then the query is unbounded. So what's likely happening is that with how much history your community already has, you're exceeding the result limit imposed for that method because you're requesting results for the entire history of your community.

     

    Bonus Question

     

    I'd say that most methods are as real-time as the UI. There may be a few methods here and there that are cached for performance, but with getting counts for messages, you shouldn't have any issues.

     

     

    Regards,

     

    Adam