Reputation: 23
I am aware of the Users list endpoint in the Admin SDK Directory API. However, it is really slow since you must iterate over all users to calculate the count.
I am also aware of the currentNumberOfUsers endpoint in the Admin Settings API. However, that API does not have a read-only scope, and it contains a lot of other potentially sensitive information.
Is there a read-only API for retrieving the current number of accounts on a domain?
Upvotes: 2
Views: 116
Reputation: 1
If you only need the count, you could actually just iterate through the userList
Directory.Users.List userList = ...
while (... ) {
...
users = userList.execute();
result += users.getUsers().size();
...
}
return result;
Upvotes: 0
Reputation: 253
Users list endpoint is not that slow if you pass a "field" parameter instead of requesting all user data. A good "fields" value could be "users/primaryEmail".
Upvotes: 1