도서관리 서비스 api 설계

Younha Lee·2026년 2월 9일

TIL

목록 보기
27/62

오늘은 도서관리 서비스의 API를 설계했어요.

1. 회원 API

1. 회원가입

구분내용
MethodPOST
URI/register
HTTP status code성공 201
Request Body{ "email" : "사용자가 입력한 이메일", "password" : "사용자가 입력한 비밀번호" }
Response Bodyx

2. 로그인

구분내용
Method
URI/login
HTTP status code성공 200
Request Body`{

"email" : "사용자가 입력한 이메일",
"password" : "사용자가 입력한 비밀번호"
}` |
| Response Body | JWT_TOKEN |

3. 비밀번호 초기화 요청

구분내용
MethodPOST
URI/reset
HTTP status code성공 200
Request Body{ "email" : "사용자가 입력한 이메일" }
Response Bodyx

4. 비밀번호 초기화 (수정)

구분내용
MethodPUT
URI/reset
HTTP status code성공 200
Request Body{ "email" : "사용자가 입력한 이메일", "password" : "사용자가 입력한 새로운 비밀번호" }
Response Bodyx

2. 도서 API

1. 전체 도서 조회

구분내용
MethodGET
URI/books
HTTP status code성공 200
Request Bodyx
Response Body[ { "id": "도서 id", "title": "도서 제목", "summary": "요약 설명", "author": "도서 작가", "price": "가격", "likes": "좋아요 수", "pubDate": "출간일" }, ... ]

2. 개별 도서 조회

구분내용
MethodGET
URI/books/{bookid}
HTTP status code성공 200
Request Bodyx
Response Body{ "id": "도서 id", "title": "도서 제목", "category": "카테고리", "format": "포맷", "isbn": "isbn", "summary": "요약 설명", "description": "상세 설명", "author": "도서 작가", "pages": "쪽 수", "index": "목차", "price": "가격", "likes": "좋아요 수", "liked": true, "pubDate": "출간일" }

3. 카테고리별 도서 목록 조회

구분내용
MethodGET
URI/books?category_id={category_id}&new={boolean}
HTTP status code성공 200
Request Bodyx
Response Body[ { "id": "도서 id", "title": "도서 제목", "summary": "요약 설명", "author": "도서 작가", "price": "가격", "likes": "좋아요 수", "pubDate": "출간일" }, ... ]

3. 좋아요 API

1. 좋아요

구분내용
MethodPUT
URI/likes/{bookId}
HTTP status code성공 200
Request Bodyx
Response Bodyx

2. 좋아요 취소

구분내용
MethodDELETE
URI/likes/{bookId}
HTTP status code성공 204
Request Bodyx
Response Bodyx
  • 저는 DELETE의 성공으로 204가 맞다고 생각하여 204를 붙였어요.

4. 장바구니 API

1. 장바구니 담기

구분내용
MethodPOST
URI/cart
HTTP status code성공 201
Request Body{ "bookId" : "도서 id", "count" : "수량" }
Response Bodyx

2. 장바구니 조회

구분내용
MethodGET
URI/cart
HTTP status code성공 200
Request Bodyx
Response Body[ { "cartItemId": "장바구니 도서 id", "bookId": "도서 id", "title": "도서 제목", "summary": "도서 요약", "count": "수량", "price": "가격" }, ... ]

3. 장바구니 도서 삭제

구분내용
MethodDELETE
URI/cart/{bookid}
HTTP status code성공 200
Request Bodyx
Response Bodyx

4. 장바구니에서 선택한 주문 '예상' 상품 목록 조회

구분내용
MethodGET
URI/cart
HTTP status code성공 200
Request Body{ cart_item_id, cart_item_id, ...}
Response Body[{ "cartItemId": "장바구니 도서 id","bookId": "도서 id", "title": "도서 제목", "summary": "도서 요약", "count": "수량", "price": "가격" }, { "cartItemId": "장바구니 도서 id", "bookId": "도서 id", "title": "도서 제목", "summary": "도서 요약", "count": "수량", "price": "가격" }]

api 설계를 하다보니 화면에 맞게 하려면 이 부분이 주문 상품이 아니라 주문 예상 품목이 되어야함을 알아 수정했어요.

5. 주문 API

1. 장바구니에서 선택한 상품 목록 조회

구분내용
MethodPOST
URI/orders
HTTP status code성공 200
Request Body
{
"items": [
{
"bookId": "도서 Id",
"count": "수량"
}
],
"delivery": {
"address": "주소",
"receiver": "이름",
"contact": "010-xxxx-xxxx"
},
"totalPrice": "총 금액"
}
Response Body[ { "cartItemId": "장바구니 도서 id", "bookId": "도서 id", "title": "도서 제목", "summary": "도서 요약", "count": "수량", "price": "가격" }, ... ]

2. 주문 목록(내역) 조회

구분내용
MethodGET
URI/orders
HTTP status code성공 200
Request Body(없음)
Response Body
[
{
"created_at": "주문일자",
"delivery": {
"address": "주소",
"receiver": "이름",
"contact": "전화번호"
},
"bookTitle": "대표 책 제목",
"totalPrice": "결제 금액",
"totalCount": "총 수량"
}
]

3. 주문 상세 조회

구분내용
MethodGET
URI/orders/{order_id}
HTTP status code성공 200
Request Body(없음)
Response Body
[
{
"bookId": "도서 Id",
"bookTitle": "도서 제목",
"author": "작가명",
"price": "가격",
"count": "수량"
},
{
"bookId": "도서 Id",
"bookTitle": "도서 제목",
"author": "작가명",
"price": "가격",
"count": "수량"
}
]
profile
할 땐 하고 놀 땐 노는 일일놀놀입니다.

0개의 댓글