Как работать с данными аккаунтов
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
В этом руководстве рассказывается, как работать с данными аккаунтов. С помощью My Business Account Management API можно выполнить следующие действия:
- Получить список всех аккаунтов.
- Получить данные определенного аккаунта.
- Обновить данные об аккаунте.
Подготовка
Прежде чем начинать работу с My Business Account Management API, зарегистрируйте свое приложение и получите учетные данные OAuth 2.0.
Подробнее о начале работы с Business Profile API…
Как получить список всех аккаунтов
Проверить все аккаунты, связанные с пользователем, выполнившим аутентификацию, проще всего, запросив их полный список. Для этого воспользуйтесь API accounts.list
.
Выполните следующие действия:
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts
Как получить данные определенного аккаунта
Иногда вам необходимо получить сведения только о конкретном аккаунте, который связан с пользователем, выполнившим аутентификацию. Воспользуйтесь API accounts.get
, чтобы получить подробную информацию об аккаунте.
Выполните следующие действия:
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
Как обновить данные об аккаунте
Изменение названия аккаунта – важная задача для администратора. Для этого нужно использовать API accounts.update
.
Выполните следующие действия:
$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
{
"account": {
"accountName": "Anne Droyd"
},
"languageCode": "en",
"validateOnly": "true"
}
Ограничения
- Единственное редактируемое поле для аккаунта –
accountName
. Все остальные передаваемые поля игнорируются.
- Обновлять таким образом можно только данные об аккаунтах типа
BUSINESS
.
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-29 UTC.
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 2025-08-29 UTC."],[[["\u003cp\u003eThe My Business Account Management API allows you to manage business accounts, including listing all accounts, retrieving specific account details, and updating account names.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you must register your application and obtain OAuth 2.0 credentials as outlined in the basic setup guide.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a list of all accounts associated with an authenticated user or fetch details for a specific account using dedicated API endpoints.\u003c/p\u003e\n"],["\u003cp\u003eUpdating an account is restricted to changing the account name for business type accounts only, with other fields being ignored.\u003c/p\u003e\n"]]],[],null,["# Work with account data\n\n\u003cbr /\u003e\n\nThis tutorial shows you how to work with account data. The My Business Account Management API\nprovides you with the ability to do the following:\n\n- List all accounts.\n- Return a specific account.\n- Update an account.\n\nBefore you begin\n----------------\n\nBefore you use the My Business Account Management API, you need to register your application\nand obtain OAuth 2.0 credentials.\n\nFor details on how to get started with the Business Profile APIs, see\n[Basic setup](/my-business/content/basic-setup).\n\nList all accounts\n-----------------\n\nA great way to validate the accounts associated with an authenticated user is to\nlist all their accounts. Use the [`accounts.list`](/my-business/reference/accountmanagement/rest/v1/accounts/list)\nAPI to list all accounts associated with a user.\n\nTo list all the accounts for an authenticated user, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts\n```\n\nReturn a specific account\n-------------------------\n\nSometimes, you only want to see information about a specific account for an\nauthenticated user. Use the [`accounts.get`](/my-business/reference/accountmanagement/rest/v1/accounts/get)\nAPI to return a specific account and review additional account details.\n\nTo return a specific account by name, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n```\n\nUpdate an account\n-----------------\n\nChanging an account name is a fundamental administrative task. Use the\n[`accounts.update`](/my-business/reference/accountmanagement/rest/v1/accounts/patch) API to alter\nthe account name.\n\nTo update a specific account by name, use the following:\nHTTP \n\n```bash\n$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n\n{\n \"account\": {\n \"accountName\": \"Anne Droyd\"\n },\n \"languageCode\": \"en\",\n \"validateOnly\": \"true\"\n}\n```\n\n### Restrictions\n\n- The only editable field for an account is `accountName`. Any other fields passed are ignored.\n- Only accounts of `BUSINESS` type can be updated in this manner."]]