在 Manus 中运行任何 Skill
一键导入
一键导入
一键在 Manus 中运行任何 Skill
开始使用api-integration-best-practices
星标0
分支0
更新时间2026年1月5日 10:25
RESTful API 설계 및 통합 전용 스킬
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
RESTful API 설계 및 통합 전용 스킬
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | API Integration Best Practices |
| description | RESTful API 설계 및 통합 전용 스킬 |
// Bearer Token 방식
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
interface APIError {
status: number;
code: string;
message: string;
details?: any;
}
interface APIResponse<T> {
success: boolean;
data?: T;
error?: APIError;
pagination?: PaginationInfo;
}
GET /api/v1/users # 사용자 목록
GET /api/v1/users/{id} # 특정 사용자
POST /api/v1/users # 사용자 생성
PUT /api/v1/users/{id} # 사용자 수정
DELETE /api/v1/users/{id} # 사용자 삭제
# 중첩 리소스
GET /api/v1/users/{id}/orders
POST /api/v1/users/{id}/orders
# 필터링
GET /api/v1/products?category=electronics&status=active
# 정렬
GET /api/v1/products?sort=price&order=desc
# 페이지네이션
GET /api/v1/products?page=2&limit=50
# 필드 선택
GET /api/v1/users?fields=id,name,email
200 OK: 일반적인 성공201 Created: 리소스 생성 성공204 No Content: 삭제 성공400 Bad Request: 잘못된 요청401 Unauthorized: 인증 필요403 Forbidden: 권한 없음404 Not Found: 리소스 없음422 Unprocessable Entity: 유효성 검증 실패500 Internal Server Error: 서버 오류502 Bad Gateway: 게이트웨이 오류503 Service Unavailable: 서비스 불가class APIClient {
constructor(
private baseURL: string,
private apiKey: string,
private timeout: number = 30000
) {}
private async request<T>(
method: string,
endpoint: string,
data?: any
): Promise<APIResponse<T>> {
const url = `${this.baseURL}${endpoint}`;
const config = {
method,
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
},
body: data ? JSON.stringify(data) : undefined,
signal: AbortSignal.timeout(this.timeout),
};
try {
const response = await fetch(url, config);
const result = await response.json();
if (!response.ok) {
throw new APIError(result.error || 'Request failed', response.status);
}
return result;
} catch (error) {
// 에러 처리 및 로깅
throw this.handleError(error);
}
}
get<T>(endpoint: string): Promise<APIResponse<T>> {
return this.request<T>('GET', endpoint);
}
post<T>(endpoint: string, data: any): Promise<APIResponse<T>> {
return this.request<T>('POST', endpoint, data);
}
}
async function withRetry<T>(
operation: () => Promise<T>,
maxRetries: number = 3,
delay: number = 1000
): Promise<T> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await operation();
} catch (error) {
if (attempt === maxRetries) throw error;
if (shouldRetry(error)) {
await sleep(delay * Math.pow(2, attempt - 1)); // 지수 백오프
continue;
}
throw error;
}
}
}
describe('API Integration', () => {
it('should handle success response', async () => {
const response = await apiClient.get('/users/1');
expect(response.success).toBe(true);
expect(response.data).toBeDefined();
});
it('should handle 404 error', async () => {
await expect(apiClient.get('/users/999'))
.rejects
.toThrow('User not found');
});
it('should retry on network error', async () => {
// 네트워크 장애 시나리오 테스트
});
});