Clojure wrapper for the Google Forms API (v1).
Provides idiomatic Clojure functions for creating and managing Google Forms, reading form responses, and updating form structure via batch updates.
Auth: use csl/scoped-delegated-credentials or csl/user-credentials with the appropriate scope:
Form structure is modified exclusively through batch-update, which takes a vector of request maps (kebab-case keys, coerced to camelCase internally). Convenience builders (create-item-request, delete-item-request, etc.) return plain Clojure maps for use with batch-update.
Responses are read-only — they are submitted by form respondents, not the API.
All list functions return {:data [...] :next-page-token "..."}. :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 Forms API (v1).
Provides idiomatic Clojure functions for creating and managing Google Forms,
reading form responses, and updating form structure via batch updates.
Auth: use csl/scoped-delegated-credentials or csl/user-credentials with
the appropriate scope:
- FormsScopes/FORMS_BODY (read + write forms)
- FormsScopes/FORMS_BODY_READONLY (read-only access to forms)
- FormsScopes/FORMS_RESPONSES_READONLY (read-only access to responses)
- FormsScopes/DRIVE (full Drive access — forms are Drive files)
- FormsScopes/DRIVE_FILE (only files used with this app)
- FormsScopes/DRIVE_READONLY (read-only Drive access)
Form structure is modified exclusively through batch-update, which takes a
vector of request maps (kebab-case keys, coerced to camelCase internally).
Convenience builders (create-item-request, delete-item-request, etc.) return
plain Clojure maps for use with batch-update.
Responses are read-only — they are submitted by form respondents, not the API.
All list functions return {:data [...] :next-page-token "..."}.
:next-page-token is absent when there are no further pages.
All functions return {:data ...} on success or {:error ...} on failure.(batch-update client
form-id
requests
&
[{:keys [include-form-in-response] :as opts}])Execute a batch of structural updates on a form.
requests — a vector of request maps, each with a single key naming the operation and a map of parameters: [(create-item-request {:title "Q1" :question-item {...}} {:index 0}) (delete-item-request 1) (update-form-info-request {:title "New Title"} "title")]
Keys use kebab-case; they are coerced to camelCase internally.
opts:
Execute a batch of structural updates on a form.
requests — a vector of request maps, each with a single key naming the
operation and a map of parameters:
[(create-item-request {:title "Q1" :question-item {...}} {:index 0})
(delete-item-request 1)
(update-form-info-request {:title "New Title"} "title")]
Keys use kebab-case; they are coerced to camelCase internally.
opts:
- :include-form-in-response — boolean, include the updated form in the response
- :read-timeout-ms — int, override the HTTP client's default read timeout
for this request.(create-form client form-data & [opts])Create a new Google Form.
form-data — a map of form properties. Only :info can be set at creation time (with keys :title, :description, :document-title). Items must be added via batch-update after creation.
opts:
Example: (create-form client {:info {:title "My Survey"}})
Create a new Google Form.
form-data — a map of form properties. Only :info can be set at creation
time (with keys :title, :description, :document-title). Items must be
added via batch-update after creation.
opts:
- :read-timeout-ms — int, override the HTTP client's default read timeout
for this request.
Example:
(create-form client {:info {:title "My Survey"}})(create-item-request item & [{:keys [index]}])Build a request map that creates a form item at the given index.
item — a map describing the item (e.g. a question, page break, text, image). opts:
Enum-typed fields (e.g. choice-question :type) should be passed as uppercase strings ("RADIO", "CHECKBOX", "DROP_DOWN") — keyword values are camelCased by csl/clj->json and may not match the API's expected enum names.
Example: (create-item-request {:title "Favorite color?" :question-item {:question {:required true :choice-question {:type "RADIO" :options [{:value "Red"} {:value "Blue"}]}}}} {:index 0})
Build a request map that creates a form item at the given index.
item — a map describing the item (e.g. a question, page break, text, image).
opts:
- :index — position to insert the item (0-based)
Enum-typed fields (e.g. choice-question :type) should be passed as
uppercase strings ("RADIO", "CHECKBOX", "DROP_DOWN") — keyword values
are camelCased by csl/clj->json and may not match the API's expected enum names.
Example:
(create-item-request
{:title "Favorite color?"
:question-item
{:question {:required true
:choice-question {:type "RADIO"
:options [{:value "Red"}
{:value "Blue"}]}}}}
{:index 0})(delete-item-request index)Build a request map that deletes the form item at the given index.
Build a request map that deletes the form item at the given index.
(extract-answers response)Extract a simplified answer map from a form response.
Given a response map (as returned by get-response), returns a map of {question-id [answer-values]} where each value is a string. Keys are kebab-case keywords (the question IDs as converted by csl/->clj).
Only text answers are extracted; file upload answers are omitted. For file upload answers, access the raw response directly.
Extract a simplified answer map from a form response.
Given a response map (as returned by get-response), returns a map of
{question-id [answer-values]} where each value is a string. Keys are
kebab-case keywords (the question IDs as converted by csl/->clj).
Only text answers are extracted; file upload answers are omitted.
For file upload answers, access the raw response directly.(forms-client credentials)(forms-client credentials opts)Build an authenticated Forms v1 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 Forms v1 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.
(get-form client form-id)(get-form client form-id opts)Retrieve a form by ID.
Returns the full form structure including items, settings, and metadata.
opts:
Retrieve a form by ID. Returns the full form structure including items, settings, and metadata. opts: - :fields —a partial response field mask string (e.g. "formId,info(title)"). Omitting it returns the full form, which can be large for forms with many items — pass a narrow mask if you only need a subset.
(get-response client form-id response-id)(get-response client form-id response-id opts)Retrieve a single form response by ID.
opts:
Retrieve a single form response by ID. opts: - :fields —a partial response field mask string (e.g. "responseId,createTime,answers").
(list-responses client form-id & [opts])List responses for a form.
opts:
List responses for a form. opts: - :filter — timestamp predicate string (e.g. "timestamp >= 2026-01-01T00:00:00Z") - :page-token — token from a previous response for pagination - :page-size — maximum number of responses per page (max 5000) - :fields — partial response field mask string (e.g. "responses(responseId,createTime),nextPageToken")
(move-item-request original-index new-index)Build a request map that moves a form item from one index to another.
Build a request map that moves a form item from one index to another.
(set-publish-settings client form-id publish-settings & [opts])Update the publish settings of a form.
publish-settings — a map of publish settings, e.g.: {:is-published true}
opts:
Update the publish settings of a form.
publish-settings — a map of publish settings, e.g.:
{:is-published true}
opts:
- :read-timeout-ms — int, override the HTTP client's default read timeout
for this request.(update-form-info-request info update-mask)Build a request map that updates the form's info (title, description).
info — a map with the updated info fields update-mask — comma-separated field mask string (e.g. "title,description")
Build a request map that updates the form's info (title, description). info — a map with the updated info fields update-mask — comma-separated field mask string (e.g. "title,description")
(update-item-request item index update-mask)Build a request map that updates a form item at the given index.
item — a map with the updated item fields index — the 0-based index of the item to update update-mask — comma-separated field mask string (e.g. "title,description")
Build a request map that updates a form item at the given index. item — a map with the updated item fields index — the 0-based index of the item to update update-mask — comma-separated field mask string (e.g. "title,description")
(update-settings-request settings update-mask)Build a request map that updates the form's settings.
settings — a map with the updated settings (e.g. quiz settings) update-mask — comma-separated field mask string (e.g. "quizSettings.isQuiz")
Build a request map that updates the form's settings. settings — a map with the updated settings (e.g. quiz settings) update-mask — comma-separated field mask string (e.g. "quizSettings.isQuiz")
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 |