Production-grade Python library for NotebookLM automation with 31 tools
Project description
PyNotebookLM
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 loginto refresh cookies. - Delete
~/.pynotebooklm/auth.jsonif cookies are corrupted, then login again.
Playwright Issues
- Ensure the browser is installed:
playwright install chromium - On Linux, install required system deps (see
Dockerfilefor 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:
- Authentication: Opens a browser for Google login, extracts cookies
- Session: Creates a headless browser session with injected cookies
- API Calls: Executes
fetch()requests viapage.evaluate()in browser context - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0445ae0ba41cc5756f64bda314eaddd656ce0096cdf64be0b311b01ac922a107
|
|
| MD5 |
998d525a80966f5bba15124c97d3fa07
|
|
| BLAKE2b-256 |
276eac42c7b6360320fb0b0efb680e49d09d4137220c54010fc8a8569bebb514
|
Provenance
The following attestation bundles were made for pynotebooklm-0.21.0.tar.gz:
Publisher:
publish.yml on Experto-AI/pynotebooklm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynotebooklm-0.21.0.tar.gz -
Subject digest:
0445ae0ba41cc5756f64bda314eaddd656ce0096cdf64be0b311b01ac922a107 - Sigstore transparency entry: 912355079
- Sigstore integration time:
-
Permalink:
Experto-AI/pynotebooklm@cac937c168178c39a5d570fabda44c577eb87119 -
Branch / Tag:
refs/tags/0.21.0 - Owner: https://github.com/Experto-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cac937c168178c39a5d570fabda44c577eb87119 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d77ae2085562f1d1d1eb4e9be8e9e949640ad372e5773407dff4ebdc8a90c53
|
|
| MD5 |
6257591a2ae466590208b4d3051938b9
|
|
| BLAKE2b-256 |
16de53d5de143064d43b425ce41aa4d680eefb9fce3c900abc2349a0e80ee145
|
Provenance
The following attestation bundles were made for pynotebooklm-0.21.0-py3-none-any.whl:
Publisher:
publish.yml on Experto-AI/pynotebooklm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynotebooklm-0.21.0-py3-none-any.whl -
Subject digest:
5d77ae2085562f1d1d1eb4e9be8e9e949640ad372e5773407dff4ebdc8a90c53 - Sigstore transparency entry: 912355128
- Sigstore integration time:
-
Permalink:
Experto-AI/pynotebooklm@cac937c168178c39a5d570fabda44c577eb87119 -
Branch / Tag:
refs/tags/0.21.0 - Owner: https://github.com/Experto-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cac937c168178c39a5d570fabda44c577eb87119 -
Trigger Event:
push
-
Statement type: