Xpersona
R

REST API Design

CLAWHUB · Unverified

REST API design patterns: resource naming, HTTP methods, status codes, pagination, filtering, authentication, rate limiting, versioning, and response formats... Skill: REST API Design Owner: djc00p Summary: REST API design patterns: resource naming, HTTP methods, status codes, pagination, filtering, authentication, rate limiting, versioning, and response formats... Tags: latest:1.0.1 Version history: v1.0.1 | 2026-05-06T01:14:15.725Z | user Fix: replace placeholder token format to clear static analysis false positive (Authorization: Bearer *token* → <your-api-token>). v1.0.0

62
Rank
84
Safety
1.3k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.3K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17akx17qd32yxnr1065qq0kdd83h2c3:rest-api-design
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-djc00p-rest-api-design/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

18,190 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: rest-api-design
description: "REST API design patterns: resource naming, HTTP methods, status codes, pagination, filtering, authentication, rate limiting, versioning, and response formats. Use when designing new endpoints, reviewing API contracts, or planning API strategies. Trigger phrases: API design, endpoint design, REST API, API versioning, schema design. Adapted from everything-claude-code by @affaan-m (MIT)"
metadata: {"clawdbot":{"emoji":"🔌","requires":{"bins":[],"env":[]},"os":["darwin","linux","win32"]}}
---

# API Design Patterns

Design consistent, developer-friendly REST APIs with resource naming, HTTP semantics, and versioning.

## When to Activate

- Designing new API endpoints
- Reviewing existing API contracts
- Adding pagination, filtering, or authentication
- Planning API versioning strategy
- Building public or partner-facing APIs

## Quick Start

1. Use nouns (plural, kebab-case) for resource URLs, not verbs
2. Apply correct HTTP method (GET/POST/PUT/PATCH/DELETE)
3. Return appropriate status codes (200/201/400/401/403/404/429)
4. Use consistent response format (data + metadata + error structure)
5. Implement pagination (cursor-based preferred) and filtering
6. Require authentication and check authorization per resource

## Key Concepts

- **Resource naming** — Plural nouns in kebab-case; use verbs sparingly for actions
- **HTTP semantics** — Each method has idempotency/safety properties; honor them
- **Status codes** — Signal intent precisely (400 for validation, 422 for semantic error)
- **Error format** — Consistent structure with codes, messages, and field details
- **Versioning** — URL path versioning (v1, v2); non-breaking changes don't need new version

## Common Usage

Most frequent patterns:
- CRUD endpoints (GET, POST, PUT, PATCH, DELETE)
- List endpoints with pagination and filtering
- Sub-resources for relationships (users/:id/orders)
- Authentication headers and permission checks
- Rate limiting headers and strategies

## References

- `references/resource-design.md` — URL structure, naming rules, HTTP methods, status codes, response formats
- `references/pagination-filtering-auth.md` — Pagination strategies, filtering, sorting, authentication, rate limiting, versioning, and checklist

_meta.json

{
  "ownerId": "kn75k4jwpn9qgy3pk38e93gkt982zqmg",
  "slug": "rest-api-design",
  "version": "1.0.1",
  "publishedAt": 1778030055725
}

references/pagination-filtering-auth.md

# Pagination, Filtering, and Authentication

## Pagination Strategies

### Offset-Based (Simple)

```bash
GET /api/v1/users?page=2&per_page=20
```

**Pros:** Easy, supports "jump to page N"
**Cons:** Slow on large offsets, inconsistent with concurrent inserts

### Cursor-Based (Scalable)

```bash
GET /api/v1/users?cursor=eyJpZCI6MTIzfQ&limit=20
```

**Pros:** Consistent performance, stable with concurrent inserts
**Cons:** Cannot jump to arbitrary page

## Filtering, Sorting, and Search

### Filtering

```bash
# Simple equality
GET /api/v1/orders?status=active&customer_id=abc-123

# Comparison operators
GET /api/v1/products?price[gte]=10&price[lte]=100

# Multiple values
GET /api/v1/products?category=electronics,clothing
```

### Sorting

```bash
# Single field (- for descending)
GET /api/v1/products?sort=-created_at

# Multiple fields
GET /api/v1/products?sort=-featured,price,-created_at
```

### Full-Text Search

```bash
GET /api/v1/products?q=wireless+headphones
```

### Sparse Fieldsets

```bash
# Return only specified fields
GET /api/v1/users?fields=id,name,email
```

## Authentication and Authorization

### Token-Based Auth

```bash
GET /api/v1/users
Authorization: Bearer <your-api-token>
```

### Resource-Level Authorization

```typescript
app.get("/api/v1/orders/:id", async (req, res) => {
  const order = await Order.findById(req.params.id);
  if (!order) return res.status(404).json({ error: { code: "not_found" } });
  if (order.userId !== req.user.id) return res.status(403).json({ error: { code: "forbidden" } });
  return res.json({ data: order });
});
```

## Rate Limiting

### Response Headers

