Skip to main content

Production-grade Python library for NotebookLM automation with 31 tools

Project description

PyNotebookLM

CI Python 3.10+ PyPI License: Apache 2.0

Production-grade Python library for Google NotebookLM automation.

Documentation: https://github.com/Experto-AI/pynotebooklm

Features

  • ๐Ÿ” Secure Authentication - Browser-based Google login with cookie persistence
  • ๐Ÿ““ Notebook Management - Create, list, rename, and delete notebooks
  • ๐Ÿ“ฐ Source Management - Add URLs, YouTube videos, Google Drive docs, and text
  • ๐Ÿ” Research & Analysis - Query notebooks and discover related sources (Web/Google Drive)
  • ๐Ÿง  Mind Maps - Generate, save, list, and export mind maps (JSON/OPML/FreeMind)
  • ๐ŸŽ™๏ธ Content Generation - Create audio overviews (podcasts), videos, infographics, and slides
  • ๐Ÿ“š Study Tools - Create flashcards, quizzes, and briefing documents

Installation

pip install pynotebooklm

Or with Poetry:

poetry add pynotebooklm

Install Playwright Browsers

After installing, you need to install the Playwright browser:

playwright install chromium

Quick Start

1. Authenticate

First, login to NotebookLM with your Google account:

pynotebooklm auth login

This opens a browser window for you to login. Cookies are saved to ~/.pynotebooklm/auth.json.

2. Verify Authentication

pynotebooklm auth check

3. Use the Library

import asyncio
from pynotebooklm import NotebookLMClient

async def main():
    async with NotebookLMClient() as client:
        # List notebooks
        notebooks = await client.notebooks.list()
        for nb in notebooks:
            print(f"{nb.name} ({nb.id})")

asyncio.run(main())

CLI Commands

Authentication

pynotebooklm auth login              # Login with Google account (opens browser)
pynotebooklm auth check              # Check authentication status
pynotebooklm auth logout             # Clear saved authentication

Notebooks

pynotebooklm notebooks list                        # List all notebooks
pynotebooklm notebooks list --detailed             # With source count and dates
pynotebooklm notebooks create "My Notebook"        # Create a new notebook
pynotebooklm notebooks get <notebook_id>           # Get detailed notebook info with sources
pynotebooklm notebooks describe <notebook_id>      # Get AI-generated summary and topics
pynotebooklm notebooks rename <notebook_id> "New Name"  # Rename a notebook
pynotebooklm notebooks delete <notebook_id>        # Delete a notebook
pynotebooklm notebooks delete <notebook_id> -f     # Delete without confirmation

Sources

pynotebooklm sources add <notebook_id> <url>               # Add URL source (Web or YouTube)
pynotebooklm sources add-text <notebook_id> "text"         # Add plain text source
pynotebooklm sources add-drive <notebook_id> <drive_id>    # Add Google Drive source
pynotebooklm sources list <notebook_id>                    # List sources in notebook
pynotebooklm sources list <notebook_id> --check-freshness  # Check if Drive sources are up-to-date
pynotebooklm sources describe <source_id>                  # AI-generated summary and keywords
pynotebooklm sources get-text <source_id>                  # Extract raw indexed text
pynotebooklm sources sync <source_id>                      # Sync stale Drive source
pynotebooklm sources delete <notebook_id> <source_id>      # Delete a source
pynotebooklm sources delete <notebook_id> <source_id> -f   # Delete without confirmation

Research Discovery

pynotebooklm research start <notebook_id> "topic"              # Fast web research
pynotebooklm research start <notebook_id> "topic" --deep       # Deep research (more comprehensive)
pynotebooklm research start <notebook_id> "topic" --source drive   # Search Google Drive
pynotebooklm research poll <notebook_id>                       # Check status and get results
pynotebooklm research poll <notebook_id> --auto-import         # Poll & auto-import when done
pynotebooklm research import <notebook_id>                     # Import all discovered sources
pynotebooklm research import <notebook_id> --indices 0,1,2     # Import specific sources

Mind Maps

pynotebooklm mindmap create <notebook_id>                      # Create from all sources
pynotebooklm mindmap create <notebook_id> --title "My Map"     # With custom title
pynotebooklm mindmap list <notebook_id>                        # List existing maps
pynotebooklm mindmap export <notebook_id> <map_id> -f json     # Export to JSON
pynotebooklm mindmap export <notebook_id> <map_id> -f opml     # Export to OPML
pynotebooklm mindmap export <notebook_id> <map_id> -f freemind # Export to FreeMind (.mm)

Chat & Query

pynotebooklm query ask <notebook_id> "question"                # Ask a question
pynotebooklm query ask <notebook_id> "question" --sources <ids> # Scope to specific sources
pynotebooklm query ask <notebook_id> "question" -c <id>        # Follow-up in conversation
pynotebooklm query summary <notebook_id>                       # Get AI summary
pynotebooklm query briefing <notebook_id>                      # Create briefing document
pynotebooklm query configure <notebook_id> --goal learning     # Set conversation goal
pynotebooklm query configure <notebook_id> --length longer     # Set response length

Content Generation

# Audio Overview (Podcast)
pynotebooklm generate audio <notebook_id>                      # Generate with defaults
pynotebooklm generate audio <notebook_id> --format deep_dive   # Format: deep_dive, brief, critique, debate
pynotebooklm generate audio <notebook_id> --length short       # Length: short, default, long
pynotebooklm generate audio <notebook_id> --language es        # Language: en, es, fr, de, ja, etc.
pynotebooklm generate audio <notebook_id> --focus "key topics" # Focus prompt for AI

# Video Overview
pynotebooklm generate video <notebook_id>                      # Generate with defaults
pynotebooklm generate video <notebook_id> --format explainer   # Format: explainer, brief
pynotebooklm generate video <notebook_id> --style anime        # Style: auto_select, classic, whiteboard, kawaii, anime, watercolor, retro_print, heritage, paper_craft

# Infographic
pynotebooklm generate infographic <notebook_id>                    # Generate with defaults
pynotebooklm generate infographic <notebook_id> --orientation portrait  # Orientation: landscape, portrait, square
pynotebooklm generate infographic <notebook_id> --detail detailed  # Detail: concise, standard, detailed

# Slide Deck
pynotebooklm generate slides <notebook_id>                         # Generate with defaults
pynotebooklm generate slides <notebook_id> --format presenter_slides  # Format: detailed_deck, presenter_slides
pynotebooklm generate slides <notebook_id> --length short          # Length: short, default

### Study Tools

