Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Query Google NotebookLM notebooks from Claude Code for source-grounded, citation-backed answers from Gemini.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/api_reference.md
1# NotebookLM Skill API Reference23Complete API documentation for all NotebookLM skill modules.45## Important: Always Use run.py Wrapper67**All commands must use the `run.py` wrapper to ensure proper environment:**89```bash10# ✅ CORRECT:11python scripts/run.py [script_name].py [arguments]1213# ❌ WRONG:14python scripts/[script_name].py [arguments] # Will fail without venv!15```1617## Core Scripts1819### ask_question.py20Query NotebookLM with automated browser interaction.2122```bash23# Basic usage24python scripts/run.py ask_question.py --question "Your question"2526# With specific notebook27python scripts/run.py ask_question.py --question "..." --notebook-id notebook-id2829# With direct URL30python scripts/run.py ask_question.py --question "..." --notebook-url "https://..."3132# Show browser (debugging)33python scripts/run.py ask_question.py --question "..." --show-browser34```3536**Parameters:**37- `--question` (required): Question to ask38- `--notebook-id`: Use notebook from library39- `--notebook-url`: Use URL directly40- `--show-browser`: Make browser visible4142**Returns:** Answer text with follow-up prompt appended4344### notebook_manager.py45Manage notebook library with CRUD operations.4647```bash48# Smart Add (discover content first)49python scripts/run.py ask_question.py --question "What is the content of this notebook? What topics are covered? Provide a complete overview briefly and concisely" --notebook-url "[URL]"50# Then add with discovered info51python scripts/run.py notebook_manager.py add \52--url "https://notebooklm.google.com/notebook/..." \53--name "Name" \54--description "Description" \55--topics "topic1,topic2"5657# Direct add (when you know the content)58python scripts/run.py notebook_manager.py add \59--url "https://notebooklm.google.com/notebook/..." \60--name "Name" \61--description "What it contains" \62--topics "topic1,topic2"6364# List notebooks65python scripts/run.py notebook_manager.py list6667# Search notebooks68python scripts/run.py notebook_manager.py search --query "keyword"6970# Activate notebook71python scripts/run.py notebook_manager.py activate --id notebook-id7273# Remove notebook74python scripts/run.py notebook_manager.py remove --id notebook-id7576# Show statistics77python scripts/run.py notebook_manager.py stats78```7980**Commands:**81- `add`: Add notebook (requires --url, --name, --topics)82- `list`: Show all notebooks83- `search`: Find notebooks by keyword84- `activate`: Set default notebook85- `remove`: Delete from library86- `stats`: Display library statistics8788### auth_manager.py89Handle Google authentication and browser state.9091```bash92# Setup (browser visible for login)93python scripts/run.py auth_manager.py setup9495# Check status96python scripts/run.py auth_manager.py status9798# Re-authenticate99python scripts/run.py auth_manager.py reauth100101# Clear authentication102python scripts/run.py auth_manager.py clear103```104105**Commands:**106- `setup`: Initial authentication (browser MUST be visible)107- `status`: Check if authenticated108- `reauth`: Clear and re-setup109- `clear`: Remove all auth data110111### cleanup_manager.py112Clean skill data with preservation options.113114```bash115# Preview cleanup116python scripts/run.py cleanup_manager.py117118# Execute cleanup119python scripts/run.py cleanup_manager.py --confirm120121# Keep library122python scripts/run.py cleanup_manager.py --confirm --preserve-library123124# Force without prompt125python scripts/run.py cleanup_manager.py --confirm --force126```127128**Options:**129- `--confirm`: Actually perform cleanup130- `--preserve-library`: Keep notebook library131- `--force`: Skip confirmation prompt132133### run.py134Script wrapper that handles environment setup.135136```bash137# Usage138python scripts/run.py [script_name].py [arguments]139140# Examples141python scripts/run.py auth_manager.py status142python scripts/run.py ask_question.py --question "..."143```144145**Automatic actions:**1461. Creates `.venv` if missing1472. Installs dependencies1483. Activates environment1494. Executes target script150151## Python API Usage152153### Using subprocess with run.py154155```python156import subprocess157import json158159# Always use run.py wrapper160result = subprocess.run([161"python", "scripts/run.py", "ask_question.py",162"--question", "Your question",163"--notebook-id", "notebook-id"164], capture_output=True, text=True)165166answer = result.stdout167```168169### Direct imports (after venv exists)170171```python172# Only works if venv is already created and activated173from notebook_manager import NotebookLibrary174from auth_manager import AuthManager175176library = NotebookLibrary()177notebooks = library.list_notebooks()178179auth = AuthManager()180is_auth = auth.is_authenticated()181```182183## Data Storage184185Location: `~/.claude/skills/notebooklm/data/`186187```188data/189├── library.json # Notebook metadata190├── auth_info.json # Auth status191└── browser_state/ # Browser cookies192└── state.json193```194195**Security:** Protected by `.gitignore`, never commit.196197## Environment Variables198199Optional `.env` file configuration:200201```env202HEADLESS=false # Browser visibility203SHOW_BROWSER=false # Default display204STEALTH_ENABLED=true # Human behavior205TYPING_WPM_MIN=160 # Typing speed206TYPING_WPM_MAX=240207DEFAULT_NOTEBOOK_ID= # Default notebook208```209210## Error Handling211212Common patterns:213214```python215# Using run.py prevents most errors216result = subprocess.run([217"python", "scripts/run.py", "ask_question.py",218"--question", "Question"219], capture_output=True, text=True)220221if result.returncode != 0:222error = result.stderr223if "rate limit" in error.lower():224# Wait or switch accounts225pass226elif "not authenticated" in error.lower():227# Run auth setup228subprocess.run(["python", "scripts/run.py", "auth_manager.py", "setup"])229```230231## Rate Limits232233Free Google accounts: 50 queries/day234235Solutions:2361. Wait for reset (midnight PST)2372. Switch accounts with `reauth`2383. Use multiple Google accounts239240## Advanced Patterns241242### Parallel Queries243244```python245import concurrent.futures246import subprocess247248def query(question, notebook_id):249result = subprocess.run([250"python", "scripts/run.py", "ask_question.py",251"--question", question,252"--notebook-id", notebook_id253], capture_output=True, text=True)254return result.stdout255256# Run multiple queries simultaneously257with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:258futures = [259executor.submit(query, q, nb)260for q, nb in zip(questions, notebooks)261]262results = [f.result() for f in futures]263```264265### Batch Processing266267```python268def batch_research(questions, notebook_id):269results = []270for question in questions:271result = subprocess.run([272"python", "scripts/run.py", "ask_question.py",273"--question", question,274"--notebook-id", notebook_id275], capture_output=True, text=True)276results.append(result.stdout)277time.sleep(2) # Avoid rate limits278return results279```280281## Module Classes282283### NotebookLibrary284- `add_notebook(url, name, topics)`285- `list_notebooks()`286- `search_notebooks(query)`287- `get_notebook(notebook_id)`288- `activate_notebook(notebook_id)`289- `remove_notebook(notebook_id)`290291### AuthManager292- `is_authenticated()`293- `setup_auth(headless=False)`294- `get_auth_info()`295- `clear_auth()`296- `validate_auth()`297298### BrowserSession (internal)299- Handles browser automation300- Manages stealth behavior301- Not intended for direct use302303## Best Practices3043051. **Always use run.py** - Ensures environment3062. **Check auth first** - Before operations3073. **Handle rate limits** - Implement retries3084. **Include context** - Questions are independent3095. **Clean sessions** - Use cleanup_manager