Clojure wrapper for the Google Sheets API (v4).
Provides idiomatic Clojure functions for reading, writing, and managing Google Sheets spreadsheets.
Auth: use csl/scoped-delegated-credentials or csl/user-credentials with the appropriate scope:
Values functions accept and return plain Clojure vectors-of-vectors. Enum options (e.g. :value-input-option) accept kebab-case keywords that are coerced internally (:user-entered -> "USER_ENTERED").
All functions return {:data ...} on success or {:error ...} on failure.
Clojure wrapper for the Google Sheets API (v4).
Provides idiomatic Clojure functions for reading, writing, and managing
Google Sheets spreadsheets.
Auth: use csl/scoped-delegated-credentials or csl/user-credentials with
the appropriate scope:
- SheetsScopes/SPREADSHEETS (read + write)
- SheetsScopes/SPREADSHEETS_READONLY (read-only access)
Values functions accept and return plain Clojure vectors-of-vectors.
Enum options (e.g. :value-input-option) accept kebab-case keywords
that are coerced internally (:user-entered -> "USER_ENTERED").
All functions return {:data ...} on success or {:error ...} on failure.(add-sheet-request title)Build a request map that adds a sheet with the given title.
Build a request map that adds a sheet with the given title.
(append-values client spreadsheet-id range values & [opts])Append rows after the last row with data in a range.
opts:
Append rows after the last row with data in a range.
opts:
- :value-input-option — :raw (default) or :user-entered
- :insert-data-option — :overwrite or :insert-rows (default)
- :read-timeout-ms — int, override the HTTP client's default read
timeout for this request(batch-clear-values client spreadsheet-id ranges & [opts])Clear values from multiple ranges.
opts:
Clear values from multiple ranges.
opts:
- :read-timeout-ms — int, override the HTTP client's default read timeout
for this request(batch-get-values client spreadsheet-id ranges & [opts])Read values from multiple ranges in a single call.
ranges — a vector of A1-notation range strings. opts:
Read values from multiple ranges in a single call.
ranges — a vector of A1-notation range strings.
opts:
- :major-dimension — :rows or :columns
- :value-render-option — :formatted-value, :unformatted-value, or :formula
- :date-time-render-option — :serial-number or :formatted-string
- :fields — partial response field mask string
- :read-timeout-ms — int, override the HTTP client's default read
timeout for this request(batch-update client spreadsheet-id requests & [opts])Execute a batch of structural updates on a spreadsheet.
requests — a vector of request maps, each with a single key naming the operation and a map of parameters: [{:add-sheet {:properties {:title "New Sheet"}}} {:delete-sheet {:sheet-id 123}} {:repeat-cell {:range {:sheet-id 0 :start-row-index 0 :end-row-index 10} :cell {:user-entered-format {:text-format {:font-family "Arial" :bold true}}} :fields "userEnteredFormat.textFormat"}}]
Keys use kebab-case; they are coerced to camelCase internally.
opts:
Execute a batch of structural updates on a spreadsheet.
requests — a vector of request maps, each with a single key naming the
operation and a map of parameters:
[{:add-sheet {:properties {:title "New Sheet"}}}
{:delete-sheet {:sheet-id 123}}
{:repeat-cell {:range {:sheet-id 0 :start-row-index 0 :end-row-index 10}
:cell {:user-entered-format
{:text-format {:font-family "Arial" :bold true}}}
:fields "userEnteredFormat.textFormat"}}]
Keys use kebab-case; they are coerced to camelCase internally.
opts:
- :include-spreadsheet-in-response — boolean
- :response-include-grid-data — boolean
- :response-ranges — vector of A1 ranges
- :read-timeout-ms — int, override the HTTP client's
default read timeout for this request(batch-update-values client spreadsheet-id range-values & [opts])Write values to multiple ranges in a single call.
range-values — a vector of maps, each with :range and :values keys: [{:range "Sheet1!A1:B2" :values [[1 2] [3 4]]} {:range "Sheet2!A1" :values [["hello"]]}]
opts:
Write values to multiple ranges in a single call.
range-values — a vector of maps, each with :range and :values keys:
[{:range "Sheet1!A1:B2" :values [[1 2] [3 4]]}
{:range "Sheet2!A1" :values [["hello"]]}]
opts:
- :value-input-option — :raw (default) or :user-entered
- :read-timeout-ms — int, override the HTTP client's default read
timeout for this request. Useful for large
multi-range batches where server-side processing
exceeds the default ~20s.(clear-values client spreadsheet-id range & [opts])Clear values from a range (formatting is preserved).
opts:
Clear values from a range (formatting is preserved).
opts:
- :read-timeout-ms — int, override the HTTP client's default read timeout
for this request(copy-sheet client source-spreadsheet-id sheet-id destination-spreadsheet-id)Copy a sheet to another spreadsheet. Returns the properties of the newly created sheet.
Copy a sheet to another spreadsheet. Returns the properties of the newly created sheet.
(create-spreadsheet client & [title])Create a new spreadsheet. Optionally pass a title string.
Create a new spreadsheet. Optionally pass a title string.
(delete-sheet-request sheet-id)Build a request map that deletes the sheet with the given ID.
Build a request map that deletes the sheet with the given ID.
(duplicate-sheet-request source-sheet-id
&
[{:keys [new-sheet-name insert-sheet-index
new-sheet-id]}])Build a request map that duplicates a sheet.
opts:
Build a request map that duplicates a sheet. opts: - :new-sheet-name — title for the new sheet - :insert-sheet-index — position to insert the new sheet - :new-sheet-id — explicit ID for the new sheet
(get-spreadsheet client spreadsheet-id & [opts])Get a spreadsheet by ID.
opts:
Get a spreadsheet by ID.
opts:
- :ranges — vector of A1-notation ranges to include in the response
- :include-grid-data — boolean, include cell data for the specified ranges
- :fields — partial response field mask string. Omit to receive
the full spreadsheet metadata, which can be very
large (and slow) for sheets with many protected
ranges, conditional formats, etc. Pass a narrow mask
like "sheets(properties(sheetId,title))" to
minimize payload.
- :read-timeout-ms — int, override the HTTP client's default read timeout
(~20s) for this request. A narrow :fields mask
shortens the response payload, but server-side
rendering of protected ranges can still take longer
than the default; raise this when fetching metadata
from a spreadsheet that has accumulated many
protected ranges or conditional formats.(get-values client spreadsheet-id range & [opts])Read values from a range.
opts:
Read values from a range.
opts:
- :major-dimension — :rows (default) or :columns
- :value-render-option — :formatted-value (default), :unformatted-value,
or :formula
- :date-time-render-option — :serial-number or :formatted-string
- :fields — partial response field mask string
- :read-timeout-ms — int, override the HTTP client's default read
timeout for this request(sheets-client credentials)(sheets-client credentials opts)Build an authenticated Sheets v4 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 Sheets v4 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.
(update-sheet-properties-request sheet-id properties fields)Build a request map that updates sheet properties.
properties — map of property keys to update (e.g. {:title "New Title"}) fields — comma-separated field mask string (e.g. "title")
Build a request map that updates sheet properties.
properties — map of property keys to update (e.g. {:title "New Title"})
fields — comma-separated field mask string (e.g. "title")(update-values client spreadsheet-id range values & [opts])Write values to a range. values is a vector of row vectors.
opts:
Write values to a range. values is a vector of row vectors.
opts:
- :value-input-option — :raw (default) or :user-entered
- :include-values-in-response — boolean
- :response-value-render-option — :formatted-value, :unformatted-value,
or :formula
- :response-date-time-render-option — :serial-number or :formatted-string
- :read-timeout-ms — int, override the HTTP client's
default read timeout for this requestcljdoc 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 |