Drive API v2 と v3 の比較ガイド
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
最新の Google Drive API バージョンは v3 です。v3 では、検索で返されるのはフィールドのサブセットのみであるため、パフォーマンスが向上しています。v2 コレクションが必要な場合を除き、現在のバージョンを使用します。v2 を使用している場合は、v3 への移行を検討してください。移行するには、Drive API v3 への移行をご覧ください。バージョンの違いの完全なリストについては、Drive API v2 と v3 の比較リファレンスをご覧ください。
v2 を引き続き使用する場合は、Drive API v2 のガイドの修正版を参照してください。v3 ガイドの一部の手順を v2 デベロッパー向けに修正する方法が記載されています。
Drive API v3 の改善点について詳しくは、Google のエンジニアが新しい API 設計について説明している次の動画をご覧ください。
V3 の改善
パフォーマンスを最適化し、API 動作の複雑さを軽減するため、v3 では以前の API バージョンに対して次の改善が行われています。
- ファイルと共有ドライブの検索では、デフォルトで完全なリソースは返されず、一般的に使用されるフィールドのサブセットのみが返されます。
fields
の詳細については、files.list
メソッドと drives.list
メソッドをご覧ください。
- レスポンスを返すほとんどのメソッドで、
fields
パラメータが必要になりました。fields
が必要なすべてのメソッドの一覧については、
Drive API リファレンスをご覧ください。
- 重複する機能を持つリソースが削除されました。例:
files.list
メソッドは Children
コレクションと Parents
コレクションと同じ機能を果たすため、v3 から削除されました。
Realtime.*
メソッドを削除しました。
- デフォルトでは、アプリデータは検索結果に表示されません。v2 では、
drive.appdata
スコープを設定でき、files.list
メソッドと changes.list
メソッドからアプリケーション データが返されますが、パフォーマンスが低下します。v3 では、drive.appdata
スコープを設定し、クエリ パラメータ spaces=appDataFolder
を設定してアプリケーション データをリクエストします。
- すべての更新オペレーションで PUT ではなく PATCH を使用します。
- Google ドキュメントをエクスポートするには、
files.export
メソッドを使用します。
changes.list
メソッドの動作は異なります。変更 ID の代わりに、不透明なページトークンを使用します。変更コレクションをポーリングするには、まず changes.getStartPageToken
メソッドを呼び出して初期値を取得します。後続のクエリでは、changes.list
メソッドは newStartPageToken
値を返します。
- 更新メソッドが、書き込み不可のフィールドを指定するリクエストを拒否するようになりました。
about
リソースの v2 exportFormats
フィールドと importFormats
フィールドは、許可されるインポートまたはエクスポート形式のリストです。v3 では、可能なターゲットとサポートされているすべてのインポートまたはエクスポートの MIME タイプのマップです。
- v2 の
appdata
エイリアスと appfolder
エイリアスは、v3 では appDataFolder
になりました。
properties
リソースは v3 から削除されます。files
リソースには、true の Key-Value ペアを含む properties
フィールドがあります。properties
フィールドには公開プロパティが含まれ、appProperties
フィールドには非公開プロパティが含まれるため、可視性フィールドは必要ありません。
files
リソースの modifiedTime
フィールドは、ファイルが最後に変更された日時を更新します。v2 では、setModifiedDate
フィールドを設定した場合にのみ、更新時に modifiedDate
フィールドを変更できました。
files
リソースの viewedByMeTime
フィールドは自動的に更新されません。
- Google ドキュメントの形式をインポートするには、リソース本文で適切なターゲット
mimeType
を設定します。v2 では、?convert=true
を設定します。
- 形式がサポートされていない場合、インポート オペレーションは 400 エラーを返します。
- 閲覧者とコメント投稿者は権限を表示できません。
- 権限の
me
エイリアスが削除されました。
- 一部の機能はリクエスト リソースの一部として利用可能でしたが、リクエスト パラメータとして利用可能になりました。例:
- v2 では、
children.delete
を使用して、親フォルダから子ファイルを削除できます。
- v3 では、URL に
?removeParents=parent_id
を含む子に files.update
を使用します。
その他の相違点
v3 では、フィールド名とパラメータ名が異なります。以下にいくつか例を示します。
name
プロパティは、files
リソースの title
に代わるものです。
Time
は、Date
ではなく、すべての日付と時刻のフィールドの接尾辞です。
- リスト オペレーションでは、結果セットを格納するために
items
フィールドを使用しません。リソースタイプには、結果のフィールド(files
や changes
など)が用意されています。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[],[],null,["# Drive API v2 and v3 comparison guide\n\nThe latest Google Drive API version is v3. The performance in v3 is better because\nsearches only return a subset of fields. Use the current version unless you need\nthe [v2](/workspace/drive/api/v2/reference) collection. If you're using v2, consider\nmigrating to v3. To migrate, see [Migrate to Drive API v3](/workspace/drive/api/guides/migrate-to-v3). For a complete list of version differences, see\nthe [Drive API v2 and v3 comparison\nreference](/workspace/drive/api/guides/v2-to-v3-reference).\n\nIf you want to continue to use v2, see the [Guide to Drive API v2](/workspace/drive/api/guides/v2-guide) amendment to learn how some instructions in the v3\nguides must be amended for v2 developers.\n\nTo learn more about Drive API v3 improvements, you can watch the\nfollowing video by Google engineers discussing the new API design. \n\nV3 improvements\n---------------\n\nTo optimize performance and reduce API behavior complexity, v3 provides these\nimprovements over the previous API version:\n\n- Searches for files and shared drives don't return full resources by default, only a subset of commonly used fields gets returned. For more details on `fields`, see the [`files.list`](/workspace/drive/api/v3/reference/files/list) method and the [`drives.list`](/workspace/drive/api/v3/reference/drives/list) method.\n- Almost all methods that return a response now require the `fields` parameter. For a list of all methods requiring `fields`, see the [Drive API reference](/workspace/drive/api/v3/reference).\n- Resources that have duplicate capabilities were removed. Some examples:\n - The `files.list` method accomplishes the same functionality as the `Children` and `Parents` collections, so they're removed from v3.\n - The `Realtime.*` methods have been removed.\n- App Data isn't returned by default in searches. In v2, you can set the `drive.appdata` scope, and it returns application data from the `files.list` method and the [`changes.list`](/workspace/drive/api/v2/reference/changes/list) method, but it slows performance. In v3, you set the `drive.appdata` scope, and also set the query parameter `spaces=appDataFolder` to request application data.\n- All update operations use PATCH instead of PUT.\n- To export Google Documents, use the [`files.export`](/workspace/drive/api/v2/reference/files/export) method.\n- The `changes.list` method behavior is different. Instead of change IDs, use opaque page tokens. To poll the change collection, first call the [`changes.getStartPageToken`](/workspace/drive/api/v2/reference/changes/getStartPageToken) method for the initial value. For subsequent queries, the `changes.list` method returns the `newStartPageToken` value.\n- Update methods now reject requests that specify non-writable fields.\n- The v2 `exportFormats` and `importFormats` fields in the [`about`](/workspace/drive/api/reference/rest/v3/about) resource are lists of allowable import or export formats. In v3, they're MIME type maps of possible targets to all supported imports or exports.\n- The v2 `appdata` and `appfolder` aliases are now `appDataFolder` in v3.\n- The `properties` resource is removed from v3. The [`files`](/workspace/drive/api/v3/reference/files) resource has the `properties` field that contains true key-value pairs. The `properties` field contains public properties, and the `appProperties` field contains private properties, so the visibility field isn't needed.\n- The `modifiedTime` field in the `files` resource updates the last time anyone modified the file. In v2, the `modifiedDate` field was only mutable on update if you set the `setModifiedDate` field.\n- The `viewedByMeTime` field in the `files` resource doesn't automatically update.\n- To import Google Docs formats, you set the appropriate target `mimeType` in the resource body. In v2, you set `?convert=true`.\n- Import operations return a 400 error if the format isn't supported.\n- Readers and commenters can't view permissions.\n- The `me` alias for permissions is removed.\n- Some functionality was available as part of the request resource but is instead available as a request parameter. For example:\n - In v2, you can use `children.delete` to remove a child file from a parent folder.\n - In v3, you use`files.update` on the child with `?removeParents=parent_id` in the URL.\n\nOther differences\n-----------------\n\nFields and parameter names are different in v3. Some examples include:\n\n- The `name` property replaces `title` in the `files` resource.\n- `Time` is the suffix for all date and time fields instead of `Date`.\n- List operations don't use the `items` field to contain the result set. The resource type provides a field for the results (such as `files` or `changes`)."]]