api-design-principles

Design REST and GraphQL APIs with schema-first patterns and versioning.

1|1|Updated Dec 15, 2024
One-click install
npx skills add https://github.com/Alejocabeza/dotfiles --skill api-design-principles-alejocabeza
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/Alejocabeza/dotfiles/tree/main/opencode/skills/api-design-principles
Command: npx skills add https://github.com/Alejocabeza/dotfiles --skill api-design-principles-alejocabeza

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

APIs across teams often suffer from inconsistency, fragmentation, and vague guidelines, making adoption and maintenance costly.

Core Features & Use Cases

  • REST and GraphQL design principles covering resource modeling, versioning, pagination, error handling, and documentation.
  • Patterns for resource design, input/output payloads, and data loading to prevent N+1 problems.
  • Use cases include designing new APIs, auditing existing specifications, and standardizing API quality across products.

Quick Start

Draft a REST or GraphQL design plan for a new service following the patterns described above, starting with a schema-first approach.

Frequently Asked Questions about api-design-principles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best practices for REST and GraphQL API design?

REST and GraphQL API design involves enforcing a schema-first approach, proper versioning, pagination, and error handling. Following these patterns ensures intuitive, scalable APIs and prevents common issues like GraphQL N+1 query problems using DataLoader.

How do I standardize API design guidelines across multiple teams?

Standardize API design by establishing shared guidelines for resource modeling, input/output payloads, and documentation. Applying consistent REST and GraphQL patterns across products prevents fragmentation and reduces maintenance costs.

How do I prevent N+1 query problems in GraphQL APIs?

Prevent GraphQL N+1 query problems by implementing DataLoader patterns. DataLoader batches and caches data fetching requests efficiently, ensuring scalable data loading without overwhelming your backend with redundant database queries.

What is a schema-first approach for API development?

A schema-first approach for API development means defining the API contract and data models before writing backend code. This establishes clear input/output payloads and documentation guidelines early, ensuring consistent REST and GraphQL implementations.

How do I audit existing API specifications for consistency?

Audit existing API specifications by reviewing them against established REST and GraphQL design principles. Check for proper versioning, pagination, error handling, and clear documentation to identify fragmentation and enforce quality standards across services.

When should I use REST versus GraphQL for my API?

Choose REST for resource modeling, versioning, and simple data fetching, or GraphQL for complex nested queries. Both require clear documentation and error handling, but GraphQL specifically benefits from DataLoader to manage data loading efficiently.