Last updated

JavaScript/TypeScript SDK

The Papr TypeScript SDK provides a strongly-typed client for interacting with the Papr API from Node.js and browser environments.

Installation

Install the SDK using npm:

npm install @papr/sdk

Or using yarn:

yarn add @papr/sdk

Requirements

  • HTTPS: The endpoint requires HTTPS protocol. HTTP connections will fail.
  • Environment Variable: Set PAPR_MEMORY_API_KEY in your environment before running.
  • X-Client-Type Header: This is automatically included by the SDK but can be customized if needed.
  • Authentication: Only use one auth method (X-API-Key takes precedence over Bearer token).

Quick Start

import { Papr } from '@papr/sdk';

const client = new Papr({
  apiKey: 'your_api_key'
});

// Add a memory
const memory = await client.memory.add({
  content: "Important meeting notes from today's discussion",
  metadata: {
    topics: ["meetings", "notes"],
    created_at: new Date().toISOString()
  }
});

// Search memories
const results = await client.memory.search({
  query: "meeting notes from today"
});

Documentation

For complete documentation, examples, and API reference, visit our TypeScript SDK repository.

Features

  • Full TypeScript support with comprehensive type definitions
  • Promise-based async API
  • Automatic retries and error handling
  • Browser and Node.js compatibility
  • Comprehensive documentation and examples

Error Handling

The SDK uses typed errors to help you handle different failure cases:

try {
  await client.memory.add({...});
} catch (err) {
  if (err instanceof Papr.APIError) {
    // Handle API errors
  } else if (err instanceof Papr.NetworkError) {
    // Handle network errors
  }
}