api

package
v0.0.0-...-a3be9c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package api provides the NotebookLM API client.

Package api provides test helpers for debugging and development

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertProjectValid

func AssertProjectValid(t *testing.T, p *pb.Project)

AssertProjectValid validates a project has required fields

func AssertSourceValid

func AssertSourceValid(t *testing.T, s *pb.Source)

AssertSourceValid validates a source has required fields

func DebugDirectRequest

func DebugDirectRequest(t *testing.T)

DebugDirectRequest is a helper function for debugging direct API requests It can be used to test raw batchexecute protocol interactions

func DebugHTTPRecorder

func DebugHTTPRecorder(t *testing.T)

DebugHTTPRecorder is a helper function for debugging HTTP recording issues It can be called from tests when needed for troubleshooting

func GenerateMockResponse

func GenerateMockResponse(rpcID string, data interface{}) string

GenerateMockResponse creates a mock batchexecute response for testing

func TestDataPath

func TestDataPath(filename string) string

TestDataPath returns the path to test data files

Types

type AudioOverviewResult

type AudioOverviewResult struct {
	ProjectID string
	AudioID   string
	Title     string
	AudioData string // Base64 encoded audio data
	IsReady   bool
}

AudioOverviewResult represents an audio overview response

func (*AudioOverviewResult) GetAudioBytes

func (r *AudioOverviewResult) GetAudioBytes() ([]byte, error)

GetAudioBytes returns the decoded audio data

func (*AudioOverviewResult) SaveAudioToFile

func (r *AudioOverviewResult) SaveAudioToFile(filename string) error

SaveAudioToFile saves audio data to a file

type ChunkedResponseParser

type ChunkedResponseParser struct {
	Raw   string
	Debug bool
	// contains filtered or unexported fields
}

ChunkedResponseParser is a specialized parser for NotebookLM's chunked response format which parses the special format used for the ListRecentlyViewedProjects response

func NewChunkedResponseParser

func NewChunkedResponseParser(raw string) *ChunkedResponseParser

NewChunkedResponseParser creates a new parser for the given raw response

func (*ChunkedResponseParser) DebugPrint

func (p *ChunkedResponseParser) DebugPrint()

DebugPrint prints the chunked response analysis for debugging

func (*ChunkedResponseParser) ParseJSONArray

func (p *ChunkedResponseParser) ParseJSONArray() ([]interface{}, error)

ParseJSONArray parses a JSON array from the response with robust error handling

func (*ChunkedResponseParser) ParseListProjectsResponse

func (p *ChunkedResponseParser) ParseListProjectsResponse() ([]*pb.Project, error)

ParseListProjectsResponse extracts projects from the raw response with fallback mechanisms

func (*ChunkedResponseParser) SanitizeResponse

func (p *ChunkedResponseParser) SanitizeResponse(input string) string

SanitizeResponse removes any trailing or invalid content from the response This is particularly useful for handling trailing digits like "25" in the error case

func (*ChunkedResponseParser) TryParseAsJSONArray

func (p *ChunkedResponseParser) TryParseAsJSONArray() ([]interface{}, error)

TryParseAsJSONArray attempts to extract and parse a JSON array from the response This is a fallback approach for the specific error in the requirements

func (*ChunkedResponseParser) WithDebug

func (p *ChunkedResponseParser) WithDebug(debug bool) *ChunkedResponseParser

WithDebug enables debug output for this parser

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles NotebookLM API interactions.

func CreateMockClient

func CreateMockClient(t *testing.T) *Client

CreateMockClient creates a client configured for testing with mock responses

func New

func New(authToken, cookies string, opts ...batchexecute.Option) *Client

New creates a new NotebookLM API client.

func (*Client) ActOnSources

func (c *Client) ActOnSources(projectID string, action string, sourceIDs []string) error

func (*Client) AddSourceFromBase64

func (c *Client) AddSourceFromBase64(projectID string, content, filename, contentType string) (string, error)

func (*Client) AddSourceFromFile

