api-studios
v1.1.1
Published
Blazing fast, zero-config API & Database documentation studio with live interactive testing console for Node.js REST APIs.
Maintainers
Readme
⚡ api-studios
Blazing fast, zero-config API & Database documentation studio with live interactive testing console for Node.js REST APIs.
api-studios empowers developers to document Node.js APIs and relational database structures directly using clean JSDoc annotations. It delivers a modern, responsive, developer-friendly Web UI with a built-in Live API Testing Console (with full JWT Bearer, API Key, and Basic Authentication support), Database Schemas & Relations explorer, dynamic multi-language code snippet generation, OpenAPI 3.0 & Postman collection export, and one-command CLI tooling.
🌟 Key Features
- 🚀 Zero-Config & Auto-Scanning: Automatically scans your project routes (
.js,.ts,.mjs,.cjs) and builds comprehensive documentation. - 🧪 Interactive "Try It Out" Live Console: Test endpoints in real time directly from the browser with dynamic path parameters, query filters, custom headers, and body payload editors.
- 📊 Database Schema & Data Models Documentation: Document database tables, columns, data types, constraints (
🔑 PK,🔗 FK,⚡ Unique,NOT NULL), entity relations (1:N,N:1,1:1), and sample JSON records using@model. - 🔒 Full Authentication Support: Seamlessly authenticate and test protected routes using JWT Bearer Tokens, API Keys (Header or Query), or Basic Auth. Credentials persist in
localStorage. - 🌐 Public & Protected Route Badges: Clear visual badges (
🔒 BearerAuth,🔑 ApiKeyAuth,🌐 Public) for each endpoint. - ⚡ Express / Node.js Middleware: Mount docs in your existing Express, Fastify, or Connect app with just a single line of code.
- 💻 One-Command CLI (
api-studios):npx api-studios serve: Instant standalone live documentation server with hot-reloading.npx api-studios generate: Build standalone static HTML, OpenAPI 3.0 JSON, and Postman Collection files.npx api-studios init: Scaffold configuration and sample annotated route files.npx api-studios validate: Validate doc comments across your codebase.
- 📋 Multi-Language Code Snippets: Automatically generates copyable code snippets in cURL, JavaScript (Fetch), Node.js (Axios), Python (Requests), and Go that reactively update as you type.
- 🎨 Modern Responsive UI: Dark & light theme switcher, instant fuzzy search, method filters (
GET,POST,PUT,DELETE,PATCH), latency timer (⏱️ 4ms), and formatted JSON response viewer with syntax highlighting. - 📄 Standard Specs Export: Instant one-click export for OpenAPI 3.0.3 and Postman Collection v2.1.
📦 Installation
# Install as a project dependency
npm install api-studios
# Or install globally for CLI use
npm install -g api-studios🚀 Quick Start
1. Express Middleware Integration
Add api-studios middleware to your Express application:
const express = require('express');
const { serveDocs } = require('api-studios');
const app = express();
app.use(express.json());
// Mount the API Documentation & Live Console at /docs
app.use('/docs', serveDocs({
title: 'My REST API',
version: '1.0.0',
description: 'Production API documentation with live interactive tester',
routesDir: './routes', // Path to your routes folder
servers: [
{ url: 'http://localhost:3000', description: 'Local Dev Server' },
{ url: 'https://api.example.com', description: 'Production' }
],
auth: {
bearer: true,
apiKey: { in: 'header', name: 'x-api-key' },
basic: true
}
}));
// Your API Routes
app.use('/api/v1/users', require('./routes/users.routes'));
app.listen(3000, () => {
console.log('API Studio available at: http://localhost:3000/docs');
});2. Standalone CLI Usage
You can also use api-studios without any middleware!
# 1. Initialize configuration and sample routes in your project
npx api-studios init
# 2. Start live studio preview server with hot-reload
npx api-studios serve --input ./routes --port 4000
# 3. Generate static HTML & OpenAPI/Postman bundle
npx api-studios generate --input ./routes --output ./dist-docs
# 4. Validate route annotations
npx api-studios validate --input ./routes✍️ Annotation Syntax Guide
Annotate your route handlers and database models using clean, intuitive JSDoc comments:
1. Public Endpoint (GET with Query Filters)
/**
* @route GET /api/v1/products
* @group Products - Product Catalog & Inventory
* @summary Search and filter products catalog
* @description Search products by category, price range, and paginate results.
*
* @query {string} [category] - Filter by category (e.g. 'electronics', 'apparel')
* @query {number} [minPrice=0] - Minimum price filter
* @query {number} [maxPrice] - Maximum price filter
* @query {boolean} [inStock=true] - Filter only products currently in stock
* @query {number} [page=1] - Page number
* @query {number} [limit=10] - Items per page (max 100)
*
* @response 200 {object} - Products retrieved successfully
* @response 200.total {number} - Total number of matching items
* @response 200.data {array} - Array of product items
*/
router.get('/products', (req, res) => {
// ... handler logic
});2. Authenticated Endpoint (POST with Body & Bearer Auth)
/**
* @route POST /api/v1/auth/login
* @group Authentication - User login and token issuance
* @summary Authenticate user and obtain Bearer JWT
* @description Validates user credentials. On success, returns access token.
*
* @header {string} [X-Client-Version] - Client application version
*
* @body {string} email.required - Registered user email address
* @body {string} password.required - Account password (min 6 chars)
* @body {boolean} [rememberMe=false] - Keep login active for 30 days
*
* @response 200 {object} - Login successful
* @response 200.token {string} - JWT access token
* @response 200.user {object} - User profile
* @response 400 {object} - Missing or invalid credentials
* @response 401 {object} - Invalid email or password
*
* @example request
* {
* "email": "[email protected]",
* "password": "SecurePassword123!",
* "rememberMe": true
* }
*/
router.post('/login', (req, res) => {
// ... handler logic
});3. Path Parameter & Bearer Token Protected Endpoint
/**
* @route GET /api/v1/users/{id}
* @group Users - User profile operations
* @summary Get user profile by ID
* @description Retrieve comprehensive profile information. Requires Bearer Token.
* @auth BearerAuth
*
* @param {string} id.path.required - Unique User Identifier (e.g. usr_101)
* @query {boolean} [includeStats=false] - Include user activity statistics
*
* @response 200 {object} - User profile retrieved
* @response 401 {object} - Unauthorized (missing or invalid Bearer token)
* @response 404 {object} - User not found
*/
router.get('/users/:id', (req, res) => {
// ... handler logic
});4. Database Structure & Data Model Documentation (@model)
You can document your Database Tables, Schemas, Constraints, Keys, and Relations directly in code comments:
/**
* @model User - System user accounts and authentication profiles
* @table users
* @field id {string} - Unique Primary Key identifier [PK, Required]
* @field name {string} - Full display name [Required]
* @field email {string} - Unique registered email address [Unique, Required]
* @field password_hash {string} - Bcrypt password hash [Required]
* @field role {enum('admin','developer','viewer')} - User access role [Default: 'developer']
* @field is_active {boolean} - Active status indicator [Default: true]
* @field created_at {timestamp} - Creation timestamp [Default: NOW()]
* @field updated_at {timestamp} - Last update timestamp
*
* @relation 1:N orders - User has many placed orders
* @relation 1:1 user_profiles - User has one extended profile
* @relation 1:N user_sessions - User has active login sessions
*
* @example
* {
* "id": "usr_101",
* "name": "Sarah Connor",
* "email": "[email protected]",
* "role": "admin",
* "is_active": true,
* "created_at": "2026-01-10T08:00:00.000Z"
* }
*/5. API Key Protected Mutation Endpoint
/**
* @route POST /api/v1/products
* @group Products - Product Catalog
* @summary Create a new product item
* @description Inserts a new product into catalog. Requires API Key.
* @auth ApiKeyAuth
*
* @header {string} [x-idempotency-key] - Unique idempotency key to prevent duplicate creation
*
* @body {string} name.required - Product title
* @body {string} category.required - Product category
* @body {number} price.required - Unit price in USD
* @body {boolean} [inStock=true] - Initial inventory state
*
* @response 201 {object} - Product created successfully
* @response 400 {object} - Validation error
* @response 401 {object} - Missing or invalid API key
*/
router.post('/products', (req, res) => {
// ... handler logic
});6. Ignoring Internal / Private Endpoints (@ignoreapi)
To exclude internal, sensitive, or debugging endpoints/models from being included in the generated API documentation, OpenAPI specifications, and Postman collections, simply add @ignoreapi:
/**
* @route GET /api/v1/internal/health-metrics
* @ignoreapi
* @summary Internal server diagnostics (hidden from public documentation)
*/
router.get('/internal/health-metrics', (req, res) => {
// ... internal metrics logic
});⚙️ Configuration Reference (apistudio.config.js)
You can optionally place an apistudio.config.js in your project root:
module.exports = {
title: 'Acme Cloud REST API',
version: '2.4.0',
description: 'Production-ready REST API & Database Studio with live testing console.',
routesDir: './routes',
servers: [
{ url: 'http://localhost:3000', description: 'Local Development' },
{ url: 'https://staging.api.acme.com', description: 'Staging Environment' },
{ url: 'https://api.acme.com', description: 'Production Environment' }
],
auth: {
bearer: true,
apiKey: { in: 'header', name: 'x-api-key' },
basic: true
},
contact: {
name: 'API Support',
email: '[email protected]'
},
license: {
name: 'MIT'
}
};💻 CLI Commands
| Command | Description | Example |
| :--- | :--- | :--- |
| npx api-studios init | Scaffolds config file & sample routes | npx api-studios init |
| npx api-studios serve | Starts live preview server with hot reload | npx api-studios serve -i ./routes -p 4000 |
| npx api-studios generate | Builds static HTML & OpenAPI/Postman bundle | npx api-studios generate -i ./routes -o ./dist-docs |
| npx api-studios validate | Validates doc annotations across codebase | npx api-studios validate -i ./routes |
🧪 Testing the Package
To run the automated test suite:
npm testTo run the live interactive demo:
npm startThen visit: 👉 http://localhost:3000/docs
📄 License
MIT © RK Dev Team
