Forum Discussion
Parshant
Boss
You can use below API to get all users from the role (eg. "Administrator") you add in name.
SELECT * FROM users WHERE roles.name='Administrator'
ADS_PSI
7 years agoMentor
I also found another post which gave me solution : https://lithosphere.lithium.com/t5/Developer-Discussion/Using-REST-API-to-get-user-list-with-specified-role-or-ranking/m-p/66794
- luk7 years agoBoss
ADS_PSI yes, although the answer you found uses API v1 while Parshant's solution uses v2, which is recommended and gives you the option to only fetch the information you actually need (OK, not if you use the SELECT * FROM =)...but it gives you far greater control over the response and is generally a bit faster than v1.
Small addition, if you need to aggregate users having multiple roles, you can do:
SELECT id FROM users WHERE roles.name IN ('Administrator', 'Moderator')
This would require you to do multiple API calls with your v1 solution...