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

infratex

v0.8.0

Published

Official Node.js SDK for the Infratex document intelligence API

Readme

Infratex Node.js SDK

Official Node.js / TypeScript SDK for the Infratex document intelligence API.

  • Parse PDFs into structured markdown
  • Parse ordered image batches into structured markdown
  • Build vector and hybrid search indexes
  • Semantic search across your documents
  • Stream AI-generated responses grounded in your data

Requires Node.js 18+. Zero runtime dependencies -- uses the native fetch API.

Install

npm install infratex

Quick start

import Infratex from 'infratex';

const client = new Infratex({ apiKey: 'infratex_sk_...' });

// Upload and parse a PDF
const doc = await client.documents.upload('./report.pdf');
console.log(doc.id, doc.page_count, 'pages');

// Upload an ordered image batch as document pages
const deck = await client.documents.uploadImages(['./page-1.png', './page-2.png'], {
  method: 'max',
});
console.log(deck.id, deck.page_count, 'pages');

// Index for search
// The SDK waits for the queued index by default.
await client.documents.index(doc.id, { method: 'vector' });

// Search
const { results } = await client.searches.create({
  query: 'quarterly revenue',
  method: 'vector',
  limit: 5,
  document_ids: [doc.id],
});

// Stream an AI response
const stream = await client.responses.create({
  message: 'Summarize the key findings',
  method: 'vector',
});

for await (const event of stream) {
  if (event.type === 'text') process.stdout.write(event.content);
}

API reference

new Infratex(config)

| Option | Type | Default | Description | |-----------|----------|------------------------------|------------------------| | apiKey | string | -- | Your API key | | baseUrl | string | https://api.infratex.io | API base URL override | | timeout | number | 300000 | Request timeout in ms |

Documents

// Upload from file path or Buffer
// The SDK keeps this as a single awaited call even though the raw HTTP API
// now creates the document first and polls until parsing completes.
const doc = await client.documents.upload('/path/to/file.pdf');
const doc = await client.documents.upload(buffer, { filename: 'report.pdf', method: 'standard' });
const richDoc = await client.documents.upload('/path/to/deck.pdf', { method: 'max' });

// Upload ordered images instead of a PDF
const images = await client.documents.uploadImages(['/tmp/page-1.png', '/tmp/page-2.png']);
const richImages = await client.documents.uploadImages(['/tmp/page-1.png', '/tmp/page-2.png'], {
  method: 'max',
  collection_id: 'col-id',
});

// Queue-first upload if you want to manage the parse lifecycle yourself
const queued = await client.documents.upload('/path/to/file.pdf', { wait: false });
const ready = await client.documents.get(queued.id, { wait: true });

// Queue-first image upload follows the same pattern
const queuedImages = await client.documents.uploadImages(['/tmp/page-1.png', '/tmp/page-2.png'], { wait: false });
const readyImages = await client.documents.get(queuedImages.id, { wait: true });

// List with pagination and filters
const { documents, total } = await client.documents.list({ limit: 50, status: 'parsed' });

// Get a single document
const doc = await client.documents.get('doc-id');

// Download extracted markdown
const markdown = await client.documents.markdown('doc-id');

// Delete
await client.documents.delete('doc-id');

// Create a search index
const index = await client.documents.index('doc-id', { method: 'vector' });

// Queue-first behavior if you want to manage polling yourself
const queued = await client.documents.index('doc-id', { method: 'hybrid', wait: false });
const indexes = await client.documents.listIndexes('doc-id');
const ready = await client.documents.getIndex('doc-id', 'hybrid', { wait: true });

Search

const response = await client.searches.create({
  query: 'revenue growth',
  method: 'vector',   // or 'hybrid'
  limit: 10,
  document_ids: ['doc-1', 'doc-2'],
});

Responses (streaming)

const stream = await client.responses.create({
  message: 'What are the key risks?',
  method: 'vector',
  limit: 5,
  document_ids: ['doc-id'],
});

for await (const event of stream) {
  switch (event.type) {
    case 'text':
      process.stdout.write(event.content);
      break;
    case 'sources':
      console.log('Sources:', event.content);
      break;
    case 'error':
      console.error(event.content);
      break;
    case 'done':
      break;
  }
}
const conv = await client.conversations.create({
  title: 'Quarterly Analysis',
  collection_id: 'col-id',
});

const stream = await client.responses.create({
  conversation_id: conv.id,
  message: 'How does that compare with the previous quarter?',
  method: 'hybrid',
  model: 'pro',
});

documents.upload(...), documents.uploadImages(...), and documents.index(...) now follow the same contract: they wait by default, support queue-first behavior with wait: false, and expose a matching getter with wait: true if you want to resume later.

Use method: 'max' when you want the Gemini parser to preserve the normal extracted text while also appending brief [visual-note: ...] lines for meaningful charts, figures, screenshots, and photos.

Collections

const col = await client.collections.create({ name: 'Q3 Reports' });
const cols = await client.collections.list();
const col = await client.collections.get('col-id');
await client.collections.update('col-id', { name: 'Q4 Reports' });
await client.collections.delete('col-id');

Conversations

const conv = await client.conversations.create({ title: 'Analysis', collection_id: 'col-id' });
const convs = await client.conversations.list();
const full = await client.conversations.get('conv-id');  // includes messages
await client.conversations.delete('conv-id');

Account & Billing

const { tenant } = await client.account.get();
console.log(tenant.credit_balance_micros);

const billing = await client.billing.get();
console.log(billing.balance_micros, billing.totals);

Error handling

All API errors throw an InfratexError:

import { InfratexError } from 'infratex';

try {
  await client.documents.get('nonexistent');
} catch (err) {
  if (err instanceof InfratexError) {
    console.error(err.status);   // 404
    console.error(err.code);     // 'not_found'
    console.error(err.message);  // 'Document not found'
  }
}

License

MIT