🚨 Fork Status: This is a maintained fork of
teng-lin/notebooklm-pycontaining critical fixes for:
- Source Addition: Fixed
add_url_sourceandadd_file_sourceparameters to match updated NotebookLM API (11-element array structure).- Artifact Generation: Improved monitoring and status parsing for artifacts (Audio, Infographic, etc.).
Install this version:
pip install git+https://github.com/Tatine13/notebooklm-py.git@main
Unofficial Python library for automating Google NotebookLM. Full programmatic access to NotebookLM's features—including capabilities the web UI doesn't expose—from Python or the command line.
Google NotebookLM is powerful, but:
- No official API exists.
- The web UI is manual and hard to automate.
- Chatbots and agents can't easily interface with it.
notebooklm-py solves this by reverse-engineering the internal RPC protocol, giving you a robust Python client that behaves like a real user but running at code speed.
- Auth & Session Management: Handles cookies, headers, and token refresh automatically.
- Full Source Support: Add URLs (incl. YouTube), PDFs, text files, MP3s, and Google Drive docs.
- Chat Interface: Send queries and get referenced answers (citations included).
- Artifact Generation: Programmatically trigger Audio Overviews (podcasts), blog posts, FAQs, and study guides.
- Rich Responses: Parse complex RPC responses into clean Pydantic models.
pip install notebooklm-pyFor Playwright-based login (recommended for initial auth):
pip install "notebooklm-py[browser]"
playwright install chromiumfrom notebooklm.auth import GoogleAuth
# Opens browser for login, saves credentials to local storage
await GoogleAuth().login()import asyncio
from notebooklm import NotebookLMClient
async def main():
async with NotebookLMClient() as client:
# Create a new notebook
notebook = await client.create_notebook("My AI Research")
print(f"Created notebook: {notebook.title} ({notebook.id})")
# Add a source (e.g., Wikipedia)
await client.add_source(notebook.id, "https://en.wikipedia.org/wiki/Artificial_intelligence")
# Ask a question
chat_response = await client.query(notebook.id, "Summarize the history of AI")
print(chat_response.answer)
if __name__ == "__main__":
asyncio.run(main())See examples/ for more advanced usage patterns.
Currently under active development. APIs may change.
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytestMIT