GICodeWarrior
GICodeWarrior

Reputation: 23

How can a Google Apps Marketplace Application retrieve the number of users on a specific domain?

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

Answers (2)

Marco
Marco

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

AMS
AMS

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

Related Questions