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

apiscribe

v0.2.2

Published

Scan any backend project and generate API documentation with AI

Readme

apiscribe

npm version license

Scan any backend project and generate API documentation with AI.

Point apiscribe at a project directory — or a public GitHub repo. It detects your API routes, sends them to an LLM, and outputs documentation — as markdown, OpenAPI spec, or interactive HTML docs with a built-in AI chat assistant.

Supported Frameworks

  • Next.js App Routerapp/api/**/route.ts
  • Supabase Edge Functionssupabase/functions/*/index.ts
  • Expressapp.get(), router.post(), etc.
  • Fastifyfastify.get(), fastify.route(), etc.

Quick Start

# 1. Set your API key
export OPENAI_API_KEY=your-key-here

# 2. Run it from your project directory
npx apiscribe . --serve

# Or point at a project from anywhere
npx apiscribe ./my-project --serve

# Or scan a public GitHub repo directly
npx apiscribe expressjs/express --serve

That's it. Your browser opens with interactive API docs on localhost:3000, complete with an AI chat assistant you can ask questions about your API.

Other providers work too:

export ANTHROPIC_API_KEY=your-key-here
npx apiscribe ./my-project --serve -p anthropic

export GEMINI_API_KEY=your-key-here
npx apiscribe ./my-project --serve -p gemini

Usage

apiscribe <directory|owner/repo> [options]

Output formats:
  --serve                Preview docs on localhost:3000 (implies --html)
  --html                 Generate interactive HTML docs (Scalar)
  --openapi              Generate OpenAPI 3.0 JSON spec
  --json                 Output as JSON instead of markdown
  (default)              Generate markdown docs

LLM options:
  -p, --provider <name>  openai, anthropic, or gemini (default: "openai")
  -m, --model <name>     Model name override

Scanning:
  --dry-run              List detected routes without calling LLM
  --frameworks <list>    Filter frameworks (e.g., nextjs,express)

General:
  -o, --output <file>    Output file path (default: "api-docs.md")
  --verbose              Show debug output
  -V, --version          Show version
  -h, --help             Show help

Examples

# Preview docs in your browser (the best way to use apiscribe)
apiscribe ./my-project --serve

# Generate interactive HTML docs you can host on your own domain
apiscribe ./my-project --html

# Generate OpenAPI spec
apiscribe ./my-project --openapi

# Generate markdown docs (default)
apiscribe ./my-project

# Preview what routes will be detected (free, no LLM call)
apiscribe ./my-project --dry-run

# Use a different provider
apiscribe ./my-project --serve -p anthropic
apiscribe ./my-project --serve -p gemini

# Use a specific model
apiscribe ./my-project --serve -p anthropic -m claude-sonnet-4-20250514

# Only scan Next.js routes
apiscribe ./my-project --serve --frameworks nextjs

# Scan a public GitHub repo
apiscribe expressjs/express --serve
apiscribe expressjs/express#5.x --dry-run
apiscribe https://github.com/expressjs/express --html

Ask AI

When using --serve, apiscribe adds an AI chat assistant to your docs. Click the Ask AI bubble in the bottom-right corner to open a chat panel where you can ask questions about your API — how endpoints work, what parameters are required, or how to integrate with your app.

The assistant uses the same LLM provider you configured and has full context of your generated OpenAPI spec.

GitHub Repos

Scan any public GitHub repo without cloning it:

# owner/repo format
apiscribe expressjs/express --serve

# specific branch
apiscribe expressjs/express#5.x --dry-run

# full URL
apiscribe https://github.com/expressjs/express --html

apiscribe downloads a tarball of the repo, scans it, and cleans up automatically.

API Key Configuration

apiscribe checks for API keys in this order:

  1. Environment variableOPENAI_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY
  2. Config file~/.apiscribe/config.json
{
  "OPENAI_API_KEY": "sk-...",
  "ANTHROPIC_API_KEY": "sk-ant-...",
  "GEMINI_API_KEY": "AI..."
}

How It Works

  1. Scan — Walks your project directory (or downloads a GitHub repo) and matches files against framework-specific patterns
  2. Detect — Identifies the framework (Next.js, Supabase, Express, Fastify) and extracts HTTP methods
  3. Infer — Converts file paths to endpoint URLs using framework conventions (e.g., app/api/users/[id]/route.ts/api/users/:id)
  4. Generate — Sends the route code to an LLM with framework-aware context and path hints
  5. Output — Writes structured markdown, OpenAPI JSON, or interactive HTML documentation
  6. Serve — With --serve, starts a local server with interactive docs and an AI chat assistant

Hosting Your Docs

With --html, apiscribe generates a self-contained index.html and openapi.json in your output directory. The HTML file has the full API spec embedded — no backend or database required.

Host it anywhere:

  • Drop it into your existing website
  • Deploy to Vercel, Netlify, or GitHub Pages
  • Serve from S3, CloudFront, or any static file host
  • Add it to your project repo and serve it from your own domain
apiscribe ./my-project --html -o docs/api-docs.md
# outputs docs/openapi.json and docs/index.html — ready to deploy

Adding Framework Support

Each framework detector implements a simple interface:

interface FrameworkDetector {
  name: string;
  filePatterns: string[];           // Glob patterns to find candidate files
  contentPatterns: RegExp[];        // Regex to confirm a file is a route handler
  inferEndpointPath(filePath, projectRoot): string;  // File path → API URL
  extractHttpMethods(content): string[];             // Extract HTTP methods from code
  promptHint: string;               // LLM context about the framework's conventions
}

See src/frameworks/ for examples.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT