google-apigoogle-contacts-apigoogle-people-api

Google People API - get contact details (batch)


Using Google People API, one can get a contact detail by its ID.

"https://people.googleapis.com/v1/" + id + "?key=" + <KEY> + "&personFields=addresses,clientData,emailAddresses,names,organizations,phoneNumbers,birthdays",

Is it possible to get such details in batch? I have a list of 100 contact ids and I want them to get at once as it'd be much faster.


Solution

  • In your situation, how about using the method of "Method: people.getBatchGet"? When this method is used, the 200 resource names (maximum number) can be retrieved by one API call. When this is used for your situation, it becomes as follows.

    Sample curl command:

    curl \
      'https://people.googleapis.com/v1/people:batchGet?personFields=addresses%2CclientData%2CemailAddresses%2Cnames%2Corganizations%2CphoneNumbers%2Cbirthdays&resourceNames=people%2Fsample1&resourceNames=people%2Fsample2&resourceNames=people%2Fsample3' \
      --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
      --header 'Accept: application/json' \
      --compressed
    

    Reference: