Google Drive API
Search, upload (simple, multipart, resumable), download and export Drive files, organize folders, share, sync changes and comment.
Productivity & workspaceGuided#storage#files#google-drive#google-workspace#uploads#oauth2
Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.
Overview
The Google Drive API lets an app work with a user's Google Drive: search and list files, upload (simple, multipart and resumable for large files), download content, export Google Docs, Sheets and Slides to PDF or Office formats, organize files in folders, share them with people or by link, work with shared drives, follow the changes feed for sync, and comment. This guided collection covers the calls most apps need first; the generated Drive listing on the Google page lists every endpoint (revisions, labels, replies, apps and more).
Get credentials, step by step
- Create or pick a project in the Google Cloud console.
- Enable the Google Drive API.
- Configure the OAuth consent screen in Google Auth Platform: External, publishing status Testing, and add your account as a test user.
- Create an OAuth client under Clients (Desktop app or Web application) and copy the ID and secret into the collection.
- Get a token with the OAuth 2.0 Playground or with folder 1 (sign-in URL, then code exchange).
Authentication and scopes
Every call sends Authorization: Bearer <access token>. Choosing the scope is the big decision:
drive.file(non-sensitive, recommended): per-file access to files your app creates or the user opens with it (for example via the Google Picker). Light verification.drive.readonly,drive.metadata.readonly,drive(restricted): access to all of the user's files. Public apps need verification and a security assessment, and are only approved for certain kinds of apps.
In Testing mode your test users can use any scope (refresh tokens expire after 7 days). To try every request here, including exporting and sharing files your app did not create, sign in with drive. See Choose Google Drive API scopes.
Base URLs
https://www.googleapis.com/drive/v3({{baseUrl}}): metadata, search, download (alt=media), export, permissions, changes.https://www.googleapis.com/upload/drive/v3({{uploadUrl}}): uploading file content.
Always pass fields: v3 returns only id, name, mimeType and kind by default, and about and comment requests fail without it.
How to use this collection
Fill the OAuth variables, get a token, set shareEmail, then run the folders in order. Folder 3 creates a folder and uploads three small files; later folders download, export, rename, move, copy, trash, share and comment on them, with IDs passed along by test scripts.
Limits
Drive meters requests per project and per user per minute; going over returns 403 userRateLimitExceeded / rateLimitExceeded or 429. There are also limits on uploads per day per user and on sharing. Retry with exponential backoff. Current values: Usage limits.
Common errors
| Status | Typical reason | What to do |
|---|---|---|
401 | Invalid Credentials / UNAUTHENTICATED: token missing, expired (about an hour) or revoked | Run Refresh the access token; if that returns invalid_grant, sign in again |
403 | insufficientPermissions / ACCESS_TOKEN_SCOPE_INSUFFICIENT: the token lacks the scope this request needs | Sign in again with the scope listed on the request; check with tokeninfo |
403 | accessNotConfigured / SERVICE_DISABLED: the API is not enabled in this Cloud project | Enable it in the API Library, wait a few minutes |
403 / 429 | rateLimitExceeded, userRateLimitExceeded, RESOURCE_EXHAUSTED: per-user or per-project quota | Back off exponentially and retry; spread work over time |
404 | notFound: wrong ID, or the item belongs to another user / was deleted | Re-run the list request that stores the ID |
400 | invalid / badRequest / INVALID_ARGUMENT: malformed body or parameter | Read error.message; it names the field |
403 | storageQuotaExceeded / teamDriveFileLimitExceeded: no space left | Free up storage |
404 | With drive.file: file not created or opened by your app | Use a broader scope or the Google Picker |
Links
Endpoints 29
1. Get an access token
- POSTExchange the authorization code for tokens
https://oauth2.googleapis.com/tokenSwaps the one-time code from the browser redirect for an access token (about an hour) and a refresh token (long-lived; 7 days while the app is in Testing).… - POSTRefresh the access token
https://oauth2.googleapis.com/tokenGets a fresh access token from the stored refresh token, without the user signing in again. When: whenever a call returns 401 (access tokens last about an… - GETCheck which scopes the token has (tokeninfo)
https://oauth2.googleapis.com/tokeninfoAsks Google what the current access token is good for: the granted scope list, the client it belongs to (aud/azp) and the seconds left (expires_in). When: a…
2. Account and finding files
- GETGet user and storage info (about)
/aboutReturns the signed-in user, their storage quota and what the Drive supports (import/export formats, maximum upload size). When: right after sign-in, to show… - GETList files (q search and fields)
/filesLists and searches files the token can see. When: browsing folders, finding a file by name or type, building a file picker. Scope: drive.readonly,… - GETFind Google Docs and Sheets
/filesSearches for native Google Docs and Sheets (which can only be exported, not downloaded directly) and stores the first of each for folder 4. When: before… - GETGet file metadata
/files/{{fileId}}Fetches one file's metadata (not its content). When: checking a file's name, type, size, parents, owners or sharing links. Uses {{fileId}} (set by the upload…
3. Upload and create
- POSTCreate a folder
/filesCreates a folder: a file with no content and the folder MIME type. When: before uploading, to keep your app's files together. Scope: drive.file or drive. What… - POSTSimple upload (content only)
{{uploadUrl}}/filesUploads file content without metadata. The new file lands in the root of My Drive, named "Untitled". When: quick uploads of small files (5 MB or less) where… - POSTMultipart upload (name, folder and content)
{{uploadUrl}}/filesUploads a file with its metadata in one request: named inventory.txt, inside {{folderId}}. When: most uploads of 5 MB or less. Scope: drive.file or drive.… - POSTResumable upload: start a session
{{uploadUrl}}/filesStarts a resumable upload session. No file content is sent yet: you send the metadata and get back a session URI in the Location response header. When: files… - PUTResumable upload: send the file
{{resumableUri}}Sends the file content to the session URI from the previous request. When: right after starting the session (uses {{resumableUri}}). Scope: the token that… - PUTCheck a resumable upload (resume after a failure)
{{resumableUri}}Asks the server how much of a resumable upload it has received. When: an upload request failed or timed out part-way. Request: an empty PUT to the session URI…
4. Download and export
- GETDownload a file (alt=media)
/files/{{fileId}}Downloads the content of a binary file; here the inventory.txt uploaded in folder 3. When: reading or saving a file's bytes. Scope: drive.readonly or drive,… - GETExport a Google Doc to PDF
/files/{{googleDocId}}/exportConverts a Google Doc to PDF and returns the PDF bytes. When: archiving, emailing or printing a Doc. Uses {{googleDocId}} from Find Google Docs and Sheets.… - GETExport a Google Sheet to Excel
/files/{{googleSheetId}}/exportConverts a Google Sheet to an Excel .xlsx workbook. When: handing spreadsheet data to tools that need Excel files. Uses {{googleSheetId}}. Scope:…
5. Rename, move, copy and delete
- PATCHRename a file (update metadata)
/files/{{simpleFileId}}Changes a file's name and description; here the "Untitled" file from Simple upload. When: renaming, editing the description, starring ("starred": true),… - PATCHMove a file to another folder
/files/{{simpleFileId}}Moves the renamed file from its current folder ({{parentId}}, stored by Simple upload) into {{folderId}}. When: organizing files. Scope: drive.file or drive.… - POSTCopy a file
/files/{{fileId}}/copyMakes a copy of a file, optionally with a new name and parent. When: templates (copy a Doc and fill it), backups. Google Docs/Sheets copies stay Google files.… - PATCHMove a file to the trash
/files/{{copyId}}Puts the copy in the trash by setting trashed to true. The user can restore it from the Drive trash (or you can, with "trashed": false) for 30 days. When: the… - DELETEDelete a file permanently
/files/{{copyId}}Deletes a file at once, without the trash. For a folder, everything inside that the user owns is deleted too. When: cleaning up temporary files your app…
6. Sharing (permissions)
- POSTShare with a person
/files/{{fileId}}/permissionsGives one person access to a file and emails them. When: sharing a document with a colleague or customer. Scope: drive.file or drive. What comes back: the… - POSTShare with anyone who has the link
/files/{{fileId}}/permissionsMakes a file readable by anyone with its link (no sign-in needed). When: public downloads, sharing outside your organization. Workspace admins can block this;… - GETList who has access
/files/{{fileId}}/permissionsLists the permissions on a file: owner, people, groups, domain and link sharing. When: showing a sharing dialog, auditing access. Scope: any scope that can…
7. Shared drives, changes and comments
- GETList shared drives
/drivesLists the shared drives the user is a member of. When: letting users pick a shared drive; shared drives exist only in Google Workspace accounts (the list is… - GETGet the start page token (changes)
/changes/startPageTokenReturns a token that marks "now" in the user's change history. When: once, when your app starts syncing; store it per user. Scope: any Drive scope. Params:… - GETList changes since the token
/changesReturns the files that changed (created, edited, trashed, removed, shared) since {{startPageToken}}. Make a change in Drive between the two requests to see… - POSTAdd a comment to a file
/files/{{fileId}}/commentsAdds a comment to a file, visible in the Drive or Docs comment panel. When: review workflows, leaving notes on uploaded files. Scope: drive.file or drive.… - GETList comments on a file
/files/{{fileId}}/commentsLists the comments (and their replies) on a file. When: showing discussion next to a file, or collecting review feedback. Scope: drive.readonly, drive.file or…
API details
- Base URL
https://www.googleapis.com/drive/v3https://www.googleapis.com/upload/drive/v3https://oauth2.googleapis.com- Authentication
- A bearer token in the Authorization header
OAuth 2.0 (authorization code flow) - Operations
- 29 operations on 29 pathsGET 13POST 10PATCH 3PUT 2DELETE 1
- Main resources
- 1. Get an access token 32. Account and finding files 43. Upload and create 64. Download and export 35. Rename, move, copy and delete 56. Sharing (permissions) 37. Shared drives, changes and comments 5
- Description format
- Swastik Codes guided collection, API version
checked against the docs on 2026-11-17 - Links
- Documentation
How to test the Google Drive API in Swastik Codes
- Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
- Fork it into your workspaceChoose a workspace. You get your own copy of the Google Drive API collection, without the publisher's secrets.
- Add your credentialsThis API uses A bearer token in the Authorization header. Add yours in the collection's variables or an environment; the requests already reference it.
- Send a requestPick an endpoint, for example “Exchange the authorization code for tokens” (POST https://oauth2.googleapis.com/token), and press Send. Check the response, add tests and run the whole collection with the runner.
Frequently asked questions
What is the Google Drive API?
Search, upload (simple, multipart, resumable), download and export Drive files, organize folders, share, sync changes and comment. It is listed under Productivity & workspace and has 29 endpoints.
Who publishes the Google Drive API?
It is listed from Google's public API description (an OpenAPI document), not published by Google on Swastik Codes. Anyone who controls googleapis.com can claim the profile by adding a DNS TXT record.
What is the base URL of the Google Drive API?
Its description lists 3 base URLs: https://www.googleapis.com/drive/v3, https://www.googleapis.com/upload/drive/v3, https://oauth2.googleapis.com. The first is the usual one; the others are typically sandbox or regional servers.
How do I authenticate with the Google Drive API?
It accepts 2 methods: A bearer token in the Authorization header; OAuth 2.0 (authorization code flow).
How many endpoints does the Google Drive API have?
29 operations on 29 paths (13 GET, 10 POST, 3 PATCH, 2 PUT, 1 DELETE). The largest groups are 1. Get an access token, 2. Account and finding files, 3. Upload and create, 4. Download and export.
Is forking the Google Drive API free?
Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.