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

@openpkg-ts/sdk

v0.37.0

Published

TypeScript API extraction SDK - programmatic primitives for OpenPkg specs

Downloads

1,619

Readme

@openpkg-ts/sdk

Programmatic SDK for TypeScript API extraction and documentation generation.

Install

npm install @openpkg-ts/sdk

Entry Points

// Full SDK (Node.js)
import { listExports, extractSpec, query } from '@openpkg-ts/sdk';

// Browser-safe (no fs, path, etc.)
import { query, loadSpec } from '@openpkg-ts/sdk/browser';

Use @openpkg-ts/sdk/browser in React, Vite, Next.js client components.

Quick Start

import { listExports, getExport, extractSpec, createDocs } from '@openpkg-ts/sdk';

// List all exports
const { exports } = await listExports({ entryFile: './src/index.ts' });

// Get single export details
const { export: spec } = await getExport({ entryFile: './src/index.ts', exportName: 'myFunc' });

// Extract full spec
const { spec } = await extractSpec({ entryFile: './src/index.ts' });

// Generate docs
const docs = createDocs(spec);
const markdown = docs.toMarkdown();

Primitives

Agent-native primitives for composable workflows:

listExports

List exports from entry point with metadata.

const { exports, errors } = await listExports({ entryFile: './src/index.ts' });

// Returns: { name, kind, file, line, description }[]

getExport

Get detailed spec for a single export.

const { export: spec, types, errors } = await getExport({
  entryFile: './src/index.ts',
  exportName: 'createClient'
});

extractSpec

Generate full OpenPkg spec (all exports + types).

const { spec, diagnostics, verification } = await extractSpec({
  entryFile: './src/index.ts',
  maxTypeDepth: 4,
  resolveExternalTypes: true,
  only: ['use*'],           // filter by pattern
  ignore: ['*Internal'],    // exclude by pattern
});

diffSpecs

Compare two specs for breaking changes.

import { diffSpecs } from '@openpkg-ts/sdk';

const diff = diffSpecs(oldSpec, newSpec);
console.log(`Breaking: ${diff.breaking.length}`);

// With options
const diff = diffSpecs(oldSpec, newSpec, {
  includeDocsOnly: false,  // exclude docs-only changes
  kinds: ['function', 'class'],  // filter by kind
});

filterSpec

Immutable spec filtering by criteria.

import { filterSpec } from '@openpkg-ts/sdk';

// Filter by kind
const { spec, matched, total } = filterSpec(fullSpec, {
  kinds: ['function', 'class'],
});

// Filter by tags
filterSpec(spec, { tags: ['public'] });

// Filter deprecated exports
filterSpec(spec, { deprecated: true });

// Search by name/description
filterSpec(spec, { search: 'client' });

// Combine criteria (AND logic)
filterSpec(spec, {
  kinds: ['function'],
  hasDescription: true,
  deprecated: false,
});

analyzeSpec

Analyze spec for quality issues.

import { analyzeSpec } from '@openpkg-ts/sdk';

const diagnostics = analyzeSpec(spec);

console.log(`Missing descriptions: ${diagnostics.missingDescriptions.length}`);
console.log(`Deprecated without reason: ${diagnostics.deprecatedNoReason.length}`);
console.log(`Missing param docs: ${diagnostics.missingParamDocs.length}`);

Documentation Generation

createDocs / loadSpec

import { createDocs, loadSpec } from '@openpkg-ts/sdk';

// From file path
const docs = createDocs('./openpkg.json');

// From spec object
const docs = loadSpec(spec);

Render Functions

// Full API reference
const markdown = docs.toMarkdown({ frontmatter: true, codeSignatures: true });
const html = docs.toHTML({ fullDocument: true, includeStyles: true });
const json = docs.toJSON();

// Single export
const markdown = docs.toMarkdown({ exportId: 'createClient' });

Navigation

import { toFumadocsMetaJSON, toDocusaurusSidebarJS } from '@openpkg-ts/sdk';

const fumadocsMeta = toFumadocsMetaJSON(spec, { basePath: '/api' });
const docusaurusSidebar = toDocusaurusSidebarJS(spec);

Search Index

import { toSearchIndex, toAlgoliaRecords } from '@openpkg-ts/sdk';

const searchIndex = toSearchIndex(spec);
const algoliaRecords = toAlgoliaRecords(spec, { indexName: 'api_docs' });

QueryBuilder API

Fluent API for querying specs. Available in both Node.js and browser entry points.

import { query } from '@openpkg-ts/sdk';
// or: import { query } from '@openpkg-ts/sdk/browser';

// Chain filters
const functions = query(spec)
  .byKind('function')
  .search('create')
  .find();

// Multiple kinds
const classesAndInterfaces = query(spec)
  .byKind('class', 'interface')
  .find();

// Combine filters
const documented = query(spec)
  .byKind('function')
  .hasDescription()
  .notDeprecated()
  .find();

// Get single export
const createClient = query(spec).byName('createClient').first();

// Search by tags
const publicAPIs = query(spec).byTag('public').find();

QueryBuilder Methods

| Method | Description | |--------|-------------| | .byKind(...kinds) | Filter by export kind | | .byName(...names) | Filter by exact name | | .byId(...ids) | Filter by export ID | | .byTag(...tags) | Filter by tags | | .search(term) | Search name/description | | .hasDescription() | Only with descriptions | | .missingDescription() | Only without descriptions | | .deprecated() | Only deprecated | | .notDeprecated() | Exclude deprecated | | .find() | Return all matches | | .first() | Return first match | | .count() | Return match count |

Query Utilities

import {
  buildSignatureString,
  formatParameters,
  formatReturnType,
  getProperties,
  getMethods,
  resolveTypeRef,
} from '@openpkg-ts/sdk';

Types

import type {
  OpenPkg,
  SpecExport,
  ExtractOptions,
  ExtractResult,
  DocsInstance,
  SimplifiedSpec,
  FilterCriteria,
  FilterResult,
  SpecDiagnostics,
  DiffOptions,
  QueryBuilder,
} from '@openpkg-ts/sdk';

Browser Entry Point

@openpkg-ts/sdk/browser exports only browser-safe utilities:

  • query() - QueryBuilder
  • loadSpec() - Load spec from object
  • filterSpec() - Filter spec by criteria
  • buildSignatureString() - Format signatures
  • Query utilities (formatParameters, getProperties, etc.)

No Node.js dependencies (fs, path, child_process).

License

MIT