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

node-api-document

v2.0.0

Published

πŸš€ Generate beautiful, interactive API documentation for Node.js/Express applications with zero configuration. Features include password protection, custom branding, responsive design, and easy integration. Perfect for REST APIs, microservices, and web ap

Readme

node-api-document

npm version License Downloads

Generate Beautiful API Documentation for Node.js Applications


✨ Features

  • πŸš€ Easy Integration - Simple setup with Express.js applications
  • πŸ“š Interactive Documentation - Beautiful, responsive API documentation interface
  • πŸ”’ Security - Password-protected documentation access
  • 🎨 Customizable - Custom headers, colors, icons, and branding
  • πŸ“± Responsive Design - Works perfectly on desktop and mobile devices
  • ⚑ Fast Performance - Lightweight and optimized for speed
  • πŸ”§ Framework Agnostic - Works with any Express.js-based application

πŸ“– Table of Contents

πŸš€ Installation

Install node-api-document using npm:

npm install node-api-document

Or using yarn:

yarn add node-api-document

⚑ Quick Start

Get started in minutes with this simple example:

const express = require('express');
const createDoc = require('node-api-document');

const app = express();
const PORT = process.env.PORT || 3000;

// Define your API documentation
const apiDoc = [
  {
    new_tag: "1",
    color: "black",
    title: "COMMON API",
    icon: "list"
  },
  {
    new_tag: "0",
    color: "orange",
    icon: "flag",
    title: "1 : COMMON",
    name: "Get Country List",
    meth: "GET",
    link: "http://localhost:3000/country_list",
    mandatory: "",
    optional: "",
    is_header: "YES",
    is_push: "NO",
    header: "API-KEY",
    notes: "This API is used to get the country list",
    example: "",
    status: "1. HTTP_OK [200] - status : success\n2. HTTP_OK [201] - status : error\n3. HTTP_NOT_FOUND [204]",
    imp: ""
  }
];

// Initialize API documentation
createDoc(app, 'token, api-key', apiDoc);

app.listen(PORT, () => {
  console.log(`πŸš€ Server running on port ${PORT}`);
  console.log(`πŸ“š API Documentation available at: http://localhost:3000/api-doc/`);
});

βš™οΈ Configuration

Environment Variables

Create a .env file in your project root and add the following variables:

Required Variables

| Variable | Description | Example | |----------|-------------|---------| | APP_NAME | Your project name | APP_NAME=My Awesome API | | LOGO_URL | URL for your project logo | LOGO_URL=https://example.com/logo.png | | BASE_URL | Base URL for your API | BASE_URL=https://api.example.com | | API_PASSWORD | Password to access documentation | API_PASSWORD=your_secure_password |

Optional Variables

| Variable | Description | Example | |----------|-------------|---------| | LOADER_IMAGE | Custom loader image URL | LOADER_IMAGE=https://example.com/loader.gif | | ARROW_IMAGE | Custom arrow image URL | ARROW_IMAGE=https://example.com/arrow.png |

Example .env File

# Required Variables
APP_NAME=My Awesome API
LOGO_URL=https://example.com/logo.png
BASE_URL=https://api.example.com
API_PASSWORD=my_secure_password_123

# Optional Variables
LOADER_IMAGE=https://example.com/loader.gif
ARROW_IMAGE=https://example.com/arrow.png

πŸ“š API Reference

createDoc(app, acceptHeaders, apiDoc)

Creates middleware for API documentation and integrates it into your Express app.

Parameters

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | app | Express.Application | βœ… | The Express.js application instance | | acceptHeaders | string | ❌ | Custom headers to be added to requests | | apiDoc | Array | ❌ | Array of objects defining API documentation structure |

Returns

A promise that resolves when the documentation is successfully integrated.

Example

// Basic usage
createDoc(app);

// With custom headers
createDoc(app, 'application/json, authorization');

// With API documentation
createDoc(app, 'token, api-key', apiDoc);

πŸ“‹ API Documentation Format

Each object in the apiDoc array should follow this structure:

