api-design-principles

Design REST and GraphQL APIs with pagination, versioning, and error handling patterns.

Updated Apr 30, 2026
One-click install
npx skills add https://github.com/AdityaBorkar/igbot-fork --skill api-design-principles-adityaborkar
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/AdityaBorkar/igbot-fork/tree/main/.agents/skills/api-design-principles
Command: npx skills add https://github.com/AdityaBorkar/igbot-fork --skill api-design-principles-adityaborkar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? Designing consistent, maintainable APIs is hard: teams struggle with inconsistent naming, missing pagination, poor error formats, N+1 query problems in GraphQL, and unplanned versioning that breaks clients. This Skill provides concrete patterns, templates, and checklists to design REST and GraphQL APIs correctly from the start. ## Core Features & Use Cases - REST Design Patterns: Resource-oriented endpoints, HTTP method semantics, pagination (offset, cursor, Link headers), filtering, rate limiting, and standardized error responses with correct status codes. - GraphQL Schema Design: Schema-first development, Relay cursor pagination, DataLoader-based N+1 prevention, input/payload mutation patterns, subscriptions, custom scalars, and deprecation strategies. - Ready-to-Use Assets: A FastAPI REST template, a GraphQL schema design reference, and a comprehensive pre-implementation review checklist covering security, monitoring, and documentation. - Use Case: Before implementing a new orders API, run the design checklist to verify resource naming, status codes, pagination, and versioning, then scaffold the endpoints from the FastAPI template. ## Quick Start Ask the assistant to design a versioned REST API for managing orders with cursor pagination and consistent error responses using the api-design-principles skill.

Frequently Asked Questions about api-design-principles

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

FAQPage Schema
How do I design a REST API with proper pagination?▼

Use offset-based pagination with page and page_size parameters for simple cases, or cursor-based pagination for large datasets. Always include pagination metadata like total count and pages, enforce a maximum page size, and apply it to every collection endpoint.

How do I prevent N+1 queries in GraphQL resolvers?▼

Use DataLoader to batch and cache database requests per request cycle. A DataLoader collects all IDs requested during a tick and fetches them in a single query, then maps results back in input order, eliminating per-item database round trips.

REST vs GraphQL: which should I choose for my API?▼

REST fits resource-oriented services with simple caching and clear HTTP semantics, while GraphQL suits clients needing flexible field selection and aggregated data from multiple sources. GraphQL requires DataLoaders, query depth limits, and complexity analysis to stay performant.

What HTTP status codes should a REST API return?▼

Return 200 for successful reads and updates, 201 for creation, 204 for deletion, 400 for malformed requests, 401 for missing authentication, 403 for insufficient permissions, 404 for missing resources, 422 for validation errors, and 429 for rate limiting.

How do I version an API without breaking existing clients?▼

Use URL versioning like /api/v1/users for clarity, or header versioning for cleaner URLs. In GraphQL, avoid versions entirely by adding nullable fields and marking old ones with the @deprecated directive instead of removing them.

Why does my GraphQL query fail with depth or complexity errors?▼

The server enforces query depth limiting and complexity analysis to block expensive nested queries. Reduce nesting, request fewer list items per field, or split the operation into multiple smaller queries to stay within configured limits.