```bash
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000

# When exceeded
HTTP/1.1 429 Too Many Requests
Retry-After: 60
```

### Rate Limit Tiers

| Tier | Limit | Window |
|------|-------|--------|
| Anonymous | 30/min | Per IP |
| Authenticated | 100/min | Per user |
| Premium | 1000/min | Per API key |

## API Versioning Strategy

### URL Path Versioning (Recommended)

```bash
/api/v1/users
/api/v2/users
```

### Non-Breaking Changes (No Version Bump)

- Adding new fields to responses
- Adding new optional query parameters
- Adding new endpoints

### Breaking Changes (New Version)

- Removing or renaming fields
- Changing field types
- Changing URL structure
- Changing authentication method

### Deprecation Timeline

1. Announce deprecation (6 months notice)
2. Add `Sunset` header: `Sunset: Sat, 01 Jan 2026 00:00:00 GMT`
3. Return `410 Gone` after sunset date

references/resource-design.md

# API Resource Design Patterns

## URL Structure

```bash
# Resources are nouns, plural, lowercase, kebab-case
GET    /api/v1/users
GET    /api/v1/users/:id
POST   /api/v1/users
PUT    /api/v1/users/:id
PATCH  /api/v1/users/:id
DELETE /api/v1/users/:id

# Sub-resources for relationships
GET    /api/v1/users/:id/orders
POST   /api/v1/users/:id/orders

# Actions that don't map to CRUD (use verbs sparingly)
POST   /api/v1/orders/:id/cancel
POST   /api/v1/auth/login
```

## Naming Rules

| Good | Bad |
|------|-----|
| `/api/v1/team-members` | `/api/v1/getTeamMembers` |
| `/api/v1/users?status=active` | `/api/v1/user` |
| `/api/v1/users/123/orders` | `/api/v1/users/123/getOrders` |

## HTTP Methods and Status Codes

### Method Semantics

| Method | Idempotent | Safe | Use For |
|--------|-----------|------|---------|
| GET | Yes | Yes | Retrieve resources |
| POST | No | No | Create resources, trigger actions |
| PUT | Yes | No | Full replacement of a resource |
| PATCH | No* | No | Partial update of a resource |
| DELETE | Yes | No | Remove a resource |

### Status Code Reference

| Code | Meaning | When to Use |
|------|---------|------------|
| 200 | OK | GET, PUT, PATCH with response body |
| 201 | Created | POST (include Location header) |
| 204 | No Content | DELETE, PUT (no response body) |
| 400 | Bad Request | Validation failure, malformed JSON |
| 401 | Unauthorized | Missing or invalid authentication |
| 403 | Forbidden | Authenticated but not authorized |
| 404 | Not Found | Resource doesn't exist |
| 409 | Conflict | Duplicate entry, state conflict |
| 422 | Unprocessable Entity | Semantically invalid (valid JSON, bad data) |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Unexpected failure (never expose details) |
| 503 | Service Unavailable | Temporary overload, include Retry-After |

## Response Format

### Success Response

```json
{
  "data": {
    "id": "abc-123",
    "email": "alice@example.com",
    "name": "Alice",
    "created_at": "2025-01-15T10:30:00Z"
  }
}
```

### Collection Response (with Pagination)

```json
{
  "data": [
    { "id": "abc-123", "name": "Alice" },
    { "id": "def-456", "name": "Bob" }
  ],
  "meta": {
    "total": 142,
    "page": 1,
    "per_page": 20,
    "total_pages": 8
  }
}
```

### Error Response

```json
{
  "error": {
    "code": "validation_error",
    "message": "Request validation failed",
    "details": [
      {
        "field": "email",
        "message": "Must be a valid email address",
        "code": "invalid_format"
      }
    ]
  }
}
```

skill-card.md

## Description:

Provides REST API design guidance for resource naming, HTTP methods, status codes, pagination, filtering, authentication, rate limiting, versioning, and response formats.

This skill is ready for commercial/non-commercial use.

## Publisher:

[djc00p](https://clawhub.ai/user/djc00p)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and engineers use this skill to design new REST endpoints, review API contracts, add pagination, filtering, authentication, and authorization patterns, and plan API versioning for public or partner-facing APIs.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Generated destructive endpoint designs, such as DELETE operations, may omit project-specific authorization, audit, or safety requirements.

Mitigation: Review destructive endpoint proposals against your authorization model, audit requirements, and operational safety controls before implementation.

## Reference(s):

- [API Resource Design Patterns](references/resource-design.md)
- [Pagination, Filtering, and Authentication](references/pagination-filtering-auth.md)
- [REST API Design ClawHub Page](https://clawhub.ai/djc00p/skills/rest-api-design)

## Skill Output:

**Output Type(s):** [guidance, markdown, code, shell commands, configuration]

**Output Format:** [Markdown with API examples, code snippets, endpoint patterns, tables, and checklists]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Markdown-only guidance; no executable behavior or required local tools.]

## Skill Version(s):

1.0.1 (source: release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to REST API Design and adjacent AI workflows.