```bash
# Flashcards
pynotebooklm study flashcards <notebook_id>                    # Generate flashcards
pynotebooklm study flashcards <notebook_id> --difficulty hard  # Difficulty: easy, medium, hard

# Quiz
pynotebooklm study quiz <notebook_id>                          # Generate quiz (default 2 questions)
pynotebooklm study quiz <notebook_id> --questions 10           # Number of questions
pynotebooklm study quiz <notebook_id> --difficulty 3           # Difficulty: 1 (easy) to 3 (hard)

# Data Table
pynotebooklm study table <notebook_id> --description "Extract dates"     # Extract structured data
pynotebooklm study table <notebook_id> --description "..." --language es # Output language

pynotebooklm studio status <notebook_id> # shows study artifacts

Studio (Artifact Management)

pynotebooklm studio list <notebook_id>             # List all artifacts (Briefings, Audio, Video, etc.)
pynotebooklm studio status <notebook_id>           # Detailed status with download URLs
pynotebooklm studio delete <artifact_id>           # Delete an artifact (with confirmation)
pynotebooklm studio delete <artifact_id> --force   # Delete without confirmation

Troubleshooting

Authentication Errors

  • Run pynotebooklm auth login to refresh cookies.
  • Delete ~/.pynotebooklm/auth.json if cookies are corrupted, then login again.

Playwright Issues

  • Ensure the browser is installed: playwright install chromium
  • On Linux, install required system deps (see Dockerfile for a reference list).

Debugging Requests

  • Enable verbose logging with PYNOTEBOOKLM_DEBUG=1.
  • Enable structured telemetry with PYNOTEBOOKLM_TELEMETRY=1.

Development

Setup

# Clone the repository
git clone https://github.com/Experto-AI/pynotebooklm.git
cd pynotebooklm

# Install dependencies
poetry install

# Install Playwright browsers
poetry run playwright install chromium

Running Tests

# Run all unit tests
poetry run pytest tests/unit/ -v

# Run with coverage
poetry run pytest tests/unit/ -v --cov=src/pynotebooklm

# Run specific test file
poetry run pytest tests/unit/test_auth.py -v

Linting and Formatting

# Lint with ruff
poetry run ruff check src tests

# Format with black
poetry run black src tests

# Type check with mypy
poetry run mypy src

Project Structure

pynotebooklm/
โ”œโ”€โ”€ src/pynotebooklm/
โ”‚   โ”œโ”€โ”€ __init__.py        # Public API exports
โ”‚   โ”œโ”€โ”€ auth.py            # Authentication manager
โ”‚   โ”œโ”€โ”€ session.py         # Browser session management
โ”‚   โ”œโ”€โ”€ api.py             # Low-level RPC wrapper
โ”‚   โ”œโ”€โ”€ notebooks.py       # Notebook management
โ”‚   โ”œโ”€โ”€ sources.py         # Source management
โ”‚   โ”œโ”€โ”€ research.py        # Research discovery
โ”‚   โ”œโ”€โ”€ mindmaps.py        # Mind map generation
โ”‚   โ”œโ”€โ”€ study.py           # Study tools (flashcards, quiz, tables)
โ”‚   โ”œโ”€โ”€ content.py         # Content generation (audio, video, etc.)
โ”‚   โ”œโ”€โ”€ chat.py            # Chat and query functionality
โ”‚   โ”œโ”€โ”€ models.py          # Pydantic data models
โ”‚   โ”œโ”€โ”€ exceptions.py      # Custom exceptions
โ”‚   โ””โ”€โ”€ cli.py             # CLI interface
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ unit/              # Unit tests (457)
โ”‚   โ”œโ”€โ”€ integration/       # Integration tests (192)
โ”‚   โ””โ”€โ”€ fixtures/          # Mock responses
โ””โ”€โ”€ docs/                  # Documentation

How It Works

PyNotebookLM uses browser automation (Playwright) to interact with NotebookLM's internal APIs:

  1. Authentication: Opens a browser for Google login, extracts cookies
  2. Session: Creates a headless browser session with injected cookies
  3. API Calls: Executes fetch() requests via page.evaluate() in browser context
  4. RPC Protocol: Communicates using NotebookLM's internal RPC format

This approach provides:

  • โœ… Full feature access (all 31 tools)
  • โœ… No API keys needed
  • โœ… Works with consumer Google accounts
  • โš ๏ธ Requires browser automation
  • โš ๏ธ Cookie refresh needed every 2-4 weeks

License

Apache License 2.0 - see LICENSE for details.

Disclaimer

This is an unofficial library. It uses NotebookLM's internal APIs which may change without notice. Use at your own risk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynotebooklm-0.21.0.tar.gz (73.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynotebooklm-0.21.0-py3-none-any.whl (79.4 kB view details)

Uploaded Python 3

File details

Details for the file pynotebooklm-0.21.0.tar.gz.

File metadata

  • Download URL: pynotebooklm-0.21.0.tar.gz
  • Upload date:
  • Size: 73.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pynotebooklm-0.21.0.tar.gz
Algorithm Hash digest
SHA256 0445ae0ba41cc5756f64bda314eaddd656ce0096cdf64be0b311b01ac922a107
MD5 998d525a80966f5bba15124c97d3fa07
BLAKE2b-256 276eac42c7b6360320fb0b0efb680e49d09d4137220c54010fc8a8569bebb514

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynotebooklm-0.21.0.tar.gz:

Publisher: publish.yml on Experto-AI/pynotebooklm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pynotebooklm-0.21.0-py3-none-any.whl.

File metadata

  • Download URL: pynotebooklm-0.21.0-py3-none-any.whl
  • Upload date:
  • Size: 79.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pynotebooklm-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d77ae2085562f1d1d1eb4e9be8e9e949640ad372e5773407dff4ebdc8a90c53
MD5 6257591a2ae466590208b4d3051938b9
BLAKE2b-256 16de53d5de143064d43b425ce41aa4d680eefb9fce3c900abc2349a0e80ee145

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynotebooklm-0.21.0-py3-none-any.whl:

Publisher: publish.yml on Experto-AI/pynotebooklm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page