Apps Script deprecated the Contacts service on December 16,2022. Instead, use the People API advanced service. The People API uses a newer JSON protocol and provides advanced features, like merging contacts with profiles.
Use this guide to learn which Contacts service methods have no equivalent in the People API advanced service, learn what you can use instead, and find code samples for migrating common tasks. For more information, refer to the Contacts API Migration Guide.
Methods without People API equivalents
The following lists getContacts
methods in the Contacts service that don’t
have
equivalent ways to search for contacts in the People API advanced service. With
the People API advanced service, you can search by a contact's names
,
nickNames
, emailAddresses
, phoneNumbers
, and organizations
fields that
are from the CONTACT
source.
Methods without equivalents |
---|
|
The following lists getContacts
methods from the Contacts service that use an
extra
label
parameter. You can use searchContacts
from the People API advanced service to get contacts by the equivalent field,
but you can’t limit the search to a specific label.
Methods with partial equivalents |
---|
|
Additional features available with People API
When you migrate to the People API advanced service, you can access the following People API features that aren't available in the Contacts service:
- Specify the data source–When you search for information about a person, you can specify where to search, such as a Google contact or a Google profile.
- Search for people by a query string–You can get a list of profiles and contacts that match a specific string.
- Batch requests–You can batch your People API calls to help reduce your script execution time.
Code samples for common tasks
This section lists common tasks from the Contacts service. The code samples show how to construct the tasks using the People API advanced service.
Get a contact group by name
The following code sample shows how to get a contact group by its name, which
is the equivalent to getContactGroup(name)
in the Contacts service.
Get a contact by email address
The following code sample shows how to get a contact by their email address,
which is the equivalent to getContact(emailAddress)
in the Contacts service.
Get all contacts
The following code sample shows how to get all of a user’s contacts, which is
the
equivalent to getContacts()
in the Contacts service.
Get a contact’s full name
The following code sample shows how to get a contact’s full name, which is the
equivalent to getFullName()
in the Contacts service.
Get all phone numbers for a contact
The following code sample shows how to get all of the phone numbers for a
contact, which is the equivalent to getPhones()
in the Contacts service.
Get a specific phone number for a contact
The following code sample shows how to get a specific phone number for a
contact, which is the equivalent to getPhoneNumber()
in the Contacts service.