func (c *Client) AddSourceFromFile(projectID string, filepath string, contentType ...string) (string, error)

func (*Client) AddSourceFromReader

func (c *Client) AddSourceFromReader(projectID string, r io.Reader, filename string, contentType ...string) (string, error)

func (*Client) AddSourceFromText

func (c *Client) AddSourceFromText(projectID string, content, title string) (string, error)

func (*Client) AddSourceFromURL

func (c *Client) AddSourceFromURL(projectID string, url string) (string, error)

func (*Client) AddSources

func (c *Client) AddSources(projectID string, sources []*pb.SourceInput) (*pb.Project, error)

func (*Client) AddYouTubeSource

func (c *Client) AddYouTubeSource(projectID, videoID string) (string, error)

func (*Client) CheckSourceFreshness

func (c *Client) CheckSourceFreshness(sourceID string) (*pb.CheckSourceFreshnessResponse, error)

func (*Client) CreateAudioOverview

func (c *Client) CreateAudioOverview(projectID string, instructions string) (*AudioOverviewResult, error)

func (*Client) CreateNote

func (c *Client) CreateNote(projectID string, title string, initialContent string) (*Note, error)

func (*Client) CreateProject

func (c *Client) CreateProject(title string, emoji string) (*Notebook, error)

func (*Client) CreateVideoOverview

func (c *Client) CreateVideoOverview(projectID string, instructions string) (*VideoOverviewResult, error)

func (*Client) DeleteAudioOverview

func (c *Client) DeleteAudioOverview(projectID string) error

func (*Client) DeleteNotes

func (c *Client) DeleteNotes(projectID string, noteIDs []string) error

func (*Client) DeleteProjects

func (c *Client) DeleteProjects(projectIDs []string) error

func (*Client) DeleteSources

func (c *Client) DeleteSources(projectID string, sourceIDs []string) error

func (*Client) DownloadAudioOverview

func (c *Client) DownloadAudioOverview(projectID string) (*AudioOverviewResult, error)

DownloadAudioOverview attempts to download the actual audio file by trying different request types until it finds one with audio data

func (*Client) DownloadVideoOverview

func (c *Client) DownloadVideoOverview(projectID string) (*VideoOverviewResult, error)

DownloadVideoOverview attempts to download video overview data

func (*Client) DownloadVideoWithAuth

func (c *Client) DownloadVideoWithAuth(videoURL, filename string) error

DownloadVideoWithAuth downloads a video using the client's authentication

func (*Client) GenerateDocumentGuides

func (c *Client) GenerateDocumentGuides(projectID string) (*pb.GenerateDocumentGuidesResponse, error)

func (*Client) GenerateFreeFormStreamed

func (c *Client) GenerateFreeFormStreamed(projectID string, prompt string, sourceIDs []string) (*pb.GenerateFreeFormStreamedResponse, error)

func (*Client) GenerateFreeFormStreamedWithCallback

func (c *Client) GenerateFreeFormStreamedWithCallback(projectID string, prompt string, sourceIDs []string, callback func(chunk string) bool) error

GenerateFreeFormStreamedWithCallback streams the response and calls the callback for each chunk

func (*Client) GenerateMagicView

func (c *Client) GenerateMagicView(projectID string, sourceIDs []string) (*pb.GenerateMagicViewResponse, error)

func (*Client) GenerateNotebookGuide

func (c *Client) GenerateNotebookGuide(projectID string) (*pb.GenerateNotebookGuideResponse, error)

func (*Client) GenerateOutline

func (c *Client) GenerateOutline(projectID string) (*pb.GenerateOutlineResponse, error)

func (*Client) GenerateReportSuggestions

func (c *Client) GenerateReportSuggestions(projectID string) (*pb.GenerateReportSuggestionsResponse, error)

func (*Client) GenerateSection

func (c *Client) GenerateSection(projectID string) (*pb.GenerateSectionResponse, error)

func (*Client) GetAudioOverview

func (c *Client) GetAudioOverview(projectID string) (*AudioOverviewResult, error)

