API 가이드
API 사용법과 예제
API 가이드
이 문서에서는 대시보드에서 제공하는 API의 사용법을 설명합니다.
인증
모든 API 요청에는 인증 토큰이 필요합니다:
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://api.example.com/dashboard/stats
주요 엔드포인트
통계 조회
// GET /api/dashboard/stats
const response = await fetch('/api/dashboard/stats', {
headers: {
Authorization: 'Bearer ' + token,
},
});
const data = await response.json();
console.log(data);
데이터 업데이트
// POST /api/dashboard/update
const response = await fetch('/api/dashboard/update', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
metric: 'page_views',
value: 1000,
}),
});
응답 형식
모든 API 응답은 다음 형식을 따릅니다:
{
"success": true,
"data": {},
"message": "Success"
}