0

I need to make a Google API call to get specific information about members of a group.

The API for fetching group members is described here: https://developers.google.com/admin-sdk/directory/v1/guides/manage-group-members

But this API only returns ONE of the fields that I require for each member. I also require first name, last name, display name, phone number, organization, job title, and department.

ALL the fields for a user are available through this API: https://developers.google.com/admin-sdk/directory/v1/guides/manage-users. But I don't want to make multiple API calls to get the user information that I need.

Is there a way to get a set of fields for the members of a group?

I have found an API parameter named "fields" which can REDUCE the number of fields returned by the "members" API: https://developers.google.com/admin-sdk/directory/v1/guides/performance#patch

But how do I INCREASE the number of fields returned?

Or, alternatively, can I make a call to the "users" API and FILTER on the group I am looking for?

I did an HTTP GET against https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members.

It returned JSON in this format:

{
  "kind": "directory#members",
  "members": [
    {"kind": "directory#member",
     "id": "group member's unique ID",
     "email": "liz@example.com",
     "role": "MANAGER",
     "type": "GROUP"
    },
  ],
}

The "members" list does not include first name, last name, phone number, etc.

I expected an API parameter which I can use to specify which attributes to return in the "members" list.

1 Answers1

1

By using a Google API batch request I was able to reduce the number of API calls to:

  1. MEMBERS API request to get the members of a group.
  2. BATCH API request comprised of 1000 USER API requests (due to the 1000 request limit per batch).

So, for example, a group with 2000 members takes 3 API calls in total:

  1. Get the members of the group.
  2. Get the attributes for the first 1000 users.
  3. Get the attributes for the second 1000 users.

Here is the info for Google API batch requests:

https://developers.google.com/admin-sdk/directory/v1/guides/batch

And the Python Google library we are using provides a very clean wrapper:

https://googleapis.github.io/google-api-python-client/docs/batch.html