Clojure wrapper for the Google Drive API (v3).
Provides idiomatic Clojure functions for managing files, permissions, comments, replies, revisions, and changes in Google Drive.
Auth: use csl/scoped-delegated-credentials or csl/user-credentials with the appropriate scope:
All list functions return {:data [...] :next-page-token "..."}; the caller is responsible for pagination by passing :page-token from one call to the next. :next-page-token is absent when there are no further pages.
All functions return {:data ...} on success or {:error ...} on failure.
Clojure wrapper for the Google Drive API (v3).
Provides idiomatic Clojure functions for managing files, permissions,
comments, replies, revisions, and changes in Google Drive.
Auth: use csl/scoped-delegated-credentials or csl/user-credentials with
the appropriate scope:
- DriveScopes/DRIVE (full access)
- DriveScopes/DRIVE_FILE (files created/opened by the app)
- DriveScopes/DRIVE_READONLY (read-only access)
- DriveScopes/DRIVE_METADATA (metadata only)
- DriveScopes/DRIVE_METADATA_READONLY (metadata read-only)
- DriveScopes/DRIVE_APPS_READONLY (list-apps only — not covered by any
other Drive scope; carved out separately
by Google)
All list functions return {:data [...] :next-page-token "..."}; the caller
is responsible for pagination by passing :page-token from one call to the next.
:next-page-token is absent when there are no further pages.
All functions return {:data ...} on success or {:error ...} on failure.(copy-file client file-id metadata & [opts])Create a copy of a file.
file-id — ID of the file to copy metadata — map of properties for the copy (e.g. {:name "Copy of report"})
opts:
Create a copy of a file.
file-id — ID of the file to copy
metadata — map of properties for the copy (e.g. {:name "Copy of report"})
opts:
- :fields — partial response field mask string
- :ignore-default-visibility — boolean
- :supports-all-drives — boolean (default false)(create-comment client file-id comment-data & [opts])Create a comment on a file.
comment-data — map with kebab-case keys. Required key: :content — the text of the comment
Create a comment on a file. comment-data — map with kebab-case keys. Required key: :content — the text of the comment
(create-file client metadata & [opts])Create a new file. For metadata-only creation (e.g. folders), pass only metadata. For upload, also pass :content in opts.
metadata — map of file properties with kebab-case keys: :name — file name :mime-type — MIME type ("application/vnd.google-apps.folder" for folders) :parents — vector of parent folder IDs
opts:
Create a new file. For metadata-only creation (e.g. folders), pass only metadata.
For upload, also pass :content in opts.
metadata — map of file properties with kebab-case keys:
:name — file name
:mime-type — MIME type ("application/vnd.google-apps.folder" for folders)
:parents — vector of parent folder IDs
opts:
- :content — file content: java.io.File, InputStream, byte[], or String
- :mime-type — MIME type of the content (required for InputStream/byte[],
defaults for File and String)
- :fields — partial response field mask string
- :supports-all-drives — boolean (default false)(create-permission client file-id permission & [opts])Create a permission on a file (share a file).
permission — map with kebab-case keys: :type — :user, :group, :domain, or :anyone :role — :owner, :organizer, :file-organizer, :writer, :commenter, or :reader :email-address — email (required for :user and :group types) :domain — domain (required for :domain type)
opts:
Create a permission on a file (share a file).
permission — map with kebab-case keys:
:type — :user, :group, :domain, or :anyone
:role — :owner, :organizer, :file-organizer, :writer,
:commenter, or :reader
:email-address — email (required for :user and :group types)
:domain — domain (required for :domain type)
opts:
- :send-notification-email — boolean (default true for user/group)
- :email-message — custom notification email message
- :transfer-ownership — boolean (default false)
- :fields — partial response field mask string
- :supports-all-drives — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
administrator (caller must hold the Workspace
admin role; combine with :supports-all-drives
true for effect on Shared Drives)(create-reply client file-id comment-id reply-data & [opts])Create a reply to a comment.
reply-data — map with kebab-case keys. Required key: :content — the text of the reply
Create a reply to a comment. reply-data — map with kebab-case keys. Required key: :content — the text of the reply
(delete-comment client file-id comment-id & [opts])Delete a comment.
Delete a comment.
(delete-file client file-id & [opts])Permanently delete a file. Does not move to trash. Use (update-file client file-id {:trashed true}) to trash instead.
opts:
Permanently delete a file. Does not move to trash.
Use (update-file client file-id {:trashed true}) to trash instead.
opts:
- :supports-all-drives — boolean (default false)(delete-permission client file-id permission-id & [opts])Remove a permission from a file (unshare).
opts:
Remove a permission from a file (unshare).
opts:
- :supports-all-drives — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
administrator (caller must hold the Workspace
admin role; combine with :supports-all-drives
true for effect on Shared Drives)(delete-reply client file-id comment-id reply-id & [opts])Delete a reply.
Delete a reply.
(delete-revision client file-id revision-id & [opts])Delete a revision. Only applicable to files with binary content in Drive.
Delete a revision. Only applicable to files with binary content in Drive.
(download-file client file-id & [opts])Download a file's content as an InputStream. Works for binary files — use export-file for Google Workspace documents (Docs, Sheets, Slides).
The caller is responsible for closing the InputStream.
opts:
Download a file's content as an InputStream. Works for binary files — use export-file for Google Workspace documents (Docs, Sheets, Slides). The caller is responsible for closing the InputStream. opts: - :acknowledge-abuse — boolean, acknowledge risk of downloading known malware
(drive-client credentials)(drive-client credentials opts)Build an authenticated Drive v3 REST client.
credentials — a com.google.auth.oauth2.GoogleCredentials instance, typically from csl/scoped-delegated-credentials or csl/user-credentials.
opts (optional):
Per-request opts on individual call sites override the client-level defaults.
Build an authenticated Drive v3 REST client. credentials — a com.google.auth.oauth2.GoogleCredentials instance, typically from csl/scoped-delegated-credentials or csl/user-credentials. opts (optional): - :read-timeout-ms per-client default read timeout (default 120000 / 120s) - :connect-timeout-ms per-client default connect timeout (default 30000 / 30s) Per-request opts on individual call sites override the client-level defaults.
(empty-trash client & [opts])Permanently delete all trashed files.
Permanently delete all trashed files.
(export-file client file-id mime-type & [opts])Export a Google Workspace document to the given MIME type as an InputStream.
The caller is responsible for closing the InputStream.
Common export MIME types:
Export a Google Workspace document to the given MIME type as an InputStream. The caller is responsible for closing the InputStream. Common export MIME types: - "application/pdf" - "text/plain" - "text/csv" - "application/vnd.openxmlformats-officedocument.wordprocessingml.document" - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
(get-about client & [opts])Get information about the user, the user's Drive, and system capabilities.
The Drive API requires a fields parameter — this function defaults to "*" (all fields). Pass :fields to request specific fields.
opts:
Get information about the user, the user's Drive, and system capabilities. The Drive API requires a fields parameter — this function defaults to "*" (all fields). Pass :fields to request specific fields. opts: - :fields — partial response field mask string (default "*")
(get-comment client file-id comment-id & [opts])Get a comment by ID.
opts:
Get a comment by ID. opts: - :fields — partial response field mask string - :include-deleted — boolean (default false)
(get-file client file-id & [opts])Get a file's metadata by ID.
opts:
Get a file's metadata by ID. opts: - :fields — partial response field mask string - :acknowledge-abuse — boolean, acknowledge risk of downloading known malware - :supports-all-drives — boolean (default false)
(get-permission client file-id permission-id & [opts])Get a permission by ID.
opts:
Get a permission by ID.
opts:
- :fields — partial response field mask string
- :supports-all-drives — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
administrator (caller must hold the Workspace
admin role; combine with :supports-all-drives
true for effect on Shared Drives)(get-reply client file-id comment-id reply-id & [opts])Get a reply by ID.
opts:
Get a reply by ID. opts: - :fields — partial response field mask string - :include-deleted — boolean (default false)
(get-revision client file-id revision-id & [opts])Get a revision by ID.
opts:
Get a revision by ID. opts: - :fields — partial response field mask string - :acknowledge-abuse — boolean
(get-start-page-token client & [opts])Get the starting page token for listing future changes.
opts:
Get the starting page token for listing future changes. opts: - :drive-id — ID of shared drive - :supports-all-drives — boolean (default false)
(list-apps client & [opts])List the Drive-connected Workspace Marketplace apps the caller has
authorized. Not paginated in v3 — the response is the full list. The
result's :items key holds the App entries.
opts:
List the Drive-connected Workspace Marketplace apps the caller has
authorized. Not paginated in v3 — the response is the full list. The
result's `:items` key holds the App entries.
opts:
- :app-filter-extensions — comma-separated file extensions to filter the
matching apps by
- :app-filter-mime-types — comma-separated MIME types to filter the
matching apps by
- :language-code — BCP-47 language code; localizes app names
- :fields — partial response field mask string(list-changes client page-token & [opts])List changes to files and shared drives.
page-token — token from get-start-page-token or a previous list-changes call
Returns {:data [...] :next-page-token "..."} when more pages remain, or {:data [...] :new-start-page-token "..."} on the last page. Save :new-start-page-token for future polling via list-changes.
opts:
List changes to files and shared drives.
page-token — token from get-start-page-token or a previous list-changes call
Returns {:data [...] :next-page-token "..."} when more pages remain, or
{:data [...] :new-start-page-token "..."} on the last page. Save
:new-start-page-token for future polling via list-changes.
opts:
- :page-size — max changes per page
- :fields — partial response field mask string
- :spaces — comma-separated list of spaces
- :supports-all-drives — boolean (default false)
- :include-items-from-all-drives — boolean (default false)
- :drive-id — ID of shared drive(list-comments client file-id & [opts])List comments on a file.
opts:
List comments on a file. opts: - :page-token — token for pagination - :page-size — max comments per page - :fields — partial response field mask string - :start-modified-time — ISO 8601 timestamp; only comments modified after this - :include-deleted — boolean (default false)
(list-drives client & [opts])List Shared Drives the caller has access to.
opts:
List Shared Drives the caller has access to.
opts:
- :page-token — token from a previous response
- :page-size — max drives per page (default 10, max 100)
- :q — query string (Drive query syntax for drive filtering)
- :fields — partial response field mask string
- :use-domain-admin-access — boolean; issue the request as a domain
administrator (caller must hold the Workspace
admin role)(list-files client & [opts])List files in the user's Drive.
opts:
List files in the user's Drive. opts: - :q — query string (Drive query syntax) - :page-token — token from a previous response - :page-size — max files per page (default 100, max 1000) - :fields — partial response field mask string - :order-by — comma-separated sort keys - :corpora — :user (default), :drive, :domain, :all-drives - :drive-id — ID of shared drive (when corpora is :drive) - :spaces — comma-separated list of spaces - :supports-all-drives — boolean (default false) - :include-items-from-all-drives — boolean (default false)
(list-permissions client file-id & [opts])List permissions on a file.
opts:
List permissions on a file.
opts:
- :page-token — token for pagination
- :page-size — max permissions per page
- :fields — partial response field mask string
- :supports-all-drives — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
administrator (caller must hold the Workspace
admin role; combine with :supports-all-drives
true for effect on Shared Drives)(list-replies client file-id comment-id & [opts])List replies to a comment.
opts:
List replies to a comment. opts: - :page-token — token for pagination - :page-size — max replies per page - :fields — partial response field mask string - :include-deleted — boolean (default false)
(list-revisions client file-id & [opts])List revisions of a file.
opts:
List revisions of a file. opts: - :page-token — token for pagination - :page-size — max revisions per page - :fields — partial response field mask string
(update-comment client file-id comment-id comment-data & [opts])Update a comment.
comment-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})
Update a comment.
comment-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})(update-file client file-id metadata & [opts])Update a file's metadata and/or content.
file-id — ID of the file to update metadata — map of file properties to update (kebab-case keys), or nil for content-only
opts:
Update a file's metadata and/or content. file-id — ID of the file to update metadata — map of file properties to update (kebab-case keys), or nil for content-only opts: - :content — new file content: java.io.File, InputStream, byte[], or String - :mime-type — MIME type of the content - :fields — partial response field mask string - :add-parents — comma-separated list of parent IDs to add - :remove-parents — comma-separated list of parent IDs to remove - :supports-all-drives — boolean (default false)
(update-permission client file-id permission-id permission & [opts])Update a permission on a file.
permission — map with kebab-case keys for fields to update (e.g. {:role :writer})
opts:
Update a permission on a file.
permission — map with kebab-case keys for fields to update (e.g. {:role :writer})
opts:
- :remove-expiration — boolean
- :transfer-ownership — boolean
- :fields — partial response field mask string
- :supports-all-drives — boolean (default false)
- :use-domain-admin-access — boolean; issue the request as a domain
administrator (caller must hold the Workspace
admin role; combine with :supports-all-drives
true for effect on Shared Drives)(update-reply client file-id comment-id reply-id reply-data & [opts])Update a reply.
reply-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})
Update a reply.
reply-data — map with kebab-case keys for fields to update (e.g. {:content "edited"})(update-revision client file-id revision-id revision-data & [opts])Update a revision's metadata.
revision-data — map with kebab-case keys: :keep-forever — boolean, pin this revision :publish-auto — boolean :published — boolean
Update a revision's metadata. revision-data — map with kebab-case keys: :keep-forever — boolean, pin this revision :publish-auto — boolean :published — boolean
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |