Viết Tài Liệu API
PROTạo tài liệu API đầy đủ từ code hoặc spec. Hỗ trợ OpenAPI, REST, GraphQL kèm ví dụ và xử lý lỗi.
Ví dụ sử dụng
Tạo OpenAPI spec cho REST API e-commerce từ code Python FastAPI.
Cách sử dụng Skill này
Sao chép skill bằng nút ở trên
Dán vào trợ lý AI của bạn (Claude, ChatGPT, v.v.)
Điền thông tin bên dưới (tùy chọn) và sao chép để thêm vào prompt
Gửi và bắt đầu trò chuyện với AI của bạn
Tùy chỉnh gợi ý
| Mô tả | Mặc định | Giá trị của bạn |
|---|---|---|
| Loại API | rest | |
| Định dạng đầu ra | markdown | |
| Ngôn ngữ lập trình tôi đang sử dụng | Python |
Authentication
[Auth Method]
Include your API key in the request header:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.example.com/v1/resource
Endpoints
[Resource Name]
List [Resources]
GET /resources
Description: [What this endpoint does]
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | No | Max results (default: 20, max: 100) |
offset | integer | No | Pagination offset |
sort | string | No | Sort field (e.g., created_at) |
Request Example:
curl -X GET "https://api.example.com/v1/resources?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
Response (200 OK):
{
"data": [
{
"id": "res_123",
"name": "Example Resource",
"created_at": "2024-01-15T10:30:00Z"
}
],
"meta": {
"total": 100,
"limit": 10,
"offset": 0
}
}
Create [Resource]
POST /resources
Description: [What this endpoint does]
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Resource name |
config | object | No | Configuration options |
Request Example:
curl -X POST "https://api.example.com/v1/resources" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "New Resource",
"config": {
"enabled": true
}
}'
Response (201 Created):
{
"data": {
"id": "res_456",
"name": "New Resource",
"config": {
"enabled": true
},
"created_at": "2024-01-15T10:35:00Z"
}
}
Error Handling
Error Response Format
{
"error": {
"code": "VALIDATION_ERROR",
"message": "The 'name' field is required",
"details": [
{
"field": "name",
"issue": "required"
}
]
}
}
Error Codes
| HTTP Code | Error Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid request data |
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 403 | FORBIDDEN | Insufficient permissions |
| 404 | NOT_FOUND | Resource not found |
| 429 | RATE_LIMITED | Too many requests |
| 500 | SERVER_ERROR | Internal server error |
Rate Limiting
| Plan | Requests/min | Burst |
|---|---|---|
| Free | 60 | 10 |
| Pro | 600 | 100 |
| Enterprise | Custom | Custom |
Rate limit headers:
X-RateLimit-Limit: Max requestsX-RateLimit-Remaining: Remaining requestsX-RateLimit-Reset: Reset timestamp
SDKs & Examples
JavaScript/Node.js
import { Client } from '@example/sdk';
const client = new Client('YOUR_API_KEY');
// List resources
const resources = await client.resources.list({ limit: 10 });
// Create resource
const newResource = await client.resources.create({
name: 'New Resource'
});
Python
from example import Client
client = Client(api_key="YOUR_API_KEY")
# List resources
resources = client.resources.list(limit=10)
# Create resource
new_resource = client.resources.create(name="New Resource")
Webhooks
Event Types
resource.createdresource.updatedresource.deleted
Payload Format
{
"event": "resource.created",
"timestamp": "2024-01-15T10:35:00Z",
"data": {
"id": "res_456",
"name": "New Resource"
}
}
Changelog
| Version | Date | Changes |
|---|---|---|
| v1.2.0 | 2024-01-15 | Added webhooks support |
| v1.1.0 | 2024-01-01 | New rate limits |
| v1.0.0 | 2023-12-01 | Initial release |
## What I Need
1. **API type**: REST, GraphQL, WebSocket?
2. **Endpoints/Operations**: What can users do?
3. **Authentication**: How do users authenticate?
4. **Data models**: Key objects and their fields?
5. **Code/Spec**: Existing code or OpenAPI spec?
6. **Audience**: Beginner or experienced developers?
Let's document your API!
---
## How to Use
1. Copy the skill above
2. Paste into your AI assistant
3. Share your API details or code
4. Get comprehensive documentation
## Kết quả bạn sẽ nhận được
- Complete API reference
- Request/response examples
- Error handling guide
- Authentication details
- SDK code examples