NestJS API Standards

Standardize NestJS API responses, pagination, and error handling.

3|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/ahiendz/DuAnCuoiKhoa --skill nestjs-api-standards
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: NestJS API Standards
Source: https://github.com/ahiendz/DuAnCuoiKhoa/tree/main/.agents/skills/api-standards
Command: npx skills add https://github.com/ahiendz/DuAnCuoiKhoa --skill nestjs-api-standards

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

NestJS projects often diverge in how API responses, pagination, and errors are formatted, leading to inconsistent client experiences and more boilerplate. This Skill provides a standardized approach to wrap responses, implement pagination, and structure errors across NestJS APIs.

Core Features & Use Cases

  • Generic response wrapper using a TransformInterceptor to unify successful responses into a standard shape: { statusCode, data, meta }.
  • Pagination support with strict DTOs (PageOptionsDto, PageDto) and a Swagger-friendly ApiPaginatedResponse decorator for consistent list endpoints.
  • Standardized error object (ApiErrorResponse) with statusCode, message, error, timestamp, and path, plus guidance for global or per-controller usage.
  • Use Cases: admin dashboards, product catalogs, user listings, and any resource collection endpoints where consistent pagination and error handling improve UX and ease of integration.

Quick Start

Configure NestJS to apply the TransformInterceptor, adopt PageOptionsDto and PageDto for paginated results, and use ApiErrorResponse for standardized errors in your list endpoints.

Frequently Asked Questions about NestJS API Standards

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize API responses in NestJS?

To standardize API responses in NestJS, use a generic TransformInterceptor to unify successful payloads into a consistent shape containing statusCode, data, and meta. This eliminates response format divergence and reduces client-side boilerplate across typical CRUD endpoints.

What is the best way to implement pagination in NestJS with Swagger?

The best way to implement pagination in NestJS with Swagger is using strict PageOptionsDto and PageDto classes alongside an ApiPaginatedResponse decorator. This ensures consistent list endpoint payloads and automatically generates accurate Swagger documentation for paginated resources.

How do I handle errors consistently in NestJS APIs?

To handle errors consistently in NestJS APIs, implement a unified ApiErrorResponse schema containing statusCode, message, error, timestamp, and path. This standardizes error payloads globally or per-controller, ensuring reliable error handling and improving client integration experiences.

Can I use a TransformInterceptor for nested resources in NestJS?

Yes, you can use a TransformInterceptor for nested resources in NestJS. It applies to typical CRUD endpoints and nested resource collections, wrapping all successful responses into the standard format to provide consistent payloads across your application architecture.

Does this NestJS response standardization approach work without external dependencies?

Yes, this NestJS response standardization approach works without external dependencies. It uses built-in decorators and interceptors to wrap responses, implement page-based pagination DTOs, and structure errors, requiring no additional libraries for integration into your existing application.