Forum Discussion

vipaggar's avatar
vipaggar
Contributor
5 years ago

Single API call for all post related info

Is there an API which will return all the following propertied related to a post ID with single api:

 

  1. Post subject
  2. Content
  3. Likes/kudos
  4. Views
  5. All comments and sub-comments. That is entire hierarchy.
  6. Tags
  7. Popularity
  8. Last update time stamp
  9. Creation time stamp

 

  • The closest you can probably get with API v2 is a query like this:

     

    SELECT id, subject, body, view_href, conversation.last_post_time, current_revision.last_edit_time, author.login, author.view_href, metrics.views, kudos.sum(weight), tags.count(*), replies.count(*), popularity FROM messages WHERE depth = 0 LIMIT 10

     

    with the information you get about tags and replies (e.g. if there are any) you could then issue the necessary API calls to fetch those objects but only if necessary.

    if you want the entire conversation (e.g. a conversation with all replies), things get a bit more complicated and the easier way out is to use API v1 because it gives you the entire conversation trough it's /threads endpoints, like this

     

    <community.url>/restapi/v1/threads/id/1223?restapi.response_format=json

     

    there you will find a node/property called "linear", that is the entire conversation...

    if you want to do it with API v2, you need to remove the depth = 0 constraint and instead figure out WHERE constraints with parent.id or ancestors.id which will then return all child messages of the parent specified and go from there...