All skills
asyrafhussin avatar

/api-design-patterns

@1de3a7a

RESTful API design, error handling, versioning, and best practices. Use when designing APIs, reviewing endpoints, implementing error responses, or setting up API structure. Triggers on "design API", "review API", "REST best practices", or "API patterns".

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/api-design-patterns

This session only. Nothing lands on disk.

rulesver-header-based.md

≈657 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Version via Accept Header

Impact: HIGH (Clean URLs with content negotiation-based versioning for API evolution)

Header-based versioning uses the Accept header to specify the desired API version, keeping URLs clean and resource-centric. This approach aligns with HTTP content negotiation semantics and is preferred when URL aesthetics matter or when the same resource should be accessible across versions without changing its canonical URL.

Incorrect

# No version information at all — client gets whatever the current version is
GET /api/users/1
Accept: application/json
# Or: custom non-standard header
GET /api/users/1
X-API-Version: 2

Problems:

  • No standard mechanism to request a specific version of the response format
  • Custom headers are not part of HTTP content negotiation and may be stripped by proxies
  • Clients have no guarantee about the response shape they will receive
  • X- prefixed headers are deprecated by RFC 6648 and signal non-standard behavior

Correct

# Request version 1
GET /api/users/1
Accept: application/vnd.myapi.v1+json
{
  "id": 1,
  "name": "Jane Smith",
  "email": "jane@example.com"
}
# Request version 2
GET /api/users/1
Accept: application/vnd.myapi.v2+json
{
  "id": 1,
  "full_name": "Jane Smith",
  "email_address": "jane@example.com",
  "profile": {
    "avatar_url": "https://cdn.example.com/avatars/1.jpg"
  }
}
# Server responds with matching Content-Type
HTTP/1.1 200 OK
Content-Type: application/vnd.myapi.v2+json
Aspect URL Path (/v1/) Accept Header
Visibility Version in every URL Hidden in headers
Caching Simple (URL-based) Requires Vary: Accept
Browser testing Easy (type URL) Needs tool (curl, Postman)
URL cleanliness Extra path segment Clean resource URLs
HTTP semantics Convention-based Proper content negotiation

Benefits:

  • URLs remain clean and resource-focused — /api/users/1 is the canonical identifier
  • Follows HTTP content negotiation standards (Accept / Content-Type)
  • Server can default to the latest version when no version header is sent
  • Multiple representations of the same resource at the same URL, which aligns with REST principles

Reference: GitHub API - Media Types

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill is a comprehensive documentation library for RESTful API design patterns. It provides best practices for resource design, error handling, security, and documentation. The skill contains no executable code, malicious instructions, or hidden functionality, and its references are restricted to well-known technical documentation sources.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    4/28 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 1de3a7a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
metadata
{
  "author": "agent-skills",
  "version": "2.0.0"
}

README badge

README badge for asyrafhussin/agent-skills/api-design-patterns