Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Versi terbaru Google Drive API adalah v3. Performa di v3 lebih baik karena
penelusuran hanya menampilkan subset kolom. Gunakan versi saat ini kecuali jika Anda memerlukan koleksi v2. Jika Anda menggunakan v2, pertimbangkan
untuk bermigrasi ke v3. Untuk bermigrasi, lihat Bermigrasi ke Drive API v3. Untuk daftar lengkap perbedaan versi, lihat
referensi perbandingan Drive API v2 dan v3.
Jika Anda ingin terus menggunakan v2, lihat amandemen Panduan Drive API v2 untuk mempelajari cara beberapa petunjuk dalam panduan v3 harus diubah untuk developer v2.
Untuk mempelajari lebih lanjut peningkatan Drive API v3, Anda dapat menonton video berikut yang dibuat oleh engineer Google yang membahas desain API baru.
Peningkatan V3
Untuk mengoptimalkan performa dan mengurangi kompleksitas perilaku API, v3 memberikan peningkatan berikut dibandingkan versi API sebelumnya:
Penelusuran file dan drive bersama tidak menampilkan resource lengkap secara default,
hanya subset kolom yang umum digunakan yang ditampilkan. Untuk mengetahui detail selengkapnya tentang
fields, lihat metode files.list
dan metode drives.list.
Hampir semua metode yang menampilkan respons kini memerlukan parameter fields. Untuk mengetahui daftar semua metode yang memerlukan fields, lihat
referensi Drive API.
Resource yang memiliki kemampuan duplikat telah dihapus. Beberapa contoh:
Metode files.list memiliki fungsi yang sama dengan koleksi
Children dan Parents, sehingga dihapus dari v3.
Metode Realtime.* telah dihapus.
Data Aplikasi tidak ditampilkan secara default dalam penelusuran. Di v2, Anda dapat menetapkan cakupan
drive.appdata, dan cakupan ini menampilkan data aplikasi dari metode files.list
dan metode changes.list, tetapi memperlambat performa. Di v3, Anda menetapkan cakupan drive.appdata,
dan juga menetapkan parameter kueri spaces=appDataFolder untuk meminta
data aplikasi.
Semua operasi update menggunakan PATCH, bukan PUT.
Untuk mengekspor Dokumen Google, gunakan metode
files.export.
Perilaku metode changes.list berbeda. Daripada mengubah ID, gunakan
token halaman buram. Untuk melakukan polling pada pengumpulan perubahan, panggil terlebih dahulu metode
changes.getStartPageToken
untuk nilai awal. Untuk kueri berikutnya, metode changes.list
menampilkan nilai newStartPageToken.
Metode update kini menolak permintaan yang menentukan kolom yang tidak dapat ditulis.
Kolom exportFormats dan importFormats v2 dalam
resource about adalah daftar
format impor atau ekspor yang diizinkan. Di v3, peta jenis MIME adalah peta target yang mungkin untuk semua impor atau ekspor yang didukung.
Alias appdata dan appfolder v2 kini menjadi appDataFolder di v3.
Resource properties dihapus dari v3. Resource
files memiliki kolom properties
yang berisi key-value pair sebenarnya. Kolom properties berisi properti publik, dan kolom appProperties berisi properti pribadi, sehingga kolom visibilitas tidak diperlukan.
Kolom modifiedTime di resource files memperbarui waktu terakhir kali seseorang mengubah file. Di v2, kolom modifiedDate hanya dapat diubah
saat update jika Anda menyetel kolom setModifiedDate.
Kolom viewedByMeTime di resource files tidak diperbarui secara otomatis.
Untuk mengimpor format Google Dokumen, Anda menetapkan mimeType target yang sesuai
di isi resource. Di v2, Anda menetapkan ?convert=true.
Operasi impor menampilkan error 400 jika format tidak didukung.
Pembaca dan pengomentar tidak dapat melihat izin.
Alias me untuk izin dihapus.
Beberapa fungsi tersedia sebagai bagian dari resource permintaan, tetapi
sebaliknya tersedia sebagai parameter permintaan. Misalnya:
Di v2, Anda dapat menggunakan children.delete untuk menghapus file turunan dari folder induk.
Di v3, Anda menggunakanfiles.update pada turunan dengan
?removeParents=parent_id di URL.
Perbedaan lainnya
Nama kolom dan parameter berbeda di v3. Contohnya antara lain:
Properti name menggantikan title dalam resource files.
Time adalah akhiran untuk semua kolom tanggal dan waktu, bukan Date.
Operasi daftar tidak menggunakan kolom items untuk berisi kumpulan hasil. Jenis
resource menyediakan kolom untuk hasil (seperti files atau
changes).
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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`)."]]