Forum Discussion

Suchith's avatar
7 years ago

How to fetch Users Data based on Sort or Order by id Using V2 API.

Hi, 

I have couple of question regarding Fetching User Data using V2 API.

In my use case. I want to fetch all the registered user from community. For this, I am getting total count of user and later am using limit and offset to get the actual data.

Total count of users rows:
https://api.lithium.com/community/2.0/<Tenant_Id>/search?q=select+count(*)+from+users

Fetching User Data:
https://api.lithium.com/community/2.0/<Tenant_Id>/search?
q=select+*+from+users+limit+25+offset+0

Note: I will be incrementing offset by 25 each iteration.

Question 1: When I increment the offset each time, will there be any possibility to get the same row?  (Reference: https://lithosphere.lithium.com/t5/Li-Discussions/Boards-and-Users-order-by-ID/m-p/486509)
Question 2: Is it possible to Sort or Order by  User ID?
Question 3: Is it possible  to fetch the User data based of ID range?

Looking forward to hear about this


  • Suchith

     Most of the user's field does not exist for object 'users' as a sort constraint, not even id. But you can sort it by registration time. It would work in an expected way. 

    select * from users order by registration_data.registration_time desc

    When you increment the offset each time, it would not fetch the same result again. 

  • Suchith

     Most of the user's field does not exist for object 'users' as a sort constraint, not even id. But you can sort it by registration time. It would work in an expected way. 

    select * from users order by registration_data.registration_time desc

    When you increment the offset each time, it would not fetch the same result again.