Node SDK Reference
Complete method reference with request examples and responses.
Installation & Initialization
Install the SDK and create a client instance. Pass your API key directly or via the KB_API_KEY environment variable.
new KBClient(options)Creates a new client. Throws if no API key is provided.
kb.health()Returns server health status.
kb.me()Returns the authenticated user profile.
Knowledge Bases
Create and manage knowledge bases that store your scraped and processed content.
kb.create(name, options?)→ KnowledgeBaseCreates a new knowledge base.
kb.list()→ KnowledgeBase[]Lists all knowledge bases owned by the authenticated user.
kb.get(kbId)→ KnowledgeBaseFetches a single knowledge base with stats.
kb.stats(kbId)→ KBStatsReturns aggregated stats for a knowledge base.
kb.deleteKb(kbId)Permanently deletes a knowledge base and all its contents.
Scrape
Extract content from a single URL and store it in a knowledge base. Returns immediately with a job_id — poll kb.job() to track progress.
kb.scrape(kbId, url, options?)→ JobRefCrawl
Recursively crawl a website from a root URL and store every discovered page. The worker polls Sarvcrawl until complete (up to 15 min).
kb.crawl(kbId, url, options?)→ JobRefSearch
Run a web search query, scrape the top results, and store them in a knowledge base.
kb.search(kbId, query, options?)→ JobRefMap
Discover all URLs on a site without extracting page content. Useful for auditing structure or planning crawls.
kb.map(kbId, url, options?)→ JobRefUpload
Parse and index a local file — PDF, DOCX, XLSX, CSV, images, and more. OCR fallback is applied for scanned PDFs.
kb.upload(kbId, filePath, options?)→ JobRefMonitor
Create a recurring check that re-scrapes a page (or re-crawls a site), diffs it against the last check, and POSTs a webhook when something is new, changed, or removed. Unlike other jobs, a monitor never "completes" — it stays "running" indefinitely by design. Output is always markdown, there's no formats/scrapeOptions field.
kb.monitor(kbId, monitorType, options)→ JobRef"page" mode watches one or more exact URLs (pass urls). "website" mode crawls a whole site and watches every discovered page (pass url, plus optional limit/include_paths/exclude_paths). schedule accepts natural language ("daily", "every 30 minutes") or a cron expression — a minimum interval is enforced server-side. notify_url is required.
Job Management
Poll, list, cancel, and inspect jobs. Job status transitions: queued → running → completed / failed.
kb.job(jobId)→ JobFetches full details and current status for a job.
kb.jobs(options?)→ Job[]Lists jobs with optional filters.
kb.cancelJob(jobId)Cancels a running or queued job. For a monitor job (which stays "running" indefinitely by design), this is the correct way to stop the recurring check — required before deleteJob() will succeed.
kb.deleteJob(jobId)Permanently deletes a job and its stored pages. Refuses jobs in "running"/"queued" status — monitor jobs must be cancelled with cancelJob() first.
kb.jobLogs(jobId)→ JobLog[]Returns processing logs for a job.
kb.jobAudit(jobId)→ AuditReportReturns a diff-audit comparing the source PDF against the extracted markdown.
Pages & Search
Browse pages stored in a knowledge base, retrieve their content, and run full-text search.
kb.pages(kbId, options?)→ PageSummary[]Lists all pages stored in a knowledge base.
kb.page(kbId, pageId, format?)→ PageContentFetches the stored content of a page in the requested format.
kb.searchKb(kbId, q, options?)→ SearchResponseFull-text Elasticsearch search over all pages in a knowledge base.
kb.embedSearchKb(kbId, q, options?)→ EmbedSearchResponseSemantic (hybrid) search over chunk embeddings — dense KNN + BM25 fused with RRF. Returns chunk-level hits ideal for RAG. Not paginated (no page param).
Files & Exports
Browse stored files, download individual files, and export jobs or entire knowledge bases as ZIP archives.
kb.kbJobs(kbId, options?)→ Job[]Lists all jobs belonging to a specific knowledge base.
kb.jobFiles(kbId, jobId)→ FileEntry[]Lists all files stored by a job (markdown, JSON, HTML, etc.).
kb.downloadFile(kbId, jobId, filePath)→ BufferDownloads a single file by its storage path.
kb.exportJobZip(kbId, jobId)→ BufferDownloads all files from a single job as a ZIP archive.
kb.exportKbZip(kbId)→ BufferDownloads all pages across every job in a knowledge base as a single ZIP archive.
kb.exportKb(kbId, format?)→ AsyncIterable<Buffer>Streams a full KB export in JSONL or CSV format. Ideal for large exports that should not be buffered in memory.