func (*Client) GetNotes

func (c *Client) GetNotes(projectID string) ([]*Note, error)

func (*Client) GetProject

func (c *Client) GetProject(projectID string) (*Notebook, error)

func (*Client) GetProjectWithContext

func (c *Client) GetProjectWithContext(ctx context.Context, projectID string) (*Notebook, error)

GetProjectWithContext is like GetProject but accepts a context for cancellation

func (*Client) GetVideoOverview

func (c *Client) GetVideoOverview(projectID string) (*VideoOverviewResult, error)

GetVideoOverview attempts to get a video overview for a notebook Since there's no official GetVideoOverview RPC endpoint, we try alternative approaches

func (*Client) ListArtifacts

func (c *Client) ListArtifacts(projectID string) ([]*pb.Artifact, error)

ListArtifacts returns artifacts for a project using direct RPC

func (*Client) ListAudioOverviews

func (c *Client) ListAudioOverviews(projectID string) ([]*AudioOverviewResult, error)

ListAudioOverviews returns audio overviews for a notebook

func (*Client) ListRecentlyViewedProjects

func (c *Client) ListRecentlyViewedProjects() ([]*Notebook, error)

func (*Client) ListVideoOverviews

func (c *Client) ListVideoOverviews(projectID string) ([]*VideoOverviewResult, error)

ListVideoOverviews returns video overviews for a notebook

func (*Client) LoadSource

func (c *Client) LoadSource(sourceID string) (*pb.Source, error)

func (*Client) MutateNote

func (c *Client) MutateNote(projectID string, noteID string, content string, title string) (*Note, error)

func (*Client) MutateProject

func (c *Client) MutateProject(projectID string, updates *pb.Project) (*Notebook, error)

func (*Client) MutateSource

func (c *Client) MutateSource(sourceID string, updates *pb.Source) (*pb.Source, error)

func (*Client) RefreshSource

func (c *Client) RefreshSource(sourceID string) (*pb.Source, error)

func (*Client) RemoveRecentlyViewedProject

func (c *Client) RemoveRecentlyViewedProject(projectID string) error

func (*Client) RenameArtifact

func (c *Client) RenameArtifact(artifactID, newTitle string) (*pb.Artifact, error)

RenameArtifact renames an artifact using the rc3d8d RPC endpoint

func (*Client) SetUseDirectRPC

func (c *Client) SetUseDirectRPC(use bool)

SetUseDirectRPC configures whether to use direct RPC calls

func (*Client) ShareAudio

func (c *Client) ShareAudio(projectID string, shareOption ShareOption) (*ShareAudioResult, error)

ShareAudio shares an audio overview with optional public access

func (*Client) ShareProject

func (c *Client) ShareProject(projectID string, settings *pb.ShareSettings) (*pb.ShareProjectResponse, error)

ShareProject shares a project with specified settings

func (*Client) StartDraft

func (c *Client) StartDraft(projectID string) (*pb.StartDraftResponse, error)

func (*Client) StartSection

func (c *Client) StartSection(projectID string) (*pb.StartSectionResponse, error)

type Note

type Note = pb.Source

type Notebook

type Notebook = pb.Project

type ShareAudioResult

type ShareAudioResult struct {
	ShareURL string
	ShareID  string
	IsPublic bool
}

ShareAudioResult represents the response from sharing audio

type ShareOption

type ShareOption int

ShareOption represents audio sharing visibility options

const (
	SharePrivate ShareOption = 0
	SharePublic  ShareOption = 1
)

type VideoOverviewResult

type VideoOverviewResult struct {
	ProjectID string
	VideoID   string
	Title     string
	VideoData string // Base64 encoded or URL
	IsReady   bool
}

func (*VideoOverviewResult) SaveVideoToFile

func (r *VideoOverviewResult) SaveVideoToFile(filename string) error

SaveVideoToFile saves video data to a file Handles both base64 encoded data and URLs NOTE: For URL downloads, use client.DownloadVideoWithAuth() for proper authentication

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL