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

@pageindex/sdk

v0.8.0

Published

PageIndex SDK - Document processing for AI applications via REST API and MCP

Readme

@pageindex/sdk

TypeScript SDK for PageIndex — upload documents, retrieve tree structures, and chat with your PDFs.

Get your API Key at dash.pageindex.ai. Full docs at docs.pageindex.ai/js-sdk.

Installation

npm install @pageindex/sdk

Quick Start

import { PageIndexClient } from '@pageindex/sdk';
import { readFileSync } from 'fs';

const client = new PageIndexClient({ apiKey: 'YOUR_API_KEY' });

// Upload a document
const file = readFileSync('./report.pdf');
const { doc_id } = await client.api.submitDocument(file, 'report.pdf');

// Get tree structure
const tree = await client.api.getTree(doc_id);

// Chat with the document
const response = await client.api.chatCompletions({
  messages: [{ role: 'user', content: 'What are the key findings?' }],
  doc_id,
});
console.log(response.choices[0].message.content);

// Stream a response
const stream = await client.api.chatCompletions({
  messages: [{ role: 'user', content: 'Summarize this document' }],
  doc_id,
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}

Configuration

const client = new PageIndexClient({
  apiKey: 'YOUR_API_KEY', // Required
  apiUrl: 'https://...', // Default: https://api.pageindex.ai
  folderScope: 'folder-id', // Restrict all operations to a folder
});

REST API (client.api)

| Method | Description | | ------------------------------------------ | ----------------------------------------------- | | submitDocument(file, fileName, options?) | Upload a document | | getTree(docId, options?) | Get tree structure and processing status | | getDocument(docId) | Get document metadata | | listDocuments(options?) | List documents (paginated) | | deleteDocument(docId) | Delete a document | | createFolder(options) | Create a folder | | listFolders(options?) | List folders | | chatCompletions(params) | Chat with documents (streaming & non-streaming) |

Chat API

Supports non-streaming, streaming, multi-document, metadata streaming, and citations. See Chat API docs for full reference.

// Multi-document chat
await client.api.chatCompletions({
  messages: [{ role: 'user', content: 'Compare these' }],
  doc_id: ['doc-1', 'doc-2'],
});

// Streaming with tool call metadata
const stream = await client.api.chatCompletions({
  messages,
  doc_id,
  stream: true,
  stream_metadata: true,
});
for await (const chunk of stream) {
  if (chunk.block_metadata?.type === 'mcp_tool_use_start') {
    console.log(`[Using: ${chunk.block_metadata.tool_name}]`);
  }
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}

MCP Tools (client.tools)

Typed wrappers for PageIndex MCP — for building custom AI agent integrations. See MCP Tools docs.

| Method | Description | | -------------------------------- | ---------------------------- | | recentDocuments(params?) | List recent uploads | | findRelevantDocuments(params?) | Search documents | | getDocument(params) | Get document details by name | | getDocumentStructure(params) | Extract document outline | | getPageContent(params) | Read page content | | getDocumentImage(params) | Retrieve embedded image | | removeDocument(params) | Delete documents (batch) | | listFolders(params?) | List folders |

Error Handling

import { PageIndexError } from '@pageindex/sdk';

try {
  await client.api.getDocument('invalid-id');
} catch (error) {
  if (error instanceof PageIndexError) {
    console.log(error.code); // "NOT_FOUND" | "UNAUTHORIZED" | "PLAN_REQUIRED" | ...
    console.log(error.message);
  }
}

Examples

Links

License

MIT