- Home
- Skills
- APIs & Backend
- Freebies — API Response Formatter
Works with the AI Agents you already use
Freebies — API Response Formatter
Standardize JSON API envelopes, error schemas, and pagination metadata across microservices with TypeScript helpers.
Free
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
- Drop this file into your
src/utilsorsrc/shareddirectory. - Update your controller return statements to use
ApiResponse.success(userData)orApiResponse.error('USER_NOT_FOUND', ...). - Apply the
ApiResponse.paginatemethod 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_CASEcodes, human-readable messages, and detailed arrays. - Generate TypeScript helpers including static
ApiResponsemethods to wrap controller logic.
How it works
- Define the envelope based on the immutable JSON response structure.
- Apply pagination metadata to list endpoints to ensure consistent client-side consumption.
- Configure error objects with timestamps and standardized error codes.
- 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.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Outputs are framework-agnostic TypeScript utilities only. Does not support non-JSON formats or GraphQL schemas.
How to use
- 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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
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 to use
No account required to browse
Trust & safety
Security scan
Security scan passed 3 days ago
- Free with an Agensi account
File System Read/Write (strictly scoped to current project workspace `./`). Zero global installation or elevated privileges required.
Permissions
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.