api-design-principles

Guides REST and GraphQL API design with patterns for versioning, pagination, and error handling.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-design-principles-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/api-design-principles
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-design-principles-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing consistent, maintainable APIs is hard: teams struggle with inconsistent naming, poor error formats, missing pagination, N+1 query problems in GraphQL, and breaking changes that frustrate API consumers. ## Core Features & Use Cases - REST Design Guidance: Resource-oriented endpoint design, correct HTTP method semantics, status codes, pagination, filtering, and HATEOAS link patterns with FastAPI examples. - GraphQL Design Guidance: Schema-first development, connection-based cursor pagination, input/payload mutation patterns, and DataLoader usage to prevent N+1 queries. - Versioning & Standards: URL, header, and query-parameter versioning strategies plus best-practice checklists for rate limiting, documentation, and deprecation. - Use Case: When reviewing a new endpoint specification before implementation, apply the resource-oriented patterns and error-handling conventions to catch action-oriented URLs, missing pagination, and inconsistent error formats early. ## Quick Start Ask the assistant to review your proposed API endpoints or design a new REST or GraphQL API following these principles.

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 RESTful API endpoints correctly?

Use resource-oriented URLs with plural nouns like /api/users, and apply HTTP methods for actions: GET to retrieve, POST to create, PUT to replace, PATCH to update, and DELETE to remove. Avoid action-oriented endpoints like /api/createUser.

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

REST suits resource-oriented services with standard HTTP semantics and caching, while GraphQL lets clients request exactly the fields they need through a single typed endpoint. GraphQL requires DataLoaders to avoid N+1 query problems.

How do I prevent N+1 queries in GraphQL?

Use the DataLoader pattern to batch and cache data fetching. A DataLoader collects IDs requested within a resolver pass and fetches them in a single batch query, returning results mapped to the original IDs.

What API versioning strategy should I use?

Common options are URL versioning (/api/v1/users), header versioning via the Accept header, and query parameter versioning. URL versioning is the most visible and widely adopted; choose one strategy and plan for breaking changes from day one.

How should REST APIs handle errors and status codes?

Return correct HTTP status codes: 2xx for success, 4xx for client errors like 404 Not Found and 422 Unprocessable Entity, and 5xx for server errors. Standardize error response bodies with a consistent structure including error type, message, and details.

When should I avoid cursor-based pagination in GraphQL?

Cursor-based pagination following the Relay connection spec is recommended for large or frequently changing datasets. For small static lists, simple offset arguments may suffice, but connections with PageInfo provide consistent forward and backward navigation.