notebooklm-py

raw JSON →
0.3.4 verified Mon Apr 27 auth: no python

Unofficial Python library for automating Google NotebookLM. Current version 0.3.4, requires Python >=3.10. Released under MIT license. Active development with frequent releases (multiple per month).

pip install notebooklm-py
error AttributeError: module 'notebooklm' has no attribute 'NotebookLMClient'
cause Trying to import NotebookLMClient from wrong location.
fix
Use: from notebooklm import NotebookLMClient
error ImportError: cannot import name 'SourceType' from 'notebooklm'
cause SourceType was moved to notebooklm.models in 0.3.0.
fix
Use: from notebooklm.models import SourceType
error RuntimeError: NotebookLMClient must be used inside an asyncio event loop
cause Attempting to use async client from sync context without event loop.
fix
Wrap code in async function and call with asyncio.run() or use CLI commands.
error ValueError: Invalid auth JSON or expired authentication
cause Auth JSON missing, malformed, or expired.
fix
Run 'notebooklm auth check --test' to validate. Set NOTEBOOKLM_AUTH_JSON env var with fresh token.
breaking Auth method changed: 0.3.0+ uses persistent cookie storage (notebooklm auth), not manual cookie passing.
fix Run 'notebooklm auth check' or use NotebookLMClient(auth_json=...) with the JSON env var.
breaking SourceType and ArtifactType moved to notebooklm.models in 0.3.0. Direct top-level import broken.
fix Change 'from notebooklm import SourceType' to 'from notebooklm.models import SourceType'.
breaking Exception hierarchy introduced in 0.3.0; generic exceptions replaced with 'from notebooklm.exceptions import *'.
fix Catch NotebookLMError from notebooklm.exceptions instead of generic Exception.
gotcha All async I/O must run in an event loop; blocking calls from sync context may hang on Windows.
fix Use async entry points or run with asyncio.run(). For sync cook, ensure ProactorEventLoop compatibility.
gotcha CLI conversation ID does not reset when switching notebooks; may cause answers from wrong notebook.
fix Upgrade to 0.3.2+ or manually clear conversation ID.

Initialize client (with auth JSON or interactive login), list notebooks, ask a question.

from notebooklm import NotebookLMClient
import os

client = NotebookLMClient(auth_json=os.environ.get('NOTEBOOKLM_AUTH_JSON', ''))

notebooks = client.notebooks.list()
if notebooks:
    notebook_id = notebooks[0].id
    result = client.chat.ask(notebook_id, 'What is the summary of this notebook?')
    print(result.answer)