npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@penpoint/js

v0.1.4

Published

Official TypeScript/JavaScript client library for the Penpoint API

Readme

Penpoint JavaScript/TypeScript Client

Official JavaScript/TypeScript client library for the Penpoint API. This library provides a modern, type-safe interface for interacting with Penpoint's document processing and reference search capabilities.

Features

  • TypeScript First: Full TypeScript support with comprehensive type definitions
  • Modern JavaScript: ES2020+ features with CommonJS and ESM support
  • File Management: Upload, list, update, and delete files
  • Discrete References: Search documents with three levels of precision (Basic, Standard, Advanced)
  • File Markup: Generate marked-up versions of documents with highlighted references
  • Error Handling: Comprehensive error handling with custom error classes
  • Retry Logic: Built-in retry mechanism with exponential backoff
  • Browser & Node.js: Works in both browser and Node.js environments

Installation

npm install @penpoint/js

Quick Start

import { PenpointClient } from '@penpoint/js';

// Initialize the client with your API key
const client = new PenpointClient({
  apiKey: 'your_api_key_here'
});

// List files
const files = await client.files.list({ limit: 20 });

// Upload a file
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
const file = fileInput.files?.[0];
if (file) {
  const uploadedFile = await client.files.upload({
    file,
    filename: file.name,
    summary: 'A sample document for testing'
  });
  
  // Search for references
  const references = await client.discreteReferences.basic(
    uploadedFile.id,
    'CMake integration',
    true,
    '#362580'
  );
  
  console.log(`Found ${references.refs.parts.length} references`);
}

API Reference

Authentication

All API requests require an API key, which should be passed in the x-api-key header.

Client Configuration

const client = new PenpointClient({
  apiKey: 'your_api_key',
  baseUrl: 'https://api.penpoint.ai/v1', // Optional, defaults to production
  timeout: 30000, // Optional, defaults to 30 seconds
  maxRetries: 3,  // Optional, defaults to 3
  userAgent: 'custom-user-agent' // Optional
});

Files

List Files

const files = await client.files.list({
  limit: 20,
  offset: 0
});

Upload File

const uploadedFile = await client.files.upload({
  file: fileObject, // File, Buffer, or string
  filename: 'document.pdf',
  summary: 'Document description'
});

Update File

const updatedFile = await client.files.update(123, {
  summary: 'Updated description',
  expirationDate: '2025-12-31'
});

Delete File

const success = await client.files.delete(123);

Get File

const file = await client.files.get(123);

Discrete References

Basic Search

const references = await client.discreteReferences.basic(
  123, // fileId
  'search term', // prompt
  true, // markupFile
  '#FF0000' // markupColor (optional)
);

Standard Search

const references = await client.discreteReferences.standard(
  123, // fileId
  'search term', // prompt
  true, // markupFile
  '#FF0000' // markupColor (optional)
);

Advanced Search

const references = await client.discreteReferences.advanced(
  123, // fileId
  'search term', // prompt
  true, // markupFile
  '#FF0000' // markupColor (optional)
);

Error Handling

The library provides comprehensive error handling:

import { PenpointError, PenpointApiError, PenpointValidationError } from '@penpoint/js';

try {
  const files = await client.files.list();
} catch (error) {
  if (error instanceof PenpointApiError) {
    console.error(`API Error: ${error.status} - ${error.message}`);
  } else if (error instanceof PenpointValidationError) {
    console.error(`Validation Error: ${error.message}`);
  } else if (error instanceof PenpointError) {
    console.error(`Client Error: ${error.message}`);
  } else {
    console.error('Unknown error:', error);
  }
}

Advanced Usage

Custom HTTP Client

const httpClient = client.getHttpClient();

// Make custom requests
const response = await httpClient.get('/custom-endpoint', {
  query: { param: 'value' },
  headers: { 'Custom-Header': 'value' }
});

File Upload with Buffer (Node.js)

import { readFileSync } from 'fs';

const buffer = readFileSync('document.pdf');
const uploadedFile = await client.files.upload({
  file: buffer,
  filename: 'document.pdf',
  summary: 'PDF document'
});

Browser vs Node.js

Browser Environment

  • Uses native fetch API
  • Supports File objects for uploads
  • FormData for multipart requests

Node.js Environment

  • Requires node-fetch (peer dependency)
  • Supports Buffer for file uploads
  • Full Node.js compatibility

Development

Setup

git clone https://github.com/penpoint/penpoint-js.git
cd penpoint-js
npm install

Available Scripts

npm run build          # Build the library
npm run dev            # Build in watch mode
npm run test           # Run tests
npm run test:watch     # Run tests in watch mode
npm run test:coverage  # Run tests with coverage
npm run lint           # Run ESLint
npm run lint:fix       # Fix ESLint issues
npm run format         # Format code with Prettier
npm run type-check     # Run TypeScript type checking
npm run docs           # Generate documentation

Testing

npm test                    # Run all tests
npm run test:coverage      # Run tests with coverage
npm run test:watch         # Run tests in watch mode

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support