본문 바로가기
AI에서 살아남기(to. Android Developer)/1인 프로젝트

(모두의 웹툰) Part 6: API 설계

by 개발자 인민군 2025. 12. 17.

API 설계 원칙

  •  RESTful 원칙 준수
  • API 버전 관리: `/api/v1`
  • 응답 형식: JSON
  • 모든 응답은 `success`, `data`/`message` 포함
  • 어드민 API는 JWT 토큰 인증 필수

사용자 앱 API (인증 불필요)

1. 섹션 목록 조회 (홈 화면)

GET /api/v1/sections?page=1&limit=3

홈 화면에 표시할 섹션 목록과 각 섹션 내 웹툰을 조회합니다.

 

요청 파라미터:

  • `page`: 페이지 번호 (기본값: 1)
  • `limit`: 페이지당 섹션 개수 (기본값: 3)

응답 예시:

더보기
{
  "success": true,
  "data": {
    "sections": [
      {
        "id": "section-1",
        "name": "이주의 추천",
        "order": 1,
        "isAdult": false,
        "webtoons": [
          {
            "id": "webtoon-1",
            "title": "화산귀환",
            "thumbnail": "https://...",
            "isAdult": false,
            "order": 1
          }
        ]
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 3,
      "total": 15,
      "totalPages": 5,
      "hasNextPage": true
    }
  }
}

2. 웹툰 상세 조회

GET /api/v1/webtoons/{webtoonId}

특정 웹툰의 상세 정보를 조회합니다.

응답 예시:

더보기
{
  "success": true,
  "data": {
    "id": "webtoon-1",
    "title": "화산귀환",
    "author": "작가명",
    "thumbnail": "https://...",
    "description": "화산이 돌아온다. 이번에는 다르다...",
    "rating": 4.5,
    "genre": "판타지",
    "isComplete": false,
    "isAdult": false,
    "serialDays": ["월", "수", "금"],
    "tags": ["액션", "복수", "무협"],
    "deepLinks": [
      {
        "platform": "네이버",
        "url": "https://comic.naver.com/webtoon/detail?titleId=123"
      },
      {
        "platform": "카카오",
        "url": "https://page.kakao.com/content/..."
      }
    ]
  }
}

 

어드민 API (JWT 인증 필수)

모든 어드민 요청에는 다음 헤더가 필요합니다:

Authorization: Bearer {JWT_TOKEN}
Content-Type: application/json

웹툰 관리 API

메서드 엔드포인트 설명
POST /api/v1/admin/webtoons 웹툰 추가
GET /api/v1/admin/webtoons 웹툰 목록 조회
GET /api/v1/admin/webtoons/{id} 웹툰 상세 조회
PUT /api/v1/admin/webtoons/{id} 웹툰 수정
DELETE /api/v1/admin/webtoons/{id} 웹툰 삭제

섹션 관리 API

메서드 엔드포인트 설명
POST /api/v1/admin/sections/{id}/webtoons 섹션에 웹툰 할당
DELETE /api/v1/admin/sections/{id}/webtoons/{webtoonId} 섹션에서 웹툰 제거
PUT /api/v1/admin/sections/{id}/webtoons/reorder 섹션 내 웹툰 순서 변경
GET /api/v1/admin/sections/{id}/webtoons 섹션 내 웹툰 조회

API 응답 형식

성공응답

{
  "success": true,
  "data": { ... }
}

에러 응답

{
  "success": false,
  "message": "에러 메시지"
}