Forum Discussion

xorrkaz's avatar
xorrkaz
Genius
13 years ago
Solved

How to get label usage count via REST?

We'd like to build a "label cloud."  However, I'm not seeing how we can get a usage count of a particular label via the REST API.  Is this possible?  Has anyone had success building a cloud for labels?  Thanks.

6 Replies

  • AdamN's avatar
    AdamN
    Khoros Oracle
    13 years ago

    Hi xorrkaz,

     

    The "posts" method on the Community object will give you a NodeMessageContext object:

    http://lithosphere.lithium.com/restapi/vc/posts

     

    The NodeMessageContext object can be handy for getting messages with a particluar label, for example:

    http://lithosphere.lithium.com/restapi/vc/posts/for/labels/text/release%20notes

     

    Once you have a NodeMessageContext object, there are many methods you can use, including the "count" method. For example:

    http://lithosphere.lithium.com/restapi/vc/posts/for/labels/text/release%20notes/count

     

    Hopefully this is what you're looking for. If not, let me know!

     

    Regards,

     

    Adam

  • xorrkaz's avatar
    xorrkaz
    Genius
    13 years ago

    Brilliant!  Thanks, Adam.  I didn't know that posts/for/labels branch existed.  It's not documented in the REST API guide (though now I see it's mentioned in the release notes).  Any chance that can get added? :smileywink:

  • xorrkaz's avatar
    xorrkaz
    Genius
    13 years ago

    I have 12.3, but I don't see the "/for/labels" API except in the release_info.txt file.  Where is it documented in the main class documentation?  Thanks.

  • AdamN's avatar
    AdamN
    Khoros Oracle
    13 years ago

    From the index page, click "NodeMessageContext" link to pull up the listing for that class. The method I referenced is "for/labels/text/label_text"

     

    If you're not seeing it in your copy of the JavaDocs, I'd recommend downloading the latest. The copy I'm referencing was generated: Fri Mar 30 02:31:04 PDT 2012

  • xorrkaz's avatar
    xorrkaz
    Genius
    13 years ago

    Thanks.  Now I see why I missed it.  I was greping for for/labels, and the HTML markup made that fail.  I found it now.