Forum Discussion

chakri's avatar
chakri
Contributor
5 years ago

Query the Users based on the "last_visit_time"

Hello everyone,

I am trying to integrate with Khoros/Lithium  v1-API's. I am trying to pull the user (/restapi/vc/users) data based on the "last_visit_time" element to get the list of the most recent users logged into the system unlike getting all the users information.

The sample user object contains the following elements mentioned below and I am trying to find if we can pass a "query" as a queryParams to get the user data based logged in the last 24 hours ?.

 

 <user type="user" href="/users/id/5">

      <last_visit_time type="date_time">2019-07-23T03:12:49+00:00</last_visit_time>

      <email type="string">sharst080102@yopmail.com</email>

      <registration_time type="date_time">2018-08-27T02:07:58+00:00</registration_time>

      <banned type="boolean">false</banned>

      <average_message_rating type="float">0.0</average_message_rating>

      <average_rating type="float">0.0</average_rating>

      <deleted type="boolean">false</deleted>

      <login type="string">shar</login>

      <anonymous type="boolean">false</anonymous>

      <sso_id type="string">efcb-e234f9c8cff1</sso_id>

      <registered type="boolean">true</registered>

      <id type="int">5</id>

    </user>

any much related is highly appreciated.

Thanks in advance 🙂

Note: I am querying through to get the results. any postman request/response will be greatly helpful

  • Hi chakri ,

    You can easily use V2 API's in the Postman as well,

    Eg. for the above V2 API you can pass something as follows:

    /api/2.0/search?q=select * from users WHERE last_visit_time > 2019-08-19T16:23:23.000-07:00

    Which in URL would seem like following

    https://[Your community domain]/api/2.0/search?q=select%20*%20from%20users%20WHERE%20last_visit_time%20%3E%202019-08-19T16:23:23.000-07:00

    The following is the documentation for the same:

    https://developer.khoros.com/khoroscommunitydevdocs/docs/getting-started-with-community-api-2

     

    Please Give Kudos if you find this post useful and also mark this as Accepted Solution if this is the required solution.


    Regards

    Tarun Kumar

3 Replies

  • Hi chakri ,

    Documentation to the V2 API: https://devdocportal.lithium.com/t5/Community-API-v2-Reference/bd-p/restv2docs?section=commv2&collection=users

    This information can be obtained from the V2 API as follows:

    ISO8601 format
    SELECT * FROM users WHERE last_visit_time > 2019-08-19T16:23:23.000-07:00

     

    milliseconds since epoch format
    SELECT * FROM users WHERE last_visit_time > 1566239058288

     

    Please Give Kudos if you find this post useful and also mark this as Accepted Solution if this is the required solution.


    Regards

    Tarun Kumar

  • chakri's avatar
    chakri
    Contributor
    5 years ago

    Hello Tarun,

     

    Thanks for your response,

    I am looking for Something in v1 version to get the most recent users logged in.

    I will also consider your response. Is it possible to provide the Post Man request and response for the query you provided ?

     

    Looking forward.

  • Hi chakri ,

    You can easily use V2 API's in the Postman as well,

    Eg. for the above V2 API you can pass something as follows:

    /api/2.0/search?q=select * from users WHERE last_visit_time > 2019-08-19T16:23:23.000-07:00

    Which in URL would seem like following

    https://[Your community domain]/api/2.0/search?q=select%20*%20from%20users%20WHERE%20last_visit_time%20%3E%202019-08-19T16:23:23.000-07:00

    The following is the documentation for the same:

    https://developer.khoros.com/khoroscommunitydevdocs/docs/getting-started-with-community-api-2

     

    Please Give Kudos if you find this post useful and also mark this as Accepted Solution if this is the required solution.


    Regards

    Tarun Kumar