apidock
v1.0.3
Published
Next-generation OpenAPI / Swagger documentation studio & interactive API testing playground with modern Scalar & macOS inspired aesthetics.
Maintainers
Readme
ApiDock
✨ Features
- 📑 OpenAPI 3.0 & 3.1 Compatible: Instant parsing of raw JSON or YAML specifications with schema models, nested objects, and response samples.
- 🎨 Scalar-Inspired 3-Column Studio: Left sidebar navigation, central interactive documentation, and right-side testing playground.
- 🧪 Live API Testing Playground: Execute requests right from the browser. Supports query parameters, headers, authorization tokens, and JSON request bodies with live metrics (Status, Latency, Size).
- 📐 Cursor-Resizable Panels: Drag-to-resize testing console so you can comfortably view deep nested payloads and raw response outputs.
- 🍏 Styled Code Windows: Syntax highlighting, line numbers, and single-click copy buttons.
- ⚡ Multi-Language Snippet Generator: Instantly generate production-ready code snippets in cURL, JavaScript (Fetch), Python (Requests), Dart / Flutter (http), and Go.
- 🌓 Dark & Light Modes: Pre-built themes with smooth transitions designed for long documentation reading sessions.
- 🪶 Zero Config Setup: Drop in a single
<ApiDock />component into any React, Next.js, or Vite application.
📦 Installation
Install apidock via your preferred package manager:
# npm
npm install apidock
# yarn
yarn add apidock
# pnpm
pnpm add apidock
# bun
bun add apidockPeer Dependency Notice: Ensure your project has
reactandreact-dom(v18 or v19) installed.
🚀 Quick Start
Import the <ApiDock /> component and its CSS stylesheet into your application:
import React from 'react';
import { ApiDock } from 'apidock';
import 'apidock/dist/style.css';
// Your OpenAPI 3.0 / 3.1 specification (JS Object, JSON string, or YAML string)
const spec = {
openapi: '3.0.3',
info: {
title: 'Storefront REST API',
version: '1.0.0',
description: 'Interactive API reference and developer testing sandbox.'
},
paths: {
'/api/v1/products': {
get: {
tags: ['Products'],
summary: 'List products with pagination',
parameters: [
{
name: 'limit',
in: 'query',
schema: { type: 'integer', default: 20 },
description: 'Number of results to return'
}
],
responses: {
'200': {
description: 'Successful response',
content: {
'application/json': {
schema: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
price: { type: 'number' }
}
}
}
}
}
}
}
}
}
}
};
export default function ApiReference() {
return (
<div style={{ width: '100vw', height: '100vh' }}>
<ApiDock
spec={spec}
title="Storefront API"
defaultTheme="dark"
/>
</div>
);
}🛠️ Props Reference
| Prop | Type | Default | Description |
| :--------------- | :----------------------- | :--------------------- | :----------------------------------------------------------- |
| spec | OpenAPISpec \| string | Default Petstore | Raw OpenAPI 3.0/3.1 object, JSON string, or YAML string. |
| title | string | spec.info.title | Custom header branding title. |
| defaultTheme | 'dark' \| 'light' | 'dark' | Initial UI theme mode. |
| environments | Environment[] | Pre-configured sandbox | Custom target environments (baseUrl, variables). |
| initialAuth | AuthConfig | undefined | Pre-populate Bearer token, API Key, or Basic authentication. |
| className | string | "" | Additional CSS class names for the root container. |
🌐 Next.js Integration (App Router & Pages Router)
Because apidock contains interactive DOM and playground handlers, mark the consuming component as a Client Component:
// app/docs/page.tsx
'use client';
import { ApiDock } from 'apidock';
import 'apidock/dist/style.css';
// Or import your spec directly from a JSON file
import openApiSpec from './spec.json';
export default function DocsPage() {
return (
<main className="w-screen h-screen">
<ApiDock
spec={openApiSpec}
title="Acme Cloud API"
defaultTheme="dark"
/>
</main>
);
}🧰 Exported Types & Utilities
apidock ships full TypeScript definitions and parser utilities:
import {
ApiDock,
parseOpenAPISpec,
extractEndpoints,
type OpenAPISpec,
type ParsedEndpoint,
type AuthConfig,
type Environment
} from 'apidock';🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check out the issues page if you want to contribute.
📄 License
This project is licensed under the MIT License.
