Top Related Projects
Beautiful static documentation for your API
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
📘 OpenAPI/Swagger-generated API Reference Documentation
Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
GUI / visual editor for creating and editing OpenAPI / Swagger definitions
Quick Overview
apiDoc is a tool that generates API documentation from inline comments in your source code. It supports multiple programming languages and can create a user-friendly HTML output, making it easier for developers to document and share their API specifications.
Pros
- Supports multiple programming languages (JavaScript, Java, PHP, Python, and more)
- Generates clean, interactive HTML documentation
- Allows for easy integration into existing projects
- Supports versioning of API endpoints
Cons
- Requires specific comment syntax, which may be unfamiliar to some developers
- Limited customization options for output styling
- May require additional setup for complex projects
- Documentation generation can be slow for large codebases
Code Examples
- Basic API endpoint documentation:
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
function getUser(id) {
// Implementation
}
- Defining API parameters:
/**
* @api {post} /user Create a new User
* @apiName PostUser
* @apiGroup User
*
* @apiParam {String} username User's username.
* @apiParam {String} email User's email.
* @apiParam {String} password User's password.
*
* @apiSuccess {Object} user Created user object.
*/
function createUser(username, email, password) {
// Implementation
}
- Specifying API error responses:
/**
* @api {delete} /user/:id Delete a User
* @apiName DeleteUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {Boolean} success Indicates successful deletion.
*
* @apiError UserNotFound The <code>id</code> of the User was not found.
* @apiError (Error 401) Unauthorized Only authenticated users can delete users.
*/
function deleteUser(id) {
// Implementation
}
Getting Started
To use apiDoc in your project:
-
Install apiDoc globally:
npm install -g apidoc
-
Add apiDoc configuration to your project's
package.json
:{ "name": "example", "version": "0.1.0", "description": "apiDoc basic example", "apidoc": { "title": "Custom apiDoc browser title", "url" : "https://api.example.com" } }
-
Run apiDoc in your project directory:
apidoc -i ./ -o ./doc/
This will generate API documentation in the ./doc/
directory based on the apiDoc comments in your source code.
Competitor Comparisons
Beautiful static documentation for your API
Pros of Slate
- Beautiful, responsive three-panel design for API documentation
- Supports multiple programming languages with syntax highlighting
- Easy to customize and extend with HTML, CSS, and JavaScript
Cons of Slate
- Requires more setup and configuration compared to apiDoc
- Less suitable for generating documentation from inline code comments
- May have a steeper learning curve for non-technical users
Code Comparison
Slate (index.html.md):
---
title: API Reference
language_tabs:
- shell
- ruby
- python
toc_footers:
- <a href='#'>Sign Up for a Developer Key</a>
includes:
- errors
---
# Introduction
Welcome to the Kittn API! You can use our API to access Kittn API endpoints...
apiDoc (example.js):
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
Slate focuses on creating a visually appealing, static documentation site, while apiDoc generates documentation from inline code comments. Slate offers more flexibility in design and layout, but apiDoc is simpler to integrate into existing codebases and maintain alongside the source code.
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
Pros of Swagger UI
- Offers a more interactive and visually appealing documentation interface
- Supports the OpenAPI Specification, which is widely adopted in the industry
- Provides built-in API testing capabilities within the documentation
Cons of Swagger UI
- Requires more setup and configuration compared to apiDoc
- May have a steeper learning curve for developers new to OpenAPI/Swagger
Code Comparison
Swagger UI (YAML):
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
paths:
/users:
get:
summary: Get users
responses:
'200':
description: Successful response
apiDoc:
/**
* @api {get} /users Get users
* @apiName GetUsers
* @apiGroup User
* @apiVersion 1.0.0
* @apiSuccess {Object[]} users List of users
*/
Key Differences
- Swagger UI uses OpenAPI Specification (YAML or JSON), while apiDoc uses inline comments
- Swagger UI provides a more comprehensive API description, including request/response schemas
- apiDoc focuses on simplicity and ease of use, with a straightforward annotation system
Use Cases
- Choose Swagger UI for complex APIs requiring detailed documentation and interactive testing
- Opt for apiDoc for simpler projects or when quick setup and minimal learning curve are priorities
📘 OpenAPI/Swagger-generated API Reference Documentation
Pros of Redoc
- Offers a more modern and visually appealing documentation interface
- Supports OpenAPI (Swagger) 2.0 and 3.0 specifications out of the box
- Provides interactive API console for testing endpoints directly in the documentation
Cons of Redoc
- Less flexible for custom documentation structures compared to apiDoc
- May require more initial setup and configuration for complex API documentation
Code Comparison
apiDoc example:
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*/
Redoc example (OpenAPI/Swagger):
paths:
/user/{id}:
get:
summary: Request User information
parameters:
- name: id
in: path
required: true
schema:
type: integer
Key Differences
- apiDoc uses inline code comments for documentation, while Redoc relies on separate OpenAPI/Swagger specification files
- Redoc focuses on rendering existing API specifications, whereas apiDoc generates documentation from code annotations
- apiDoc offers more customization options for documentation structure, while Redoc provides a standardized, polished output based on OpenAPI specifications
Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
Pros of Elements
- Offers a more modern, customizable UI for API documentation
- Supports multiple API specification formats (OpenAPI, AsyncAPI, JSON Schema)
- Provides interactive API console for testing endpoints
Cons of Elements
- Steeper learning curve for implementation and customization
- Requires more setup and configuration compared to apidoc
- May be overkill for simpler API documentation needs
Code Comparison
Elements (React component):
import { API } from '@stoplight/elements';
function MyAPI() {
return <API apiDescriptionUrl="https://api.example.com/openapi.yaml" />;
}
apidoc (JSDoc-style comments):
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*/
Key Differences
- Elements focuses on rendering existing API specifications, while apidoc generates documentation from code comments
- Elements provides a more interactive and visually appealing documentation experience
- apidoc is simpler to set up and use for basic API documentation needs
- Elements offers more advanced features like API testing and multiple specification support
- apidoc is better suited for projects where documentation needs to be tightly coupled with the codebase
Both tools have their strengths, and the choice between them depends on the specific requirements of the project, the desired level of interactivity, and the preferred documentation workflow.
GUI / visual editor for creating and editing OpenAPI / Swagger definitions
Pros of openapi-gui
- Provides a graphical user interface for creating and editing OpenAPI specifications
- Supports real-time preview of the generated OpenAPI document
- Offers a more user-friendly approach for those less familiar with writing YAML or JSON
Cons of openapi-gui
- Limited to OpenAPI specification format, while apidoc supports multiple documentation styles
- May have a steeper learning curve for users already comfortable with writing API documentation in code comments
- Less flexibility in customizing the output format compared to apidoc
Code Comparison
apidoc example:
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*/
openapi-gui example (resulting OpenAPI YAML):
paths:
/user/{id}:
get:
summary: Request User information
parameters:
- name: id
in: path
required: true
schema:
type: integer
responses:
'200':
description: Successful response
Both tools aim to simplify API documentation, but they approach it differently. apidoc focuses on generating documentation from code comments, while openapi-gui provides a visual interface for creating OpenAPI specifications. The choice between them depends on the project's requirements and the team's preferred workflow.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Important note
This project is currently not active maintained! See discussion https://github.com/apidoc/apidoc/issues/1436
apiDoc
apiDoc creates a documentation from API descriptions in your source code.
Documentation: apidocjs.com
Live DEMO
Installation
$ npm install -g apidoc
Usage
Add some apidoc comments anywhere in your source code:
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id User's unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
Now generate the documentation from src/
into doc/
.
$ apidoc -i src/ -o doc/
This repository contains and example
folder from which you can generate a very complete documentation on an example api endpoint. It also contains best practice hints (in the footer.md
file).
$ git clone https://github.com/apidoc/apidoc && cd apidoc
$ npm install --prod
$ ./bin/apidoc -i example -o /tmp/doc
$ $BROWSER /tmp/doc
Programmatic usage
You can generate the documentation programmatically:
import path from 'path'
import { createDoc } from 'apidoc'
const doc = createDoc({
src: path.resolve(__dirname, 'src'),
dest: path.resolve(__dirname, 'doc'), // can be omitted if dryRun is true
// if you don't want to generate the output files:
dryRun: true,
// if you don't want to see any log output:
silent: true,
})
if (typeof doc !== 'boolean') {
// Documentation was generated!
console.log(doc.data) // the parsed api documentation object
console.log(doc.project) // the project information
}
Install type definitions (see @types/apidoc):
$ npm install -D @types/apidoc
Docker image
You can use apidoc in Docker like this:
# first build the image after cloning this repository
docker build -t apidoc/apidoc .
# run it
docker run --rm -v $(pwd):/home/node/apidoc apidoc/apidoc -o outputdir -i inputdir
Supported programming languages
-
C#, Go, Dart, Java, JavaScript, PHP, Scala (all DocStyle capable languages):
/** * This is a comment. */
-
Clojure:
;;;; ;; This is a comment. ;;;;
-
CoffeeScript:
### This is a comment. ###
-
Elixir:
#{ # This is a comment. #}
-
Erlang:
%{ % This is a comment. %}
-
Perl
#** # This is a comment. #*
=pod This is a comment. =cut
-
Python
""" This is a comment. """
-
Ruby
=begin This is a comment. =end
Plugins (extend apiDoc)
apiDoc will auto include installed plugins.
- apidoc-plugin-schema Generates and inject apidoc elements from api schemas.
npm install apidoc-plugin-schema
For details and an example on how to implement your own plugin, please view apidoc-plugin-test.
Support
Please create a new issue if you have a suggestion/question or if you found a problem/bug.
Contributing
apiDoc is a collaborative project. Pull requests are welcome. Please see the CONTRIBUTING file.
Build tools
- flask-apidoc
pip install flask-apidoc
- grunt-apidoc
npm install grunt-apidoc
. - gapidoc (gulp)
npm install gapidoc
. - webpack-apidoc
npm install --save-dev webpack-apidoc
.
Integration
Converter
Top Related Projects
Beautiful static documentation for your API
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
📘 OpenAPI/Swagger-generated API Reference Documentation
Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
GUI / visual editor for creating and editing OpenAPI / Swagger definitions
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot