Skip to main content

gdocs

Python Version License

A lightweight, environment-agnostic Python package to seamlessly authenticate, read, and modify Google Docs.

gdocs is designed to work flawlessly across different environments. It intelligently detects if you are running code inside Google Colab and uses native Colab authentication. If you are running locally or on a standard server, it gracefully falls back to local Application Default Credentials (ADC).

✨ Features

  • Environment Agnostic: Works out-of-the-box in Google Colab, Jupyter Notebooks, and local Python scripts without code changes.
  • Recursive Parsing: Automatically extracts text from standard paragraphs, complex nested tables, and lists.
  • Full Tabs Support: Fully supports reading and navigating Google Docs' new nested Tabs structure.
  • AI-Ready Manipulation: Built-in methods to append text, insert executive summaries, or replace template variables (ideal for LLM agent workflows).
  • Robust Error Handling: Built-in isolated logging and graceful failure handling for API timeouts and HTTP errors.

📦 Installation

Since gdocs is currently in development and not yet published to PyPI, you can install it directly from the GitHub repository using standard pip or the faster uv package manager.

Using pip

pip install git+[https://github.com/chintu4/gdocs.git](https://github.com/chintu4/gdocs.git)

Using uv

uv pip install git+[https://github.com/chintu4/gdocs.git](https://github.com/chintu4/gdocs.git)

(Note: This automatically installs required dependencies like google-api-python-client and google-auth)

🔐 Authentication Setup

1. In Google Colab

No setup required. The package will automatically trigger the standard Colab authentication popup when you execute the client.

2. Local Environment

To run locally, you need to provide Google Cloud credentials via Application Default Credentials (ADC).

Install the Google Cloud CLI and run:

gcloud auth application-default login

This opens a browser for you to sign in. gdocs will automatically detect and use these credentials.

🚀 Usage

Basic Reading

Extract text from a full document, automatically parsing all tabs and nested tables:

from gdocs.main import GoogleDocsService

# You can pass a full URL or just the ID directly!
DOCUMENT_URL = "[https://docs.google.com/document/d/1aBcD_eFgHiJkLmNoPqRsTuVwXyZ/edit](https://docs.google.com/document/d/1aBcD_eFgHiJkLmNoPqRsTuVwXyZ/edit)"

# Initialize the service (Handles auth automatically)
docs_service = GoogleDocsService()

# Read the entire document
text = docs_service.read_document(DOCUMENT_URL)
print(text)

Working with Tabs

If your document utilizes Google Docs Tabs:

# Get a dictionary mapping {tab_id: tab_title}
tabs = docs_service.get_tabs_info(DOCUMENT_URL)
print(tabs)

# Read a specific tab only
if tabs:
    first_tab_id = list(tabs.keys())[0]
    tab_text = docs_service.read_specific_tab(DOCUMENT_URL, target_tab_id=first_tab_id)

Modifying Documents (AI Workflows)

Perfect for AI agents generating and logging content:

# Append text to the very bottom of the document
docs_service.append_text(DOCUMENT_URL, text="\n\nAI Summary: This is an automated summary.")

# Insert text at the very beginning
docs_service.insert_text_at_start(DOCUMENT_URL, text="CONFIDENTIAL DRAFT\n")

# Replace template variables (e.g., replacing '{{NAME}}' with 'Alice')
docs_service.replace_text(DOCUMENT_URL, search_string="{{NAME}}", replacement_string="Alice")

📄 License

This project is licensed under the MIT License.

Metadata

Release files for gdocs 0.1.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 gdocs 0.1.0
File Size Uploaded Provenance Actions
gdocs-0.1.0.tar.gz 6.3 kB With provenance Details for gdocs-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 12.6 kB

Release files / gdocs-0.1.0.tar.gz

Download URL gdocs-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8773ceea0ad8be4bdd30b615877377484d3f10e62d45508864bd3b440dea21f2
BLAKE2b-256 checksum
How to use checksums
772337c117ac1bdf05356ffea6420e4cab735a571ec00cfdfa94cc6b9144e212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / gdocs-0.1.0-py3-none-any.whl

Download URL gdocs-0.1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2df619965ac5b5e2a64c5d4222279b111dfef4b88e2709eee864c8e340f24f57
BLAKE2b-256 checksum
How to use checksums
9a69df9c38f45f74bdc25593c0555a28686bc3319f9b71a5f2bb39956a760ede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Security for gdocs 0.1.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 gdocs-0.1.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 Oct 11, 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.

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