Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

rest-api

БесплатноБез исполняемых скриптовНе проверен

REST API design principles. Covers resources, methods, and status codes. Use when designing or reviewing REST APIs. USE WHEN: user mentions "REST API"…

claude-dev-suiteот claude-dev-suite★ 51 звезда на GitHub

Об этом скилле

REST API Core Knowledge

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: rest-api for comprehensive documentation.

Resource Naming

# Collections (plural nouns)
GET    /users              # List users
POST   /users              # Create user
GET    /users/{id}         # Get user
PUT    /users/{id}         # Update user
DELETE /users/{id}         # Delete user

# Nested resources
GET    /users/{id}/posts   # User's posts
POST   /users/{id}/posts   # Create user's post

# Avoid verbs in URLs
❌ GET /getUsers
❌ POST /createUser
✅ GET /users
✅ POST /users

HTTP Methods

Method Purpose Idempotent
GET Read resource Yes
POST Create resource No
PUT Replace resource Yes
PATCH Partial update Yes
DELETE Remove resource Yes

Status Codes

Code Meaning Use Case
200 OK Successful GET/PUT/PATCH
201 Created Successful POST
204 No Content Successful DELETE
400 Bad Request Validation error
401 Unauthorized Missing/invalid auth
403 Forbidden No permission
404 Not Found Resource doesn't exist
409 Conflict Duplicate/conflict
422 Unprocessable Semantic error
500 Server Error Internal error

Response Format

// Success
{
  "data": { "id": 1, "name": "John" },
  "meta": { "timestamp": "2024-01-15T10:00:00Z" }
}

// Collection
{
  "data": [...],
  "meta": { "total": 100, "page": 1, "limit": 20 }
}

// Error
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Email is required",
    "details": [{ "field": "email", "message": "Required" }]
  }
}

Query Parameters

GET /users?status=active&sort=-createdAt&page=1&limit=20
GET /users?fields=id,name,email
GET /users?include=posts,profile
GET /users?filter[age][gte]=18

When NOT to Use This Skill

  • GraphQL API design (use graphql skill)
  • tRPC type-safe APIs (use trpc skill)
  • OpenAPI specification writing (use openapi skill)
  • Real-time APIs requiring WebSockets or SSE
  • APIs requiring complex nested queries (consider GraphQL)

Anti-Patterns

Anti-Pattern Why It's Bad Solution
Using verbs in URLs (/getUser, /createOrder) Not RESTful, violates resource naming Use HTTP methods on nouns (GET /users, POST /orders)
Returning 200 for errors Misleading, breaks HTTP semantics Use appropriate 4xx/5xx status codes
Not versioning API Breaking changes affect all clients Use URL or header versioning (/v1/, /v2/)
Exposing database IDs directly Security risk, implementation leak Use UUIDs or opaque identifiers
No pagination on large collections Performance issues, timeouts Implement cursor or offset pagination
Ignoring HTTP caching headers Poor performance, unnecessary load Use ETag, Cache-Control, Last-Modified
Using GET for state-changing operations Security risk, breaks REST principles Use POST, PUT, PATCH, DELETE
Inconsistent response formats Client confusion, integration issues Standardize on JSON envelope format
Missing rate limiting API abuse, resource exhaustion Implement rate limiting with 429 responses

Quick Troubleshooting

Issue Possible Cause Solution
401 Unauthorized Missing or invalid auth token Check Authorization header, verify token
403 Forbidden Valid auth but insufficient permissions Check user roles, verify access control
404 Not Found Resource doesn't exist or wrong path Verify endpoint URL, check resource ID
409 Conflict Resource already exists or state conflict Check uniqueness constraints, handle idempotency
422 Unprocessable Entity Validation failed Check request body, validate against schema
429 Too Many Requests Rate limit exceeded Implement backoff, check rate limit headers
500 Internal Server Error Server-side bug or crash Check server logs, add error handling
CORS errors Missing CORS headers Configure CORS middleware with allowed origins
Slow API responses No pagination, N+1 queries Add pagination, optimize database queries

Production Readiness

Security Configuration

// Input validation and sanitization
import { z } from 'zod';

const CreateUserSchema = z.object({
  name: z.string().min(1).max(100).trim(),
  email: z.string().email().toLowerCase(),
  age: z.number().int().min(0).max(150).optional(),
});

// Validate request body
app.post('/users', async (req, res) => {
  const result = CreateUserSchema.safeParse(req.body);
  if (!result.success) {
    return res.status(400).json({
      error: { code: 'VALIDATION_ERROR', details: result.error.issues },
    });
  }
  // Use result.data (validated and transformed)
});

// SQL injection prevention - always use parameterized queries
// NEVER: `SELECT * FROM
Полный SKILL.md на GitHub

Установить rest-api в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob

Вложенные файлы

quick-ref/conventions.mdquick-ref/error-handling.md

FAQ

Что делает скилл rest-api?

REST API design principles. Covers resources, methods, and status codes. Use when designing or reviewing REST APIs. USE WHEN: user mentions "REST API", "RESTful", "HTTP methods", "status codes", "resource naming", "API endpoints", "pagination", "versioning", asks about "how to design REST API", "REST best practices", "API documentation", "HTTP verbs" DO NOT USE FOR: GraphQL APIs - use `graphql` instead; tRPC - use `trpc` instead; OpenAPI specs - use `openapi` instead; Spring Boot REST - combine with `springdoc-openapi`

Как установить скилл rest-api?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл rest-api запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить rest-api с