Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Freebies — API Response Formatter

    1

    Standardize JSON API envelopes, error schemas, and pagination metadata across microservices with TypeScript helpers.

    Free

    Security scanned
    Freebies — API Response Formatter

    Freebies — API Response Formatter

    Example session with this skill installed

    Standardize the JSON response envelope for my user profile microservice and include pagination for the list endpoint.

    • Read your context and instructions
    • Compiled the freebies

    I have generated the standardized API response envelope and pagination metadata utilities. This implementation ensures all responses follow the { success, data, error, meta } pattern with strict TypeScript typing.

    API Response Utility Implementation

    // types/api-response.ts
    
    export type ErrorObject = {
      code: string;
      message: string;
      details?: any[];
      timestamp: string;
    };
    
    export type MetaObject = {
      page?: number;
      limit?: number;
      totalItems?: number;
      totalPages?: number;
      hasNextPage?: boolean;
      hasPrevPage?: boolean;
      [key: string]: any;
    };
    
    export interface ApiResponseEnvelope<T> {
      success: boolean;
      data?: T;
      error?: ErrorObject;
      meta?: MetaObject;
    }
    
    export class ApiResponse {
      static success<T>(data: T, meta?: MetaObject): ApiResponseEnvelope<T> {
        return {
          success: true,
          data,
          meta,
        };
      }
    
      static error(code: string, message: string, details: any[] = []): ApiResponseEnvelope<null> {
        return {
          success: false,
          error: {
            code,
            message,
            details,
            timestamp: new Date().toISOString(),
          },
        };
      }
    
      static paginate(
        data: any[], 
        page: number, 
        limit: number, 
        totalItems: number
      ): ApiResponseEnvelope<any[]> {
        const totalPages = Math.ceil(totalItems / limit);
        return this.success(data, {
          page,
          limit,
          totalItems,
          totalPages,
          hasNextPage: page < totalPages,
          hasPrevPage: page > 1,
        });
      }
    }
    

    Next steps

    1. Drop this file into your src/utils or src/shared directory.
    2. Update your controller return statements to use ApiResponse.success(userData) or ApiResponse.error('USER_NOT_FOUND', ...).
    3. Apply the ApiResponse.paginate method to your user list queries to include the metadata object.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Inconsistent API responses across microservices make frontend integration brittle and debugging difficult. This skill standardizes your JSON payloads, error structures, and pagination metadata into a predictable format. It provides the utility logic needed to enforce these conventions across your entire backend.

    What it does

    • Standardize envelopes by wrapping data in a consistent { success, data, error, meta } structure.
    • Normalize pagination with mandatory fields like totalItems, totalPages, and navigation booleans.
    • Unify error schemas using SCREAMING_SNAKE_CASE codes, human-readable messages, and detailed arrays.
    • Generate TypeScript helpers including static ApiResponse methods to wrap controller logic.

    How it works

    1. Define the envelope based on the immutable JSON response structure.
    2. Apply pagination metadata to list endpoints to ensure consistent client-side consumption.
    3. Configure error objects with timestamps and standardized error codes.
    4. Export TypeScript utilities that developers can drop into controllers for immediate use.

    Frameworks & tools

    This skill produces framework-agnostic TypeScript utility classes and JSON schemas. It is designed for backend microservices environments where consistent contract enforcement is required.

    Why this beats prompting it yourself

    Prompting often results in subtle inconsistencies in field naming (e.g., total_count vs totalItems) across different sessions. This skill enforces a deterministic schema and provides the actual helper code to implement it, preventing architectural drift.

    Use cases

    • Enforcing a unified API contract across multiple distributed microservices.
    • Designing a standard error handling strategy for a new backend project.
    • Adding consistent pagination metadata to existing REST endpoints.

    Known limitations

    Outputs are restricted to TypeScript-based utility classes. It focuses on JSON REST patterns and does not cover GraphQL or gRPC specific structures.

    Outputs are framework-agnostic TypeScript utilities only. Does not support non-JSON formats or GraphQL schemas.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 3 days ago

    • Free with an Agensi account

    Requires

    File System Read/Write (strictly scoped to current project workspace `./`). Zero global installation or elevated privileges required

    Permissions

    Read Files

    Target Use Cases: - Standardize JSON API response envelope across microservices. - Create a TypeScript response formatter with pagination metadata. - Design consistent error response structures for REST APIs.

    Listed3 days ago

    What's inside

    Frequently Asked Questions

    This skill eliminates 'brittle' frontend integrations by providing a deterministic TypeScript schema and helper classes that ensure every microservice returns data, errors, and pagination in the exact same format.

    While the generated utility classes are framework-agnostic TypeScript, the skill is optimized for AI agents capable of generating code, such as AutoGPT, BabyAGI, or custom LLM-based development assistants.

    You receive the standardized JSON envelope definitions, normalized pagination schemas, and the full TypeScript source code for the ApiResponse utility methods to integrate into your controllers.

    No, this skill is specifically designed for JSON REST API patterns; it does not currently support the unique schema requirements of GraphQL or gRPC.

    Simply import the generated TypeScript utility class into your backend project and wrap your controller returns in the provided static methods to instantly enforce the standard envelope.

    New in APIs & Backend