Advanced People Service
Stay organized with collections
Save and categorize content based on your preferences.
The advanced People service allows you to use the
People API in Apps Script. This API allows scripts
to create, read, and update contact data for the logged in user and read profile
data for google users.
Reference
For detailed information on this service, see the
reference documentation for the People API.
Like all advanced services in Apps Script, the advanced People service uses the
same objects, methods, and parameters as the public API. For more information, see How method signatures are determined.
To report issues and find other support, see the
People v1 support guide.
Sample code
The sample code below uses version 1 of the API.
Get the user's connections
To get a list of people in the user's contacts,
use the following code:
Get the person for the user
To get the user's profile, you need to request
the https://www.googleapis.com/auth/userinfo.profile
scope by following the
instructions to add explicit scopes
to your appsscript.json
manifest file. Once the scope is added, you can use
the following code:
Get the person for a Google Account
To get the person information for any Google Account,
use the following code:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe advanced People service in Apps Script utilizes the People API to manage contact data for the logged-in user and access Google user profiles.\u003c/p\u003e\n"],["\u003cp\u003eThis advanced service needs to be enabled before use and mirrors the functionality of the public People API.\u003c/p\u003e\n"],["\u003cp\u003eScripts can create, read, and update contact details for the current user, as well as retrieve profile information for other Google users.\u003c/p\u003e\n"],["\u003cp\u003eSample code snippets are provided to demonstrate functionalities like fetching user connections, retrieving the user's own profile, and getting information for any Google Account by ID.\u003c/p\u003e\n"]]],[],null,["# Advanced People Service\n\nThe advanced People service allows you to use the\n[People API](/people) in Apps Script. This API allows scripts\nto create, read, and update contact data for the logged in user and read profile\ndata for google users.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/people/api/rest) for the People API.\nLike all advanced services in Apps Script, the advanced People service uses the\nsame objects, methods, and parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[People v1 support guide](/people/support).\n\nSample code\n-----------\n\nThe sample code below uses [version 1](/people/api/rest) of the API.\n\n### Get the user's connections\n\nTo [get a list of people in the user's contacts](/people/api/rest/v1/people.connections/list),\nuse the following code: \nadvanced/people.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/people.gs) \n\n```javascript\n/**\n * Gets a list of people in the user's contacts.\n * @see https://developers.google.com/people/api/rest/v1/people.connections/list\n */\nfunction getConnections() {\n try {\n // Get the list of connections/contacts of user's profile\n const people = People.People.Connections.list('people/me', {\n personFields: 'names,emailAddresses'\n });\n // Print the connections/contacts\n console.log('Connections: %s', JSON.stringify(people, null, 2));\n } catch (err) {\n // TODO (developers) - Handle exception here\n console.log('Failed to get the connection with an error %s', err.message);\n }\n}\n```\n\n### Get the person for the user\n\nTo [get the user's profile](/people/api/rest/v1/people/get), you need to request\nthe `https://www.googleapis.com/auth/userinfo.profile` scope by following the\n[instructions to add explicit scopes](/apps-script/concepts/scopes#setting_explicit_scopes)\nto your `appsscript.json` manifest file. Once the scope is added, you can use\nthe following code: \nadvanced/people.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/people.gs) \n\n```javascript\n/**\n * Gets the own user's profile.\n * @see https://developers.google.com/people/api/rest/v1/people/getBatchGet\n */\nfunction getSelf() {\n try {\n // Get own user's profile using People.getBatchGet() method\n const people = People.People.getBatchGet({\n resourceNames: ['people/me'],\n personFields: 'names,emailAddresses'\n // Use other query parameter here if needed\n });\n console.log('Myself: %s', JSON.stringify(people, null, 2));\n } catch (err) {\n // TODO (developer) -Handle exception\n console.log('Failed to get own profile with an error %s', err.message);\n }\n}\n```\n\n### Get the person for a Google Account\n\nTo [get the person information for any Google Account](/people/api/rest/v1/people/get),\nuse the following code: \nadvanced/people.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/people.gs) \n\n```javascript\n/**\n * Gets the person information for any Google Account.\n * @param {string} accountId The account ID.\n * @see https://developers.google.com/people/api/rest/v1/people/get\n */\nfunction getAccount(accountId) {\n try {\n // Get the Account details using account ID.\n const people = People.People.get('people/' + accountId, {\n personFields: 'names,emailAddresses'\n });\n // Print the profile details of Account.\n console.log('Public Profile: %s', JSON.stringify(people, null, 2));\n } catch (err) {\n // TODO (developer) - Handle exception\n console.log('Failed to get account with an error %s', err.message);\n }\n}\n```"]]