必備條件
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在開始設計第一個用戶端應用程式之前,您必須先做以下幾件事。
申請 Google 帳戶
您必須擁有 Google 帳戶,才能在 Google API 控制台中建立專案。如果您已經有帳戶,則您已準備好了。
您可能也想另外建立測試用的 Google 帳戶。
試用 Google AdMob
這份 API 說明文件假設您曾使用過 Google AdMob,且熟悉網頁程式設計概念和網站資料格式。
如果您還沒有使用過 Google AdMob,在開始編寫程式碼之前,請先試用使用者介面。
為用戶端建立專案
您必須先將用戶端相關資訊告知 Google,並啟用 API 存取權,才能傳送請求給 Google AdMob。如要註冊這項計畫,請使用 Google API 控制台建立「專案」(專案為具名的集合,內含設定和 API 存取資訊),並註冊應用程式。
如要開始使用 AdMob API,
使用
設定工具,會引導您在
Google API 控制台,啟用 API 並建立憑證。
瞭解 REST 的基本概念
REST 是一種軟體架構,可提供簡便且一致的資料要求及修改方法。
REST 這個詞是「Representational State Transfer (表現層狀態轉換)」的簡稱。在 Google API 中,這是指使用 HTTP 動詞來擷取及修改 Google 所儲存資料的表示法。
在符合 REST 樣式的系統中,資源會儲存在資料儲存庫中。用戶端向伺服器發出執行特定動作 (例如建立、擷取、更新或刪除資源) 的要求後,伺服器就會執行指定動作並傳回回應 (大多採用指定資源表示法的形式)。
在具備 REST 特性的各種 Google API 中,用戶端會使用 POST
、GET
、PUT
或 DELETE
等 HTTP 動詞來指定動作。接著,該動詞會透過全域唯一的 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
關於 API 中一共有哪些 URI 用於各項支援的操作,都已總結在 AdMob API 參考資料文件中。
瞭解 JSON 的基本概念
AdMob API 會以 JSON 格式傳回資料。
JSON (JavaScript Object Notation) 是一種不涉及語言的常用資料格式,可透過簡單的文字呈現多種資料結構。詳情請參閱 json.org。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間: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"]]