NLdoc API Specification

An OpenAPI 3.1.0 compatible specification for the NLdoc API. This TypeScript library provides a comprehensive API framework for document conversion services, health monitoring, and file management.
Overview
This specification defines a standardized REST API for NLdoc services including:
- Document conversion operations
- Server-Sent Events (SSE) for conversion progress tracking
- File retrieval and management
- Health check endpoints
The API follows RPC-style principles inspired by REST, using clear, action-driven endpoints and standard HTTP semantics to deliver streamlined operations.
Getting Started
Prerequisites
- Node.js >= 22.0.0 < 23.0.0
- npm >= 10.0.0 < 12.0.0
Installation
Install the package via npm:
npm install @nldoc/api-specification
Or using yarn:
yarn add @nldoc/api-specification
Basic Usage
import {
specification,
validExamples,
invalidExamples
} from '@nldoc/api-specification';
console.log(specification);
console.log(validExamples);
console.log(invalidExamples);
Accessing the OpenAPI Specification
After building the project, the complete OpenAPI 3.1.0 specification is available at:
npm run build
Development
Local Setup
Available Scripts
npm run test - Run the test suite with Vitest and generate coverage reports
npm run build - Build the OpenAPI specification, examples, and TypeScript files
npm run lint - Lint the codebase using ESLint
npm run format - Format code using Prettier
npm run format:check - Check code formatting
npm run fix - Auto-fix linting and formatting issues
npm run lint:openapi - Validate OpenAPI specification against ADR standards and generate reports
npm run lint:spectral - Validate against Dutch API Design Rules (ADR 2.1)
npm run lint:vacuum - Generate an HTML report for the OpenAPI specification
Building Components
The build process consists of several steps:
- OpenAPI Generation:
npm run build:openapi - Generates the OpenAPI JSON specification
- Example Extraction:
npm run build:examples - Extracts valid and invalid test examples
- TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
- Documentation:
npm run build:redocly - Generates HTML documentation using Redocly
API Endpoints
The specification defines the following main endpoints:
Core Operations
- POST /conversion: Convert files to different formats
- GET /conversion/{uuid}: Stream conversion events via Server-Sent Events (SSE)
- GET /file/{key}: Retrieve converted files
- HEAD /file/{key}: Check file metadata
Health Monitoring
- GET /health: Get health status with detailed response
- HEAD /health: Quick health check
Headers and Parameters
The API uses standard headers for request tracking and versioning:
X-Trace-Id: Distributed tracing identifier
X-Request-Id: Unique request identifier
API-Version: API version information
Content-Type: Content type for requests and responses
API Documentation
The generated OpenAPI specification can be viewed:
Testing
Run the test suite:
npm test
Contributing
We welcome contributions! Please ensure:
- All tests pass (
npm test)
- Code is properly formatted (
npm run format:check)
- Linting rules are followed (
npm run lint)
- OpenAPI specification is valid (
npm run lint:openapi)
- Compliance with Dutch API Design Rules (
npm run lint:spectral)
License
This project is licensed under the European Union Public License 1.2 - see LICENSE for details.
Acknowledgements