← ClaudeAtlas

api-organizationlisted

Explains the standardized API organization pattern for this codebase. Use when creating new API endpoints, API clients, or modifying existing API structure. Covers the 5-file system (endpoint-types, endpoints, api-client, admin-api-client, protected-endpoints), role-based access patterns (admin vs regular users), and TypeScript type safety across the API layer. All API code lives in src/lib/api/ following this exact pattern.
aiskillstore/marketplace · ★ 329 · API & Backend · score 79
Install: claude install-skill aiskillstore/marketplace
# API Organization Pattern This skill defines the standardized API organization pattern used throughout this codebase. All external API integrations follow the same 5-file structure for consistency, type safety, and maintainability. ## When to Use This Skill Use this skill when: - Creating new API endpoints or integrations - Adding new API categories or domains - Implementing role-based API access (admin vs regular users) - Modifying existing API structure - Setting up authentication for API calls - Creating type-safe API wrappers ## Core Principles 1. **Single Source of Truth** - All API URLs defined once in `endpoints.ts` 2. **Type Safety** - Full TypeScript coverage from params to responses 3. **Role-Based Access** - Separate clients for regular vs admin endpoints 4. **Centralized Auth** - Authentication handled automatically by clients 5. **DRY Code** - Reusable client functions, no duplicate endpoint definitions ## The 5-File System All API code lives in `src/lib/api/` with exactly these files: ``` src/lib/api/ ├── endpoint-types.ts # TypeScript types for all endpoints ├── endpoints.ts # URL definitions organized by domain ├── api-client.ts # Generic authenticated API client ├── admin-api-client.ts # Admin-only API client with role checks └── protected-endpoints.ts # Type-safe wrapper functions ``` ### File Purposes **1. endpoint-types.ts** - Define all TypeScript interfaces for API data - Organize types by domain (e.g., audience