Low-level Google Sheets API operations: reading ranges, batch updates, sheet management, and URL utilities.
Low-level Google Sheets API operations: reading ranges, batch updates, sheet management, and URL utilities.
(add-sheet service spreadsheet-id title)Add a new tab with title to spreadsheet-id. Returns the API response.
Add a new tab with `title` to `spreadsheet-id`. Returns the API response.
(append-rows! service spreadsheet-id sheet-id data-rows)Appends rows to a specific sheet using the CellDataValue protocol for precise type encoding — dates are written as serial numbers with number formats, booleans and nils are encoded explicitly, and callers can extend CellDataValue for custom types. Appends after the last non-blank row (determined client-side via a preflight read). Breaks down requests into batches of ~10k cells. If any row is wider than the sheet's current column count, inserts the necessary additional columns first.
data-rows is a sequence of sequences of CellDataValue-compatible values.
sheet-id is the numeric sheet ID.
Appends rows to a specific sheet using the CellDataValue protocol for precise type encoding — dates are written as serial numbers with number formats, booleans and nils are encoded explicitly, and callers can extend CellDataValue for custom types. Appends after the last non-blank row (determined client-side via a preflight read). Breaks down requests into batches of ~10k cells. If any row is wider than the sheet's current column count, inserts the necessary additional columns first. `data-rows` is a sequence of sequences of CellDataValue-compatible values. `sheet-id` is the numeric sheet ID.
(auto-fill-request sheet-id src-start-col src-end-col fill-length)AutoFillRequest filling from columns [src-start-col, src-end-col) for fill-length columns.
0-based.
AutoFillRequest filling from columns [src-start-col, src-end-col) for `fill-length` columns. 0-based.
(copy-to service src-spreadsheet-id src-sheet-id dst-spreadsheet-id sheet-title)Copy sheet src-sheet-id from src-spreadsheet-id to dst-spreadsheet-id.
If sheet-title is provided, the new sheet is renamed after copying.
Returns the properties of the newly created sheet.
Copy sheet `src-sheet-id` from `src-spreadsheet-id` to `dst-spreadsheet-id`. If `sheet-title` is provided, the new sheet is renamed after copying. Returns the properties of the newly created sheet.
(copypaste-cols-request sheet-id
src-start-col
src-end-col
dst-start-col
dst-end-col
{:keys [paste-type]})CopyPasteRequest copying columns [src-start-col, src-end-col) to dst-start-col.
options may include :paste-type string. 0-based.
CopyPasteRequest copying columns [src-start-col, src-end-col) to dst-start-col. `options` may include `:paste-type` string. 0-based.
(copypaste-rows-request sheet-id
src-start-row
src-end-row
dst-start-row
dst-end-row)CopyPasteRequest copying rows [src-start-row, src-end-row) to dst-start-row. 0-based.
CopyPasteRequest copying rows [src-start-row, src-end-row) to dst-start-row. 0-based.
(delete-cols-request sheet-id start-col end-col)DeleteDimensionRequest for COLUMNS [start-col, end-col). 0-based.
DeleteDimensionRequest for COLUMNS [start-col, end-col). 0-based.
(delete-rows-request sheet-id start-row end-row)DeleteDimensionRequest for ROWS [start-row, end-row). 0-based.
DeleteDimensionRequest for ROWS [start-row, end-row). 0-based.
(delete-sheet service spreadsheet-id sheet-id)Delete the sheet tab identified by sheet-id from spreadsheet-id.
Delete the sheet tab identified by `sheet-id` from `spreadsheet-id`.
(do-with-retries {:keys [max-retries retry-delay retryable-error? log-level
message context]
:or {max-retries 3 retryable-error? (constantly true)}}
f)Options: :max-retries - number of retries (default 3) :retry-delay - nil | [:random-range :min M :max N] | [:random-exp-backoff :base B :+/- J :max M] :retryable-error? - (fn [ex]) → bool; default: any exception :log-level - :info/:warn/:debug/:error (default: nil = silent) :message - string prefix for retry log message :context - map merged into ex-data on final ExceptionInfo failure, or logged alongside plain exception message
Options:
:max-retries - number of retries (default 3)
:retry-delay - nil | [:random-range :min M :max N]
| [:random-exp-backoff :base B :+/- J :max M]
:retryable-error? - (fn [ex]) → bool; default: any exception
:log-level - :info/:warn/:debug/:error (default: nil = silent)
:message - string prefix for retry log message
:context - map merged into ex-data on final ExceptionInfo failure,
or logged alongside plain exception message(exec! service spreadsheet-id requests)Execute requests (sequence of Request) as a single batchUpdate.
Retries up to 2 times on 429 with exponential backoff. Wrapped in an OTEL span.
Execute `requests` (sequence of Request) as a single batchUpdate. Retries up to 2 times on 429 with exponential backoff. Wrapped in an OTEL span.
(find-sheet-id service spreadsheet-id sheet-title)Return the numeric sheet ID for sheet-title within spreadsheet-id, or nil.
Return the numeric sheet ID for `sheet-title` within `spreadsheet-id`, or nil.
(get-cells service spreadsheet-id sheet-range)Fetch sheet-range from spreadsheet-id, returning rows of raw cell maps.
Wrapped in an OTEL span.
Fetch `sheet-range` from `spreadsheet-id`, returning rows of raw cell maps. Wrapped in an OTEL span.
(get-sheet-name service spreadsheet-id sheet-id)Return the title string for sheet-id in spreadsheet-id, or nil.
Return the title string for `sheet-id` in `spreadsheet-id`, or nil.
(gsheet-get service spreadsheet-id range)Call spreadsheets.values.get with UNFORMATTED_VALUE render option.
Call spreadsheets.values.get with UNFORMATTED_VALUE render option.
(gsheet-get-values service spreadsheet-id range)Return the "values" vec-of-vecs from a gsheet-get response.
Return the "values" vec-of-vecs from a gsheet-get response.
(info service spreadsheet-id)Return the full spreadsheets.get response for spreadsheet-id.
Return the full spreadsheets.get response for `spreadsheet-id`.
(insert-data! service
spreadsheet-id
sheet-id
row
col
vector-row-data
&
[inherit-from-before])Insert vector-row-data rows at row/col, sending both the insert-rows and
update-grid requests in a single exec! call. row and col are 0-based.
Insert `vector-row-data` rows at `row`/`col`, sending both the insert-rows and update-grid requests in a single exec! call. `row` and `col` are 0-based.
(insert-dimension-request sheet-id dim inherit-from-before start num)InsertDimensionRequest for dim ("ROWS" or "COLUMNS") starting at start.
inherit-from-before controls formatting inheritance. 0-based.
InsertDimensionRequest for `dim` ("ROWS" or "COLUMNS") starting at `start`.
`inherit-from-before` controls formatting inheritance. 0-based.(insert-rows-request sheet-id inherit-from-before start-row num-rows)InsertDimensionRequest for ROWS before start-row. 0-based.
InsertDimensionRequest for ROWS before `start-row`. 0-based.
(parse-spreadsheet-link url)Parse a Google Sheets URL into {:spreadsheet-id "..." :sheet-id 123}. Returns nil for nil input.
Parse a Google Sheets URL into {:spreadsheet-id "..." :sheet-id 123}.
Returns nil for nil input.(rate-limit-error? e)True if e is a Google API 429 (rate limit) response.
True if `e` is a Google API 429 (rate limit) response.
(set-hidden service spreadsheet-id sheet-id hidden?)Set the hidden property of sheet sheet-id to hidden?.
Set the hidden property of sheet `sheet-id` to `hidden?`.
(sheet-info service spreadsheet-id sheet-id)Return the raw sheet map for sheet-id within spreadsheet-id, or nil.
Return the raw sheet map for `sheet-id` within `spreadsheet-id`, or nil.
(spreadsheet-link spreadsheet-id sheet-id)Format a Google Sheets URL for a specific sheet tab.
Format a Google Sheets URL for a specific sheet tab.
(try-catch-gsr-exception f err-pattern)Call f. If a GoogleJsonResponseException matching err-pattern is thrown,
return true. If f succeeds, return false. Other exceptions re-thrown.
Call `f`. If a GoogleJsonResponseException matching `err-pattern` is thrown, return true. If f succeeds, return false. Other exceptions re-thrown.
(update-cells-request sheet-id row-idx col-idx data)UpdateCellsRequest for a single row of data at [row-idx col-idx]. 0-based.
UpdateCellsRequest for a single row of data at [row-idx col-idx]. 0-based.
(update-grid! service spreadsheet-id sheet-id row-idx col-idx data)Build and execute an update-grid-request. 0-based row/col.
Build and execute an update-grid-request. 0-based row/col.
(update-grid-request sheet-id row-idx col-idx data)UpdateCellsRequest for a 2D region starting at [row-idx col-idx].
data is a vec of rows, each row a vec of CellDataValue-compatible values.
Indexes are 0-based.
UpdateCellsRequest for a 2D region starting at [row-idx col-idx]. `data` is a vec of rows, each row a vec of CellDataValue-compatible values. Indexes are 0-based.
(update-title service spreadsheet-id sheet-id new-sheet-title)Rename sheet sheet-id to new-sheet-title.
Rename sheet `sheet-id` to `new-sheet-title`.
(update-title-with-incrementing-name service
spreadsheet-id
sheet-id
sheet-name0)Rename sheet sheet-id. If name already exists, append .01, .02, etc.
Rename sheet `sheet-id`. If name already exists, append `.01`, `.02`, etc.
(with-retries f err-message)Execute f with default retry options (up to 3 retries). err-message is
logged as context on failure.
Execute `f` with default retry options (up to 3 retries). `err-message` is logged as context on failure.
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 |