Google Business Performance API 的新 API 方法可通过单个 API 请求提取多个 `DailyMetrics`。 请查看弃用时间表和相关说明,并从 v4 reportInsights API 方法迁移至 Google Business Profile Performance API。
如要继续操作,请确保您已完成前提条件中的步骤,且您的项目已获准使用 Business Profile API。
启用 API
您必须在 Google API 控制台中启用以下 8 个与商家资料相关联的 API:
Google My Business API
My Business Account Management API
My Business Lodging API
My Business Place Actions API
My Business Notifications API
My Business Verifications API
My Business Business Information API
My Business Q&A API
启用 API
如果您已满足所有前提条件且已获得相应 API 的访问权限,但仍无法使用提供的快捷方式,则可以按照以下步骤手动启用该 API。
要为您的项目启用 API,请执行以下操作:
在 Google API 控制台中打开 API 库。如果系统提示,请选择一个项目或创建一个新项目。API 库中列出了所有可用的 API(按产品系列和热门程度分组)。
如果列表中没有显示您要启用的 API,请使用搜索功能查找该 API。
选择您要启用的 API,然后点击启用按钮。
如果系统提示,请启用结算功能。
如果系统提示,请接受该 API 的服务条款。
如果您是 Google Workspace 用户,请确认在您的 Google Workspace 组织中已为您的账号启用 Google 商家资料。如果您所在的 Google Workspace 组织为您的账号停用了 Google 商家资料,那么您在使用 GBP API 时会收到“错误 403 - 权限遭拒”的消息。
请求 OAuth 2.0 客户端 ID
您的应用将访问受保护的非公开数据,因此,您需要使用 OAuth 2.0 客户端 ID。您的应用可通过该 ID 以应用用户的身份请求授权,以便访问贵组织的营业地点数据。
您的应用必须在要访问非公开用户数据的所有 Business Profile API 请求中发送 OAuth 2.0 令牌。
如果您尚未创建 OAuth 2.0 凭据,请前往 Google API 控制台的“凭据”部分,点击创建凭据 > OAuth 客户端 ID 进行创建。创建凭据后,您将在凭据页面上看到客户端 ID。点击客户端 ID 即可查看详细信息(例如客户端密钥、重定向 URI、JavaScript 源地址及电子邮件地址)。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eBefore using Business Profile APIs, ensure project approval and enable the eight associated APIs in the Google API Console.\u003c/p\u003e\n"],["\u003cp\u003eObtain an OAuth 2.0 client ID for your application to authorize access to location data.\u003c/p\u003e\n"],["\u003cp\u003eUnderstand REST basics and JSON format to interact with the APIs via HTTP requests and responses.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the OAuth Playground for experimenting with API calls, and consider using client libraries for simplified interaction.\u003c/p\u003e\n"],["\u003cp\u003eThere is no sandbox environment for testing API calls; use \u003ccode\u003evalidateOnly\u003c/code\u003e parameter for request validation without data modification.\u003c/p\u003e\n"]]],["To begin using Business Profile APIs, ensure prerequisites are met and project access is approved. Enable eight specified APIs in the Google API Console. If you're a Google workspace user, make sure Google Business Profile is enabled. Generate an OAuth 2.0 client ID for secure data access. Understand REST basics, using HTTP verbs (GET, POST, PUT, DELETE) with unique URIs, and learn the structure of JSON, the data format used. Utilize the OAuth 2.0 Playground for testing; the client libraries can also be used.\n"],null,["# Basic setup\n\nTo proceed, make sure you've completed the steps in\n[Prerequisites](/my-business/content/prereqs) and that we've approved your project for Business Profile\nAPIs access.\n\nEnable the APIs\n---------------\n\n| **Note:** The Google My Business API is only visible in the Google API Console to users who submit and receive approval for their Google Account through the access request form. For more details, see [Request access to the APIs](/my-business/content/prereqs#request-access).\n\n\nThere are eight APIs associated with Business Profile that must be enabled in the Google API\nConsole:\n\n- Google My Business API\n- My Business Account Management API\n- My Business Lodging API\n- My Business Place Actions API\n- My Business Notifications API\n- My Business Verifications API\n- My Business Business Information API\n- My Business Q\\&A API\n\n### Enable an API\n\nIf you've completed all of the\n[Prerequisites](/my-business/content/prereqs) and have been granted access to the API, but are still unable\nto use the provided shortcut, you can enable the API manually with the following steps.\n\n\nTo enable an API for your project, do the following:\n\n1. [Open the API Library](https://console.cloud.google.com/apis/library) in the Google API Console. If prompted, select a project or create a new one. The API Library lists all available APIs, grouped by product family and popularity.\n2. If the API you want to enable isn't visible in the list, use search to find it.\n3. Select the API you want to enable, then click the **Enable** button.\n4. If prompted, enable billing.\n5. If prompted, accept the API's Terms of Service.\n\nIf you are a **Google workspace user** , confirm that [Google Business Profile is turned on for your account](https://support.google.com/a/answer/10623799) in your Google workspace organization. You will get \\`error 403 - PERMISSION DENIED\\` when using the GBP APIs if Google Business Profile is turned off for your account in your Google workspace organization.\n\nRequest an OAuth 2.0 client ID\n------------------------------\n\nBecause your app accesses protected, non-public data, you need an\n[OAuth 2.0](/identity/protocols/OAuth2) client ID. This lets your app request\nauthorization to access your organization's location data on behalf of your app's users.\n\nYour application must send an OAuth 2.0 token with any Business Profile APIs request\nthat accesses private user data.\n\nIf you haven't done so already, go to the \"Credentials\" section of the\n[Google API Console](https://console.developers.google.com/apis/credentials) and click\n**Create credentials \\\u003e OAuth client ID** to create your OAuth 2.0 credentials. After you've\ncreated the credentials, you can see your client ID on the **Credentials** page. Click the\nclient ID for details, such as client secret, redirect URIs, JavaScript origins address, and email\naddress.\n\nLearn REST basics\n-----------------\n\nThere are two ways to invoke the APIs:\n\n- Send an HTTP request and parse the responses.\n- Use [client libraries](/my-business/samples).\n\nIf you decide not to use client libraries, you need to understand the basics of REST.\n\nREST is a style of software architecture that provides a convenient and consistent approach to\nrequest and modify data.\n\nThe term REST is short for\n\"[Representational State Transfer](https://en.wikipedia.org/wiki/Representational_state_transfer).\" In the context of Google APIs, it refers\nto the use of HTTP verbs to retrieve and modify representations of data stored by Google.\n\nA RESTful system stores resources in a data store. A client sends a request for the\nserver to perform a particular action, such as to create, retrieve, update, or delete a resource,\nand the server performs the action and sends a response. That response is often in the form of a\nrepresentation of the specified resource.\n\nIn Google's RESTful APIs, the client specifies an action with an HTTP verb, such as\n`GET`, `POST`, `PUT`, or `DELETE`. The client specifies\na resource by a globally unique uniform resource identifier (URI) of the following form: \n\n```\nhttps://apiName.googleapis.com/apiVersion/resourcePath?parameters\n```\n\nBecause all API resources have unique HTTP-accessible URIs, REST enables data caching and is\noptimized to work with the web's distributed infrastructure.\n\nYou might find the\n[method definitions](https://tools.ietf.org/html/rfc7231#section-4.3) in the HTTP 1.1 standards documentation\nuseful. They include specifications for `GET`, `POST`, `PUT`, and\n`DELETE`.\n\nREST in the Business Profile APIs\n---------------------------------\n\nThe Business Profile APIs operations map directly to REST HTTP verbs.\n\nThe specific format for the Business Profile APIs is shown in the following URI: \n\n```\nhttps://apiName.googleapis.com/apiVersion/resourcePath?parameters\n```\n\nThe full set of URIs used for each supported operation in the APIs appears in the Business Profile APIs\n[Reference](/my-business/reference/rest) documentation.\n\nResource paths vary based on the endpoint.\n\nFor example, the resource path to an account appears as in the following example: \n\n accounts/accountId\n\nThe resource path for a location appears in the following form: \n\n locations/locationId\n\nLearn JSON basics\n-----------------\n\nThe Business Profile APIs return data in JSON format.\n\nJavaScript Object Notation ([JSON](http://en.wikipedia.org/wiki/JSON)) is a common, language-independent data format that\nprovides a simple text representation of arbitrary data structures. For more information, see\n[json.org](http://www.json.org/).\n\nUse Oauth Playground to make a simple HTTP request\n--------------------------------------------------\n\nYou can use the\n[OAuth 2.0 Playground](https://developers.google.com/oauthplayground)\nto experiment with the Business Profile APIs. Because the Business Profile APIs\naren't public APIs, there are a few extra steps you need to take to use it in the Playground. You\nneed a client ID for a web application to proceed.\n\n1. Go to the [Google API Console](https://console.developers.google.com/apis/credentials) and open your project. If you don't have an OAuth client ID for web applications, create one now:\n 1. From the *Create credentials* drop-down list, select **OAuth client ID**.\n 2. For *Application type* , click **Web Application**.\n 3. Add the following as a valid redirect URI:\n\n ```\n https://developers.google.com/oauthplayground\n \n ```\n 4. Click **Create**.\n2. Copy the client ID to the clipboard.\n3. Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground).\n4. Click the gear icon to open the configuration options and make the following changes:\n 1. Set *OAuth flow* to **Client-side**.\n 2. Select **Use your own OAuth credentials**.\n 3. Paste in your OAuth client ID.\n5. Close the configuration options.\n6. Under \"Step 1 - Select \\& authorize APIs,\" paste the following scope for the\n Business Profile APIs into the *Input your own scopes* field:\n\n ```\n https://www.googleapis.com/auth/business.manage\n ```\n7. Click **Authorize APIs**.\n8. Click **Accept** when prompted.\n9. Under \"Step 2 - Configure request to API,\" paste the following URI into the\n *Request URI* field:\n\n ```\n https://mybusinessaccountmanagement.googleapis.com/v1/accounts\n ```\n10. Click **Send the request** . The response should show a status of `200 OK`.\n\nFor more information about how to make various types of requests, see\nthe [Business Profile APIs Reference](/my-business/reference/rest).\n| **Note:** There's no Sandbox environment for the Business Profile APIs. Some calls allow for a `validateOnly` query parameter that, when set to `true`, validates a request without changes made.\n| **Note:** The OAuth 2.0 playground automatically adds debugging headers. If you use a different client and would like to view detailed error messages in the response, add the following header to the request: `X-GOOG-API-FORMAT-VERSION: 2`\n\nClient libraries\n----------------\n\nThe Business Profile APIs client libraries support the functionality of the Business Profile APIs. They provide\nfunctionality common to all Google APIs, such as HTTP transport, error handling, authentication,\nand JSON parsing.\n\nTo download client libraries, see [Libraries](/my-business/samples)."]]