注意:您正在查看 API 的 REST 接口的文档。我们的大多数官方客户端库都使用 gRPC。如需了解详情,请参阅
REST 简介。
其他方法
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
虽然 Mutate
、Search
和 SearchStream
是 Google Ads API 中最常用的方法,但还有许多其他方法可用于特定用途。所有服务及其 API 均记录在参考文档中。
Protocol Buffer RPC 到 REST 的映射
所有服务端点(无论使用 REST 还是 gRPC)最终都是使用 proto3 接口定义语言在服务软件包的 .proto 文件中定义的。
示例:ListAccessibleCustomers
例如,customer_service.proto
文件定义了一个 ListAccessibleCustomers
方法,以及标准 Mutate
。其 google.api.http
注释描述了该方法如何映射到 HTTP。它使用带有自定义动词 listAccessibleCustomers
的 HTTP GET
:
rpc ListAccessibleCustomers(ListAccessibleCustomersRequest)
returns (ListAccessibleCustomersResponse) {
option (google.api.http) = {
get: "/v21/customers:listAccessibleCustomers"
};
}
此方法会映射到 customers.listAccessibleCustomers REST 方法。
示例:CreateCustomerClient
customer_service.proto
中的另一个示例是 CreateCustomerClient
方法。其 google.api.http
注释使用自定义动词 createCustomerClient
描述了 HTTP POST
:
rpc CreateCustomerClient(CreateCustomerClientRequest)
returns (CreateCustomerClientResponse) {
option (google.api.http) = {
post: "/v21/customers/{customer_id=*}:createCustomerClient"
body: "*"
};
option (google.api.method_signature) = "customer_id,customer_client";
}
这会映射到 customers.createCustomerClient REST 方法。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eWhile \u003ccode\u003eMutate\u003c/code\u003e, \u003ccode\u003eSearch\u003c/code\u003e, and \u003ccode\u003eSearchStream\u003c/code\u003e are commonly used, the Google Ads API offers a wide range of methods for specific tasks, all documented in the REST reference documentation.\u003c/p\u003e\n"],["\u003cp\u003eAll Google Ads API service endpoints, including REST and gRPC, are defined in .proto files using the proto3 Interface Definition Language.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle.api.http\u003c/code\u003e annotation within these .proto files details how each method maps to HTTP for RESTful interactions, including examples like \u003ccode\u003eListAccessibleCustomers\u003c/code\u003e and \u003ccode\u003eCreateCustomerClient\u003c/code\u003e.\u003c/p\u003e\n"]]],["The Google Ads API includes various methods beyond `Mutate`, `Search`, and `SearchStream`, all detailed in REST documentation. Service endpoints are defined in `.proto` files using proto3. `ListAccessibleCustomers` is a GET method, mapped using the `google.api.http` annotation in the `customer_service.proto` file, and uses custom verb `listAccessibleCustomers`. Similarly, `CreateCustomerClient`, a POST method, uses custom verb `createCustomerClient`, also defined in the same file.\n"],null,["# Other Methods\n\nWhile `Mutate`, `Search`, and `SearchStream` are the most common methods\nin the Google Ads API, there are many others for specific purposes. All services and\ntheir APIs are documented in the\n[reference documentation](/google-ads/api/reference/rpc/v21/overview).\n\nProtocol buffer RPC to REST mappings\n------------------------------------\n\nAll the service endpoints (whether using REST and gRPC) are ultimately defined\nin the\n[.proto files of the services package](https://github.com/googleapis/googleapis/tree/master/google/ads/googleads/v21/services)\nusing the\n[proto3 Interface Definition Language](//cloud.google.com/apis/design/proto3).\n\n### Example: ListAccessibleCustomers\n\nFor example, the [`customer_service.proto`](https://github.com/googleapis/googleapis/tree/master/google/ads/googleads/v21/services/customer_service.proto) file\ndefines a `ListAccessibleCustomers` method, in addition to the standard `Mutate`\n. Its [`google.api.http`](//google.aip.dev/127) annotation describes\nhow the method maps to HTTP. It uses an HTTP `GET` with the custom verb\n`listAccessibleCustomers`: \n\n```css+lasso\nrpc ListAccessibleCustomers(ListAccessibleCustomersRequest)\n returns (ListAccessibleCustomersResponse) {\n option (google.api.http) = {\n get: \"/v21/customers:listAccessibleCustomers\"\n };\n}\n```\n\nThis maps to the\n[customers.listAccessibleCustomers](/google-ads/api/reference/rpc/v21/CustomerService/ListAccessibleCustomers)\nREST method.\n\n### Example: CreateCustomerClient\n\nAnother example from [`customer_service.proto`](https://github.com/googleapis/googleapis/tree/master/google/ads/googleads/v21/services/customer_service.proto) is\nthe `CreateCustomerClient` method. Its `google.api.http` annotation describes an\nHTTP `POST` using the custom verb `createCustomerClient`: \n\n```css+lasso\nrpc CreateCustomerClient(CreateCustomerClientRequest)\n returns (CreateCustomerClientResponse) {\n option (google.api.http) = {\n post: \"/v21/customers/{customer_id=*}:createCustomerClient\"\n body: \"*\"\n };\n option (google.api.method_signature) = \"customer_id,customer_client\";\n}\n```\n\nThis maps to the [customers.createCustomerClient](/google-ads/api/reference/rpc/v21/CustomerService/CreateCustomerClient)\nREST method."]]