Liking cljdoc? Tell your friends :D

goog.workspace.forms

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.

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.
raw docstring

batch-updateclj

(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:

  • :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.
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.
raw docstring

create-formclj

(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:

  • :read-timeout-ms — int, override the HTTP client's default read timeout for this request.

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"}})
raw docstring

create-item-requestclj

(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:

  • :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})

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})
raw docstring

delete-item-requestclj

(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.
raw docstring

extract-answersclj

(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.
raw docstring

forms-clientclj

(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):

  • :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.

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.
raw docstring

get-formclj

(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:

  • :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.
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.
raw docstring

get-responseclj

(get-response client form-id response-id)
(get-response client form-id response-id opts)

Retrieve a single form response by ID.

opts:

  • :fields —a partial response field mask string (e.g. "responseId,createTime,answers").
Retrieve a single form response by ID.

opts:
- :fields —a partial response field mask string (e.g.
  "responseId,createTime,answers").
raw docstring

list-responsesclj

(list-responses client form-id & [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")
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")
raw docstring

move-item-requestclj

(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.
raw docstring

set-publish-settingsclj

(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:

  • :read-timeout-ms — int, override the HTTP client's default read timeout for this request.
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.
raw docstring

update-form-info-requestclj

(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")
raw docstring

update-item-requestclj

(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")
raw docstring

update-settings-requestclj

(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")
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close