api-design-principles

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

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill api-design-principles-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/agents/.agents/skills/api-design-principles
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill api-design-principles-ravitejakarra24

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, N+1 query problems in GraphQL, unclear error formats, and unplanned versioning. This Skill provides concrete REST and GraphQL design patterns, checklists, and working code templates to build well-structured APIs from the start. ## Core Features & Use Cases - REST Design Patterns: Resource-oriented URL structures, correct HTTP method semantics, status codes, pagination (offset, cursor, Link header), filtering, sorting, rate limiting, and idempotency keys. - GraphQL Schema Design: Schema-first development, Relay cursor pagination, input/payload mutation patterns, DataLoader-based N+1 prevention, query depth and complexity limiting, and deprecation strategies. - Ready-to-Use Assets: A production-style FastAPI template with pagination, validation, and error handling, plus a comprehensive pre-implementation API design checklist. - Use Case: When designing a new users endpoint, apply the resource-oriented patterns, paginate with cursor or offset strategies, return consistent error responses, and validate the design against the checklist before implementation. ## Quick Start Ask the agent to design a REST or GraphQL API for your resource, for example: design a paginated GraphQL schema with mutations for an orders API following 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 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.

How do I prevent N+1 queries in GraphQL?

Use DataLoaders to batch and cache database requests per request cycle. A DataLoader collects all IDs requested during resolver execution and fetches them in a single query, then maps results back in input order.

Should I use REST or GraphQL for my API?

REST fits resource-oriented services with simple CRUD and caching needs, while GraphQL suits clients needing flexible field selection and aggregated data from multiple sources. GraphQL requires DataLoaders and query complexity limits to stay performant.

What is the best way to version an API?

URL versioning like /api/v1/users is the most visible and easiest to route, while header versioning keeps URLs clean. In GraphQL, prefer schema evolution with the @deprecated directive instead of hard version cuts.

Which HTTP status codes should a REST API return?

Return 200 for successful reads and updates, 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.

When should I avoid cursor-based pagination?

Cursor pagination adds complexity and does not support jumping to arbitrary pages, so it is a poor fit for small datasets or admin interfaces needing numbered page navigation. Offset pagination is simpler and sufficient for those cases.