{
  new_tag: "0" | "1",           // Flag to denote new items
  color: "string",              // Display color (e.g., "blue", "orange", "green")
  icon: "string",               // Icon name or URL
  title: "string",              // Title of the documentation section
  name: "string",               // Name of the API or link
  meth: "GET" | "POST" | "PUT" | "DELETE" | "Link", // HTTP method
  link: "string",               // API endpoint or link
  mandatory: "string",          // Mandatory parameters
  optional: "string",           // Optional parameters
  is_header: "YES" | "NO",      // Whether header is required
  is_push: "YES" | "NO",        // Whether push notification is enabled
  header: "string",             // Header name
  notes: "string",              // Additional notes
  example: "string",            // Example request/response
  status: "string",             // Status codes and descriptions
  imp: "string"                 // Important information
}

🎯 Examples

Complete Example with Multiple APIs

const express = require('express');
const createDoc = require('node-api-document');

const app = express();

const apiDoc = [
  // Section Header
  {
    new_tag: "1",
    color: "black",
    title: "AUTHENTICATION API",
    icon: "lock"
  },
  
  // Login API
  {
    new_tag: "0",
    color: "green",
    icon: "login",
    title: "1 : AUTHENTICATION",
    name: "User Login",
    meth: "POST",
    link: "http://localhost:3000/api/auth/login",
    mandatory: "email, password",
    optional: "remember_me",
    is_header: "NO",
    is_push: "NO",
    header: "",
    notes: "Authenticate user and return JWT token",
    example: `{
  "email": "[email protected]",
  "password": "password123"
}`,
    status: "1. HTTP_OK [200] - Login successful\n2. HTTP_UNAUTHORIZED [401] - Invalid credentials\n3. HTTP_BAD_REQUEST [400] - Missing required fields",
    imp: "Store the returned token for subsequent API calls"
  },
  
  // Section Header
  {
    new_tag: "1",
    color: "black",
    title: "USER MANAGEMENT",
    icon: "users"
  },
  
  // Get User Profile
  {
    new_tag: "0",
    color: "blue",
    icon: "user",
    title: "2 : USER MANAGEMENT",
    name: "Get User Profile",
    meth: "GET",
    link: "http://localhost:3000/api/user/profile",
    mandatory: "",
    optional: "",
    is_header: "YES",
    is_push: "NO",
    header: "Authorization: Bearer <token>",
    notes: "Retrieve current user's profile information",
    example: "",
    status: "1. HTTP_OK [200] - Profile retrieved successfully\n2. HTTP_UNAUTHORIZED [401] - Invalid token\n3. HTTP_NOT_FOUND [404] - User not found",
    imp: "Requires valid JWT token in Authorization header"
  },
  
  // Direct Link Example
  {
    new_tag: "0",
    color: "purple",
    icon: "link",
    title: "EXTERNAL LINKS",
    name: "API Documentation",
    meth: "Link",
    link: "https://node-api-document.vercel.app/",
    imp: "Visit our comprehensive documentation"
  }
];

createDoc(app, 'authorization, content-type', apiDoc);

app.listen(3000, () => {
  console.log('πŸš€ Server running on port 3000');
  console.log('πŸ“š API Documentation: http://localhost:3000/api-doc/');
});

πŸ” Access Documentation

Once your server is running, access the API documentation at:

http://localhost:3000/api-doc/

You'll be prompted to enter the API_PASSWORD you configured in your environment variables.

πŸ› οΈ Error Handling

The package includes comprehensive error handling:

createDoc(app, 'token, api-key', apiDoc)
  .then(() => {
    console.log('βœ… API documentation initialized successfully');
  })
  .catch((error) => {
    console.error('❌ Error initializing API documentation:', error);
  });

🀝 Contributing

We welcome contributions! Please feel free to submit issues and pull requests.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/tirth-gaudani/node-api-document.git

# Install dependencies
npm install

# Run tests
npm test

# Start development server
npm run dev

πŸ†˜ Support

  • πŸ“– Documentation - Comprehensive guides and examples
  • πŸ› Issues - Report bugs or request features
  • πŸ’¬ Discussions - Ask questions and share ideas

πŸ“„ License

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

πŸ‘¨β€πŸ’» Author


Made with ❀️ for the Node.js community