Google ドキュメント API の概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Google Docs API を使用すると、Google ドキュメントでドキュメントを作成、変更できます。
アプリケーションは Docs API と統合して、ユーザーとシステムの両方から提供されたデータから洗練されたドキュメントを作成できます。Docs API を使用すると、次のことができます。
- 処理の自動化
- ドキュメントを一括で作成する
- ドキュメントの書式を設定する
- 請求書または契約書を生成する
- オブジェクトの特定の属性を取得する
Docs API で使用される一般的な用語を以下に示します。
- ドキュメント ID
ドキュメントの一意の識別子。ドキュメントを参照する文字、数字、一部の特殊文字を含む特定の文字列で、ドキュメントの URL から導出できます。ドキュメント 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 タイプをご覧ください。
- Index
コンテンツ本文内のほとんどの要素には、startIndex
プロパティと endIndex
プロパティがあります。これらは、要素の開始と終了のオフセットを、囲んでいる セグメントの開始に対する相対値で示します。
- インライン画像
ドキュメント内のテキストのフローに表示される画像。添付ファイルではありません。
- 名前付き範囲
連続したテキストの範囲。NamedRange
は、同じ namedRangeId
を持つ範囲のコレクションです。名前付き範囲を使用すると、ドキュメントの一部を任意のユーザー定義ラベルに関連付けることができます。これにより、後でその内容をプログラムで読み取ったり編集したりできます。ドキュメントには同じ名前の複数の名前付き範囲を含めることができますが、すべての名前付き範囲には一意の ID があります。
- セグメント
構造要素またはコンテンツ要素を含む Body
、Header
、Footer
、または Footnote
。セグメント内の要素のインデックスは、そのセグメントの先頭を基準としています。
- 候補
ドキュメントの元のテキストを変更せずに、変更を提案することができます。提案内容をオーナーが承認すると、元のテキストが置き換えられます。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[],[],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)."]]