api-design-principles

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

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill api-design-principles-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/api-design-principles
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill api-design-principles-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fastapi, pydantic, ariadne, aiodataloader, uvicorn, and includes references (resource) and assets (resource) components.

What problem does it solve? Designing consistent, scalable APIs is hard—teams struggle with inconsistent naming, poor error handling, missing pagination, and N+1 query problems. This Skill provides proven REST and GraphQL design patterns, checklists, and production-ready templates to build intuitive APIs. ## Core Features & Use Cases - REST API Patterns: Resource-oriented endpoint design, HTTP method semantics, pagination, filtering, HATEOAS, versioning strategies, and standardized error responses. - GraphQL Schema Design: Schema-first development, Relay cursor pagination, DataLoader patterns to prevent N+1 queries, input/payload mutation patterns, and custom scalars. - Ready-to-Use Resources: A FastAPI template with pagination and error handling, a comprehensive API design checklist, and in-depth reference guides for REST best practices and GraphQL schema design. - Use Case: When designing a new user management API, use this Skill to structure endpoints correctly, implement cursor-based pagination, define consistent error formats, and validate your design against the checklist before implementation. ## Quick Start Use the api-design-principles skill to review my REST API endpoint design and suggest improvements for pagination and error handling.

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 REST API endpoints with proper pagination?

Use query parameters like page and page_size with sensible defaults (e.g., 20 items per page, max 100). Return a paginated response containing items, total count, current page, and total pages. For large datasets, consider cursor-based pagination instead of offset-based.

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

Use the DataLoader pattern to batch and cache database requests. Create loader classes that collect multiple IDs and fetch them in a single query, then register loaders in the GraphQL context so resolvers share them across a request.

Should I use REST or GraphQL for my API?

REST works well for simple CRUD resources, caching, and file uploads, while GraphQL suits clients needing flexible data fetching and complex relationships. GraphQL eliminates over-fetching but requires DataLoaders and query complexity limits to stay performant.

What HTTP status codes should a REST API return?

Return 200 for successful GET/PATCH/PUT, 201 for POST creation, 204 for DELETE, 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 a REST API without breaking clients?

Use URL versioning like /api/v1/users for clarity, or header versioning via the Accept header for cleaner URLs. For GraphQL, prefer schema evolution with the @deprecated directive instead of versioning, since adding fields is backward compatible.

What are common REST API design mistakes to avoid?

Avoid verbs in URLs like /api/createUser, deep nesting beyond two levels, inconsistent error formats, missing pagination on collections, and ignoring HTTP method semantics such as using POST for idempotent operations. Always document endpoints with OpenAPI.