Skip to main content

JavaScript/TypeScript SDK

npm version License: MIT The official JavaScript/TypeScript SDK for interacting with Plugged.in’s Library API. Easily manage documents, create AI-generated content, and perform RAG queries with full type safety.

NPM Package

View on NPM Registry

GitHub Repository

Source code and examples

Installation

Quick Start

Authentication

Get your API key from your Plugged.in Profile and configure the client:

Core Features

Document Management

List Documents

Get Document

Search Documents

Create AI-Generated Document

Update Document

RAG Operations

Simple Query

Query with Sources

Find Relevant Documents

File Uploads

Important: Direct file uploads are no longer exposed via the public API. The client.uploads helpers now throw descriptive errors so existing code fails fast. Use the Plugged.in web interface or the forthcoming ingestion workflow for binary files. AI-generated content can still be created with client.documents.create or client.uploads.uploadDocument.

Error Handling

The SDK provides typed error classes for better error handling:

TypeScript Support

The SDK is written in TypeScript and provides comprehensive type definitions:

Advanced Configuration

Environment Variables

Custom HTTP Client

PAP Agents

The SDK provides full support for managing PAP (Plugged.in Agent Protocol) agents:

Creating Agents

Listing and Managing Agents

Heartbeats and Metrics

CRITICAL: Heartbeats contain ONLY liveness data. Resource telemetry goes in metrics (separate channel). This separation is PAP’s zombie prevention superpower.

Agent States

Agents follow the PAP lifecycle state machine:
See PAP Agents Documentation for complete details on the Plugged.in Agent Protocol.

Rate Limiting

The SDK automatically handles rate limiting with exponential backoff:
  • API Endpoints: 60 requests per minute
  • Document Search: 10 requests per hour for AI document creation
  • RAG Queries: Subject to plan limits

Browser Support

The SDK works in both Node.js and browser environments:

Examples

Complete working examples are available in the GitHub repository:

API Reference

Client Options

Document Methods

RAG Methods

Upload Methods

All binary upload helpers now throw descriptive errors because the public API no longer exposes direct upload endpoints. Use the web interface or upcoming ingestion pipeline for file uploads.

Clipboard Methods

Agent Methods

See PAP Agents API Reference for complete endpoint documentation.

Clipboard (Memory) Service

The Clipboard service provides persistent key-value storage for MCP tools and AI agents.

Named Access

Indexed (Stack) Access

List All Entries

TypeScript Types

Support