api-design-principles

Design REST and GraphQL APIs using resource-oriented patterns, pagination, and error handling standards.

Updated Jul 28, 2026
One-click install
npx skills add https://github.com/truongnat/Restly --skill api-design-principles-truongnat
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/truongnat/Restly/tree/main/.agents/skills/api-design-principles
Command: npx skills add https://github.com/truongnat/Restly --skill api-design-principles-truongnat

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, wrong HTTP status codes, missing pagination, N+1 query problems in GraphQL, and breaking changes that frustrate API consumers. ## Core Features & Use Cases - REST Design Guidance: Resource-oriented URL patterns, correct HTTP method semantics, status code conventions, pagination strategies, rate limiting, and versioning approaches. - GraphQL Schema Patterns: Schema-first design, Relay cursor pagination, DataLoader-based N+1 prevention, input/payload mutation patterns, and deprecation strategies. - Ready-to-Use Assets: A pre-implementation review checklist and a production-style FastAPI template with pagination, filtering, and structured error responses. - Use Case: When designing a new users API, apply the resource naming conventions, wire cursor or offset pagination, return standardized error payloads, and validate the spec against the included checklist before implementation. ## Quick Start Review my API endpoint design for a users resource and recommend REST conventions for pagination, error handling, and versioning.

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.

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 queries and exact field selection. GraphQL requires DataLoaders to avoid N+1 queries and complexity limits to prevent expensive queries.

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

Use the DataLoader pattern to batch and cache relationship lookups in a single query per request. Combine this with query depth limiting and complexity analysis to protect the API from 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 for missing auth, 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/query parameter versioning for cleaner URLs. For GraphQL, evolve the schema by adding nullable fields and marking old ones with the @deprecated directive instead of removing them.

What are common REST API design mistakes to avoid?▼

Avoid verbs in URLs, inconsistent error formats, missing rate limits, deep resource nesting beyond two levels, and mirroring database schemas directly in the API. Standardize error responses and document endpoints with OpenAPI.