api-design-principles

Design REST and GraphQL APIs with resource-oriented endpoints, pagination, and error handling patterns.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/scoots31/engineering-playbook --skill api-design-principles-scoots31
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/scoots31/engineering-playbook/tree/main/references/api-design-principles
Command: npx skills add https://github.com/scoots31/engineering-playbook --skill api-design-principles-scoots31

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing APIs without consistent conventions leads to confusing endpoints, breaking changes, and frustrated consumers. This Skill provides proven REST and GraphQL design patterns so your APIs are intuitive, versioned, and maintainable from day one. ## Core Features & Use Cases - REST Design Patterns: Resource-oriented URL structures, correct HTTP method semantics, pagination, filtering, HATEOAS links, and standardized error responses with proper status codes. - GraphQL Design Patterns: Schema-first type definitions, Relay-style cursor pagination, input/payload mutation types, and DataLoader-based N+1 query prevention. - API Versioning & Standards: Guidance on URL, header, and query-parameter versioning plus best practices for rate limiting, documentation, and deprecation. - Use Case: When building a new FastAPI backend, use this Skill to structure your endpoints, implement paginated list responses, and return consistent validation errors before writing any business logic. ## Quick Start Ask the AI to design a REST API for your resource using the api-design-principles skill, including 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 a REST API with proper resource endpoints?

Use plural nouns for collections like /api/users and map HTTP methods to actions: GET reads, POST creates, PUT replaces, PATCH updates, DELETE removes. Avoid action-oriented URLs like /api/createUser, and nest related resources such as /api/users/{id}/orders.

How to implement pagination in a FastAPI endpoint?

Accept page and page_size query parameters with validation bounds, compute an offset from the page number, and return a response containing items, total count, current page, and total pages. Cap page_size at a maximum like 100 to protect performance.

REST vs GraphQL: which should I use for my API?

REST fits resource-centric services with simple caching and standard HTTP semantics, while GraphQL suits clients needing flexible queries that fetch exactly the fields they require. GraphQL adds schema and resolver complexity and requires DataLoaders to avoid N+1 query problems.

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

Use DataLoader to batch and cache per-request data fetching. A loader collects IDs from multiple resolver calls within one request and issues a single batched database query, then maps results back to the original request order.

What HTTP status codes should API errors return?

Return 400 for malformed requests, 401 for missing authentication, 403 for forbidden access, 404 for missing resources, 409 for conflicts, and 422 for validation failures. Pair each with a consistent error body containing an error code, message, and details object.

When should I version my API and which strategy works best?

Version your API from the start to allow breaking changes without disrupting existing clients. URL versioning like /api/v1/users is the most visible and common approach, while header and query-parameter versioning keep URLs stable at the cost of discoverability.