前提条件
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在开始编写您的首个客户端应用之前,您需要做一些准备工作(如果您还没有做的话)。
获取 Google 账号
您需要拥有一个 Google 账号才能在 Google API 控制台中创建项目。如果您已经具有账号,则您已准备就绪。
您可能还需要一个单独的 Google 账号进行测试。
试用 Google AdMob
本 API 文档假定您使用过 Google AdMob,并且您熟悉网络编程概念和网络数据格式。
如果您尚未使用过 Google AdMob,请在开始编码前,试用一下界面。
为客户端创建一个项目
在向 Google AdMob 发送请求之前,您需要先将客户端的相关信息告知 Google,并激活 API 的访问权限。为此,您可以使用 Google API 控制台创建一个项目(项目是设置和 API 访问信息的指定集合),然后注册您的应用。
要开始使用 AdMob API,您首先需要
设置工具,它会引导您在
Google API 控制台、启用 API 并创建凭据。
了解 REST 基础知识
REST 是一种软件架构样式,可提供便利、一致的方法来请求和修改数据。
术语 REST 是“具象状态传输”的简称。在 Google API 的上下文中,指的是使用 HTTP 谓词来检索和修改由 Google 存储的数据的表示法。
在 RESTful 系统中,资源存储在数据存储区中;在客户端发送要求服务器执行特定操作(例如创建、检索、更新或删除资源)的请求之后,服务器便会执行该操作并发送响应,此响应的格式通常为所指定资源的表示法。
在 Google 的 RESTful API 中,客户端使用 HTTP 谓词(例如 POST
、GET
、PUT
或 DELETE
)指定操作。它通过以下格式的全局唯一 URI 来指定资源:
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
由于所有 API 资源都具有 HTTP 可访问的唯一 URI,因此 REST 启用了数据缓存,而且经过优化以与网络的分布式基础架构一起使用。
您可能会发现 HTTP 1.1 标准文档中的方法定义十分有用;这些定义中包含了 GET
、POST
、PUT
和 DELETE
的规范。
AdMob API 中的 REST
AdMob API 操作会直接映射到 REST HTTP 动词。
AdMob API URI 的具体格式为:
https://admob.googleapis.com/v1/resourcePath?parameters
AdMob API 参考文档总结了用于 API 中各项受支持操作的全部 URI。
了解 JSON 基础知识
AdMob API 以 JSON 格式返回数据。
JSON(JavaScript 对象表示法)是一种与语言无关的常见数据格式,可通过简单的文本来表示任意数据结构。如需了解详情,请参阅 json.org。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eBefore coding, you need a Google Account (potentially a separate one for testing) and familiarity with Google AdMob.\u003c/p\u003e\n"],["\u003cp\u003eYou must create a project in the Google API Console using the provided setup tool to enable API access for your client application.\u003c/p\u003e\n"],["\u003cp\u003eThe AdMob API utilizes RESTful architecture, meaning you should understand basic REST principles and HTTP verbs for interacting with resources.\u003c/p\u003e\n"],["\u003cp\u003eData is exchanged in JSON format, so familiarity with JSON structure and parsing is beneficial.\u003c/p\u003e\n"]]],[],null,["# Prerequisites\n\nBefore you can start coding your first client application, there are a few\nthings you need to do, if you haven't done them already.\n\nGet a Google Account\n--------------------\n\nYou need a [Google Account](https://www.google.com/accounts/NewAccount) in order to [create a project](#project) in the Google API Console. If you already have an account, then you're all set.\n\nYou might also want a separate Google Account for testing purposes.\n\nTry out Google AdMob\n--------------------\n\nThis API documentation assumes that you've used Google AdMob, and that you're familiar with web programming concepts and web data formats.\n\nIf you haven't used Google AdMob, then try out the [user interface](https://admob.google.com) before starting to code.\n\nCreate a project for your client\n--------------------------------\n\nBefore you can send requests to Google AdMob, you need to tell Google about your client and activate access to the API. You do this by using the Google API Console to create a project, which is a named collection of settings and API access information, and register your application.\n\nTo get started using AdMob API, you need to first\n[use\nthe setup tool](https://console.cloud.google.com/start/api?id=admob.googleapis.com&credential=client_key), which guides you through creating a project in the\nGoogle API Console, enabling the API, and creating credentials.\n\nLearn REST basics\n-----------------\n\nREST is a style of software architecture that provides a convenient and consistent approach to requesting and modifying data.\n\nThe term REST is short for \"[Representational State Transfer](https://en.wikipedia.org/wiki/Representational_state_transfer).\" In the context of Google APIs, it refers to using HTTP verbs to retrieve and modify representations of data stored by Google.\n\nIn a RESTful system, resources are stored in a data store; a client sends a request that the server perform a particular action (such as creating, retrieving, updating, or deleting a resource), and the server performs the action and sends a response, often in the form of a representation of the specified resource.\n\nIn Google's RESTful APIs, the client specifies an action using an HTTP verb such as `POST`, `GET`, `PUT`, or `DELETE`. It specifies a resource by a globally-unique URI of the following form: \n\n```\nhttps://www.googleapis.com/apiName/apiVersion/resourcePath?parameters\n```\n\nBecause all API resources have unique HTTP-accessible URIs, REST enables data caching and is optimized to work with the web's distributed infrastructure.\n\nYou may find the [method definitions](https://tools.ietf.org/html/rfc7231#section-4.3) in the HTTP 1.1 standards documentation useful; they include specifications for `GET`, `POST`, `PUT`, and `DELETE`.\n\n### REST in the AdMob API\n\nThe AdMob API operations map directly to REST HTTP verbs.\n\nThe specific formats for AdMob API URIs are: \n\n```\nhttps://admob.googleapis.com/v1/resourcePath?parameters\n```\n\nThe full set of URIs used for each supported operation in the API is summarized in the [AdMob API Reference](/admob/api/v1/reference/rest) document.\n\nLearn JSON basics\n-----------------\n\nThe AdMob API returns data in JSON format.\n\n\n[JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information, see [json.org](http://www.json.org/).\n\n\u003cbr /\u003e"]]