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-node-sdk

v1.0.5

Published

Node-first TypeScript SDK for the PageIndex API

Readme

PageIndex Node SDK (pageindex-node-sdk)

Node-first TypeScript SDK for the PageIndex API.
PageIndex is a vectorless, reasoning-based RAG framework that turns long, complex documents into a tree-structured index and lets LLMs perform agentic reasoning over that structure for context‑aware, traceable retrieval — with no vector database and no chunking required.
This SDK wraps the core HTTP endpoints (PDF upload, document status/tree/OCR, listing, deletion, and Chat API with streaming) for easy use from Node.js.

Install

npm install pageindex-node-sdk
# or
yarn add pageindex-node-sdk

Requirements

  • Node.js >= 18 (uses built‑in fetch, FormData, ReadableStream)
  • A PageIndex API key from the Developer Dashboard

Quickstart (TypeScript / ESM)

import { PageIndexClient } from "pageindex-node-sdk";

const client = new PageIndexClient({
  apiKey: process.env.PAGEINDEX_API_KEY!,
});

async function main() {
  // 1) Upload a PDF
  const { doc_id } = await client.submitDocumentFromPath({
    path: "./2023-annual-report.pdf",
  });
  console.log("doc_id:", doc_id);

  // 2) Poll until tree processing is complete
  let status = "processing";
  while (status !== "completed") {
    const doc = await client.getTree(doc_id);
    status = doc.status;
    console.log("status:", status, "retrieval_ready:", doc.retrieval_ready);
    if (status !== "completed") {
      await new Promise((r) => setTimeout(r, 1500));
    }
  }

  // 3) Non‑streaming chat
  const chat = await client.chatCompletions({
    doc_id,
    messages: [
      { role: "user", content: "What are the key findings in this document?" },
    ],
    enable_citations: true,
  });
  console.log(chat.choices?.[0]?.message?.content);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Streaming chat example

import { PageIndexClient } from "pageindex-node-sdk";

const client = new PageIndexClient({
  apiKey: process.env.PAGEINDEX_API_KEY!,
});

async function streamChat(docId: string) {
  for await (const evt of client.chatCompletionsStream({
    doc_id: docId,
    messages: [
      { role: "user", content: "Summarize this document in 5 bullet points." },
    ],
    enable_citations: true,
  })) {
    if (evt.type === "data") {
      const delta = evt.data.choices?.[0]?.delta?.content ?? "";
      if (delta) process.stdout.write(delta);
    } else if (evt.type === "done") {
      break;
    }
  }
  process.stdout.write("\n");
}

API overview

All methods live on PageIndexClient:

  • Constructor

    • new PageIndexClient({ apiKey, baseUrl?, fetch? })
      • apiKey (required): your PageIndex API key (sent via api_key header).
      • baseUrl (optional): defaults to https://api.pageindex.ai.
      • fetch (optional): custom fetch implementation (e.g. for tests).
  • PDF processing

    • submitDocument({ file, filename?, mode? })
      • Wraps POST /doc/ with multipart/form-data.
    • submitDocumentFromPath({ path, filename?, mode? })
      • Node‑only helper that reads a local PDF and calls submitDocument.
  • Document results

    • getDocument(docId, { type?, format?, summary? })
      • Generic wrapper over GET /doc/{doc_id}/.
    • getTree(docId, { summary? })
      • Convenience wrapper for type=tree.
    • getOcr(docId, { format? })
      • Convenience wrapper for type=ocr + format=page|node|raw.
  • Metadata & management

    • getDocumentMetadata(docId)
      • GET /doc/{doc_id}/metadata
    • listDocuments({ limit?, offset? })
      • GET /docs
    • deleteDocument(docId)
      • DELETE /doc/{doc_id}/
  • Chat API (beta)

    • chatCompletions(request)
      • Non‑streaming POST /chat/completions.
    • chatCompletionsStream(request)
      • Streaming via Server‑Sent Events (SSE); yields parsed events with:
        • type: "data" | "done" | "comment"
        • data: parsed chunk (when type === "data").

The request/response shapes are aligned with the official PageIndex API reference.


Contribution Guidelines

  • Issues & feature requests

    • Open a GitHub issue with:
      • A clear description of the problem or feature.
      • Steps to reproduce (if applicable).
      • Environment details (Node version, OS).
  • Pull requests

    • Fork the repository.
    • Create a feature branch (feat/my-feature or fix/my-bug).
    • Ensure:
      • npm run typecheck passes.
      • npm run lint passes.
    • Write clear commit messages and, where useful, update this README.md or code comments for non-obvious behavior.
  • Code style

    • Follow existing patterns in src/pageindex-client.ts and src/types.ts.
    • Prefer small, focused PRs.

License

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


Repository

Source code and issue tracking live on GitHub:
https://github.com/coolpinkzz/pageindex-node-sdk