Google Document API 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以使用 Google 文件 API 建立及修改 Google 文件。
應用程式可以整合文件 API,根據使用者和系統提供的資料建立精美文件。透過 Docs API,您可以:
- 自動化程序
- 大量建立文件
- 設定文件格式
- 產生應付憑據或合約
- 擷取物件的特定屬性
以下列出 Google Docs API 中常用的術語:
- 文件 ID
文件的專屬 ID。這是一組特定字串,包含字母、數字和部分特殊字元,可參照文件,並可從文件網址衍生而來。即使文件名稱變更,文件 ID 也不會變動。如要進一步瞭解如何尋找 ID,請參閱「文件 ID」。
https://docs.google.com/document/d/DOCUMENT_ID/edit
- 元素
組成文件的結構。文件的頂層元素包括 Body
、DocumentStyle
和 List
。
- Google Workspace 文件
Google 文件等 Google Workspace 應用程式建立的檔案。
文件的 MIME 類型格式為 application/vnd.google-apps.document
。如需 MIME 類型清單,請參閱「
Google Workspace 和 Google 雲端硬碟支援的 MIME 類型」。
- 索引
內容主體中的大多數元素都具有 startIndex
和 endIndex
屬性。這些屬性表示元素開始和結束的偏移量,相對於封閉 區段的開頭。
- 內嵌圖片
顯示在文件內文中的圖片。這不是附件。
- 已命名範圍
連續的文字範圍。NamedRange
是具有相同 namedRangeId
的一系列範圍。開發人員可以透過具名範圍,將文件部分內容與任意使用者定義的標籤建立關聯,以便日後透過程式輔助方式讀取或編輯內容。文件可以包含多個同名的已命名範圍,但每個已命名範圍都有專屬 ID。
- 區隔
包含結構或內容元素的 Body
、Header
、Footer
或 Footnote
。區隔中元素的索引是相對於該區隔的開頭。
- 建議
你可以在不變更原始文字的情況下,在文件中提出修訂建議。建議內容若獲得擁有者核准,就會取代原始文字。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Google Docs API overview\n\nThe Google Docs API lets you create and modify documents in Google Docs.\n\nApplications can integrate with the Docs API to create polished\ndocuments from both user and system-provided data. The Docs API lets\nyou:\n\n- Automate processes\n- Create documentation in bulk\n- Format documents\n- Generate invoices or contracts\n- Retrieve specific attributes of objects\n\nThe following is a list of common terms used in the Docs API:\n\n*Document ID*\n\n: The unique identifier for a document. It's a particular string containing\n letters, numbers, and some special characters that reference a document and\n it can be derived from the document's URL. Document IDs are stable, even if\n the document name changes. For more information on how to find the ID, see\n [Document ID](/workspace/docs/api/concepts/document#document-id).\n\n https://docs.google.com/document/d/\u003cvar translate=\"no\"\u003eDOCUMENT_ID\u003c/var\u003e/edit\n\n*Element*\n\n: The structure that makes up a document. Top-level elements of a document\n include the [`Body`](/workspace/docs/api/reference/rest/v1/documents#body),\n [`DocumentStyle`](/workspace/docs/api/reference/rest/v1/documents#documentstyle), and\n [`List`](/workspace/docs/api/reference/rest/v1/documents#list).\n\n*Google Workspace document*\n\n: A file that a Google Workspace application, like Google Docs, creates.\n The MIME type format for Docs is\n `application/vnd.google-apps.document`. For a list of MIME types, see [Google Workspace and Google Drive supported MIME types](/drive/api/guides/mime-types).\n\n*Index*\n\n: Most *elements* within the content body have the `startIndex` and `endIndex`\n properties. These indicate the offset of an element's beginning and end,\n relative to the beginning of its enclosing *segment*.\n\n*Inline image*\n\n: An image that appears in the flow of text within a document. It's not an\n attachment.\n\n*Named range*\n\n: A contiguous range of text. A\n [`NamedRange`](/workspace/docs/api/reference/rest/v1/documents#namedrange) is a\n collection of ranges with the same `namedRangeId`. Named ranges allow\n developers to associate parts of a document with an arbitrary user-defined\n label so their contents can be programmatically read or edited later. A\n document can contain multiple named ranges with the same name, but every\n named range has a unique ID.\n\n*Segment*\n\n: The `Body`, [`Header`](/workspace/docs/api/reference/rest/v1/documents#header),\n [`Footer`](/workspace/docs/api/reference/rest/v1/documents#footer), or\n [`Footnote`](/workspace/docs/api/reference/rest/v1/documents#footnote) containing\n structural or content *elements* . The *indexes* of the elements within a\n segment are relative to the beginning of that segment.\n\n*Suggestion*\n\n: Changes to a document without changing the original text. If the owner\n approves your suggestions, they replace the original text.\n\nRelated topics\n--------------\n\n- To learn about developing with Google Workspace APIs, including handling\n authentication and authorization, refer to [Develop on\n Google Workspace](/workspace/guides/get-started).\n\n- To get a conceptual overview of a document, see\n [Document](/workspace/docs/api/concepts/document).\n\n- To learn how to configure and run a Docs API app, try the\n [JavaScript quickstart](/workspace/docs/api/quickstart/js)."]]