api-design-principles

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

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/ttnhan18062000/rpg-based-simulation --skill api-design-principles-ttnhan18062000
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/ttnhan18062000/rpg-based-simulation/tree/main/.agents/skills/api-design-principles
Command: npx skills add https://github.com/ttnhan18062000/rpg-based-simulation --skill api-design-principles-ttnhan18062000

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Designing consistent, maintainable REST and GraphQL APIs is hard: teams struggle with naming conventions, status codes, pagination, versioning, and N+1 query problems, leading to inconsistent contracts that frustrate API consumers. ## Core Features & Use Cases - REST Design Guidance: Resource-oriented URL patterns, correct HTTP method and status code usage, pagination, filtering, rate limiting, and HATEOAS patterns. - GraphQL Schema Patterns: Schema-first design with input/payload mutations, Relay cursor pagination, DataLoader-based N+1 prevention, and union error types. - Review Checklists and Templates: A pre-implementation checklist plus a FastAPI REST template for bootstrapping consistent endpoints. - Use Case: When designing a new users API, apply the resource modeling and pagination patterns, then validate the spec against the checklist before implementation. ## Quick Start Use the api-design-principles skill to review my proposed REST endpoints for a users resource and recommend pagination, error handling, and versioning conventions.

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 and filtering?

Use query parameters for pagination (page/page_size or cursor-based), filtering (status, search), and sorting (sort=-created_at). Return pagination metadata like total, pages, and has_next in the response body, and enforce a maximum page size such as 100.

REST vs GraphQL: which API style should I choose?

REST fits resource-oriented CRUD with simple caching and clear HTTP semantics; GraphQL fits clients needing flexible field selection and aggregated queries. The skill covers both, including schema-first GraphQL design and REST resource modeling.

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

Use the DataLoader pattern to batch relationship loads into single queries per request. Combine it with query depth limiting and complexity analysis to protect against expensive nested queries.

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/403 for auth failures, 404 for missing resources, 422 for validation errors, and 429 for rate limiting.

When should I not use these API design guidelines?

Avoid them when you only need framework-specific implementation help, when doing infrastructure-only work without API contracts, or when you cannot change or version public interfaces. The guidance targets design decisions, not library internals.