home / skills / leavesfly / jimi / api-design
This skill guides RESTful API design using resource-oriented principles, enabling consistent, scalable endpoints with JSON responses and proper error handling.
npx playbooks add skill leavesfly/jimi --skill api-designReview the files below or copy the command above to add this skill to your agents.
---
name: api-design
description: RESTful API design best practices and conventions guide
---
# API Design Skill
This skill provides comprehensive guidance for designing RESTful APIs following industry best practices.
## Core Principles
### 1. Resource-Oriented Design
- Use nouns for resource names (e.g., `/users`, `/products`)
- Avoid verbs in URLs
- Use HTTP methods to represent actions
### 2. HTTP Methods
- **GET**: Retrieve resources
- **POST**: Create new resources
- **PUT**: Update entire resources
- **PATCH**: Partial updates
- **DELETE**: Remove resources
### 3. URL Structure
```
GET /api/v1/users - List all users
GET /api/v1/users/{id} - Get specific user
POST /api/v1/users - Create new user
PUT /api/v1/users/{id} - Update user
DELETE /api/v1/users/{id} - Delete user
```
### 4. Response Format
- Use JSON as default format
- Use camelCase for field names
- Include metadata (pagination, timestamps)
### 5. Error Handling
```json
{
"error": {
"code": "INVALID_REQUEST",
"message": "User ID must be a positive integer",
"details": []
}
}
```
### 6. Status Codes
- 200: Success
- 201: Created
- 400: Bad Request
- 401: Unauthorized
- 404: Not Found
- 500: Internal Server Error
## Best Practices
- Version your APIs
- Use pagination for list endpoints
- Implement rate limiting
- Document with OpenAPI/Swagger
This skill delivers practical guidance for designing RESTful APIs using widely adopted conventions and industry best practices. It focuses on resource-oriented design, clear URL structure, consistent response formats, and robust error handling. The guidance is language-agnostic but uses examples that map easily to Java-based backends. It helps teams produce predictable, maintainable, and versioned APIs.
The skill inspects API design decisions and recommends patterns: noun-based resource naming, correct HTTP method usage, and logical URL hierarchies. It defines response and error formats (JSON, camelCase fields, metadata) and maps common operations to appropriate status codes. It also recommends operational considerations like pagination, rate limiting, and OpenAPI documentation to make APIs discoverable and reliable.
Should I use verbs in endpoint paths?
No. Use nouns for resources and let HTTP methods indicate actions to keep URLs intuitive and RESTful.
When do I version my API in the path vs headers?
Path versioning (e.g., /api/v1/) is simple and explicit; header versioning can be used for silent evolution but is harder for tooling and debugging.
How should errors be structured?
Return a JSON object with an error code, human-readable message, and optional details array to help clients programmatically handle failures.