api-design-principles

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

Updated Aug 13, 2026
One-click install
npx skills add https://github.com/Martino17x/Sentinel-Invest --skill api-design-principles-martino17x
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/Martino17x/Sentinel-Invest/tree/main/.agents/skills/api-design-principles
Command: npx skills add https://github.com/Martino17x/Sentinel-Invest --skill api-design-principles-martino17x

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Designing consistent, scalable 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. ## Core Features & Use Cases - REST Design Patterns: Resource-oriented endpoints, HTTP method semantics, pagination, filtering, HATEOAS, and standardized error responses with correct status codes. - GraphQL Design Patterns: Schema-first development, Relay cursor pagination, DataLoader-based N+1 prevention, input/payload mutation patterns, and deprecation strategies. - Ready-to-Use Resources: A FastAPI REST template, a pre-implementation design checklist, and in-depth reference guides for REST best practices and GraphQL schema design. - Use Case: When reviewing a new API specification, apply the checklist to verify naming conventions, status codes, rate limiting, and authentication before implementation begins. ## Quick Start Ask the AI to review your API endpoint design or generate a paginated FastAPI user endpoint following REST best practices.

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 query parameters like page and page_size with sensible defaults (e.g., 20 items, max 100), and return metadata including total count and page numbers. For large datasets, cursor-based pagination performs better than offset-based approaches.

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

Use the DataLoader pattern to batch and cache database requests within a single query execution. A DataLoader collects all IDs requested during resolution and fetches them in one query, eliminating per-item database round trips.

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

REST fits resource-oriented services with simple CRUD operations and caching needs, while GraphQL suits clients needing flexible data fetching from multiple related entities. GraphQL requires DataLoaders and query complexity limits to stay performant.

What HTTP status codes should a REST API return?▼

Return 200 for successful reads, 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, prefer the @deprecated directive to phase out fields gradually instead of publishing new schema versions.

Why does my GraphQL API slow down with nested queries?▼

Deeply nested queries trigger N+1 database fetches and unbounded complexity. Add DataLoaders for relationships, enforce query depth limits, and apply complexity analysis to reject expensive queries before execution.