Skip to main content

gformlib

PyPI version Python versions CI Documentation Status License: MIT codecov

gformlib is a Python library for creating and managing Google Forms programmatically from JSON configurations. It is a high-level wrapper around the official Google Forms API v1.

Features

  • Create Google Forms from a simple Python dict / JSON file
  • All question types supported: short answer, paragraph, multiple choice, checkboxes, dropdown, scale, date, time, file upload
  • Service-account and OAuth 2.0 authentication
  • Full type annotations (PEP 561 compliant)
  • Retrieve form responses with automatic pagination
  • Professional project structure, ready to publish to PyPI

Installation

pip install gformlib

Quickstart

from gformlib import GoogleFormsClient

client = GoogleFormsClient.from_service_account("path/to/service_account.json")

2. Authenticate with OAuth 2.0 (desktop / installed apps)

client = GoogleFormsClient.from_oauth_credentials(
    "client_secrets.json",
    token_file="token.json",
)

3. Create a form from a dict

info = client.create_form(
    {
        "title": "Customer Satisfaction Survey",
        "description": "Tell us how we're doing.",
        "questions": [
            {
                "title": "Your name",
                "type": "short_answer",
                "required": True,
            },
            {
                "title": "Overall rating",
                "type": "scale",
                "low": 1,
                "high": 5,
                "low_label": "Poor",
                "high_label": "Excellent",
                "required": True,
            },
            {
                "title": "Which features do you use?",
                "type": "checkboxes",
                "options": ["Dashboard", "Reports", "API", "Integrations"],
            },
            {
                "title": "Any other comments?",
                "type": "paragraph",
            },
        ],
    }
)

print(f"Form ID   : {info.form_id}")
print(f"Share URL : {info.responder_uri}")

4. Read responses

responses = client.list_responses(info.form_id)
for r in responses:
    print(r["responseId"], r.get("answers"))

Supported question types

type value Google Forms equivalent
short_answer Short answer (single line)
paragraph Paragraph (multi-line)
multiple_choice Multiple choice (radio)
checkboxes Checkboxes
dropdown Dropdown
scale Linear scale
date Date
time Time
file_upload File upload

Authentication setup

Service Account

  1. Create a Service Account in Google Cloud Console.
  2. Enable the Google Forms API and Google Drive API.
  3. Download the JSON key file.
  4. Share the target Google Drive folder with the service account email.

OAuth 2.0

  1. Create an OAuth 2.0 Desktop app client in Google Cloud Console.
  2. Download client_secrets.json.
  3. On first run, a browser window opens to authorise access.
  4. The token is cached in token.json for subsequent runs.

Development

git clone https://github.com/andhit-r/gformlib.git
cd gformlib
pip install -e ".[dev]"
pytest

Running the full test matrix with tox

tox

Contributing

See CONTRIBUTING.md.

License

MIT

Metadata

Release files for gformlib 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gformlib 0.2.0
File Size Uploaded Provenance Actions
gformlib-0.2.0.tar.gz 27.7 kB With provenance Details for gformlib-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gformlib 0.2.0
File Interpreter ABI Platform Actions
gformlib-0.2.0-py3-none-any.whl Python 3 none any Details for gformlib-0.2.0-py3-none-any.whl

Total release size: 48.0 kB

Release files / gformlib-0.2.0.tar.gz

Download URL gformlib-0.2.0.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
42510f7f1b5a9c4f72be10f716bf9c865f4f360ad6834f2ffd16f1a5d902f864
BLAKE2b-256 checksum
How to use checksums
a4b2585faffd9cd867800e5fa5f72abd735d1306ad0bc0597e95225e4145068c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2026.

Transparency log

Release files / gformlib-0.2.0-py3-none-any.whl

Download URL gformlib-0.2.0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47359030caba0ba085e8016c8378aa12c6bbf5ff81a995686a38a9dea1423946
BLAKE2b-256 checksum
How to use checksums
1a31609580314b6ff7f9714817a36ca4c0943c1e5b0a7ff5fc9101b0cf563746
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2026.

Transparency log

Security for gformlib 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gformlib-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page