개요
HTTP 동사
본 REST API에서 사용하는 HTTP 동사(verbs)는 가능한한 표준 HTTP와 REST 규약을 따릅니다.
| 동사 | 용례 |
|---|---|
|
리소스를 가져올 때 사용 |
|
새 리소스를 만들 때 사용 |
|
기존 리소스를 수정할 때 사용 |
|
기존 리소스의 일부를 수정할 때 사용 |
|
기존 리소스를 삭제할 떄 사용 |
Response API JSON
//성공
{
"status" : "success",
"message" : null,
"data" : { data }
}
//일반 에러
{
"status" : "fail",
"message" : "fail message",
"data" : null
}
//예외 발생
{
"status" : "error",
"message" : "error message",
"data" : null
}
예외 메시지 형식
{
"status" : "error",
"message" : "[{오류값}] {오류필드}: {오류메시지}.",
"data" : null
}
회원
회원 가입
Request
POST /api/v1/auth/signup HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 93
Host: localhost:8080
{
"account" : "test1234",
"password" : "test123*",
"passwordConfirm" : "test123*"
}
Response
-
201 Created
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Content-Length: 64
{
"status" : "success",
"message" : null,
"data" : 0
}
-
400 BadRequest
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Content-Length: 125
{
"status" : "error",
"message" : "[1] account: 계정명을 6 ~ 20 사이로 입력해주세요.",
"data" : null
}
로그인
Request
POST /api/v1/auth/login HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 57
Host: localhost:8080
{
"account" : "test123",
"password" : "test123*"
}
Response
-
200
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 249
{
"status" : "success",
"message" : null,
"data" : {
"grantType" : "올바른 Grant 타입",
"accessToken" : "새로운 Access 토큰",
"refreshToken" : "새로운 Refresh 토큰",
"accessTokenExpiresIn" : 166574
}
}
-
400
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Content-Length: 112
{
"status" : "error",
"message" : "[null] password: 비밀번호가 틀렸습니다.",
"data" : null
}
토큰 재발급
Request
POST /api/v1/auth/login HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 57
Host: localhost:8080
{
"account" : "test123",
"password" : "test123*"
}
Response
-
200
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 249
{
"status" : "success",
"message" : null,
"data" : {
"grantType" : "올바른 Grant 타입",
"accessToken" : "새로운 Access 토큰",
"refreshToken" : "새로운 Refresh 토큰",
"accessTokenExpiresIn" : 166574
}
}
-
400
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Content-Length: 112
{
"status" : "error",
"message" : "[null] password: 비밀번호가 틀렸습니다.",
"data" : null
}
로그아웃
Request
POST /api/v1/auth/logout HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 97
Host: localhost:8080
{
"accessToken" : "올바른 Access 토큰",
"refreshToken" : "올바른 Refresh 토큰"
}
Response
-
200
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 67
{
"status" : "success",
"message" : null,
"data" : null
}
사용자 정보 조회
Request
GET /api/v1/member/1 HTTP/1.1
Authorization: JWT_TOKEN
Host: localhost:8080
Response
-
200
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 317
{
"status" : "success",
"message" : null,
"data" : {
"account" : "test1234",
"createdAt" : null,
"updatedAt" : null,
"authority" : "ROLE_USER",
"memberLocation" : {
"lat" : 1232.111,
"logt" : 212.1232,
"createdAt" : null,
"updatedAt" : null
}
}
}
-
401
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
Content-Length: 101
{
"status" : "error",
"message" : "[] : 유요한 자격이 없습니다.",
"data" : null
}
사용자 위치 정보 수정
Request
PUT /api/v1/member/location/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: JWT_TOKEN
Content-Length: 44
Host: localhost:8080
{
"lat" : 112.121,
"logt" : 121.121
}
Response
-
201
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Content-Length: 64
{
"status" : "success",
"message" : null,
"data" : 1
}
-
403
HTTP/1.1 403 Forbidden
Content-Type: application/json;charset=UTF-8
Content-Length: 117
{
"status" : "error",
"message" : "[1] memberId: 필요한 접근 권한이 없습니다.",
"data" : null
}
시구군
시구군 목록 조회
Request
GET /api/v1/location HTTP/1.1
Host: localhost:8080
Response
-
200 Ok
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 66
{
"status" : "success",
"message" : null,
"data" : [ ]
}
맛집
사용자 위치 기반 맛집 목록 조회
Request
GET /api/v1/restaurants?lat=37.2040&lon=127.07596008849987&range=2.0&sort=distance HTTP/1.1
Host: localhost:8080
Response
-
200 Ok
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 66
{
"status" : "success",
"message" : null,
"data" : [ ]
}
맛집 상세 조회
Request
GET /api/v1/restaurants/1 HTTP/1.1
Host: localhost:8080
Response
-
200 Ok
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 67
{
"status" : "success",
"message" : null,
"data" : null
}
리뷰
리뷰 작성
request
POST /api/v1/reviews/members/1/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: JWT_TOKEN
Content-Length: 53
Host: localhost:8080
{
"score" : 4.5,
"content" : "리뷰 내용"
}
response
-
201
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Content-Length: 64
{
"status" : "success",
"message" : null,
"data" : 1
}
-
400 (점수 형식 틀림)
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Content-Length: 142
{
"status" : "error",
"message" : "[4.3] score: 1.0에서 5.0 사이인 0.5 단위의 점수를 입력해주세요",
"data" : null
}
회사의 모든 리뷰 조회
request
GET /api/v1/reviews/restaurants/1 HTTP/1.1
Host: localhost:8080
response
-
200
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 464
{
"status" : "success",
"message" : null,
"data" : {
"reviews" : [ {
"reviewId" : 1,
"score" : 4.5,
"content" : "리뷰 내용",
"userAccount" : "test1234"
}, {
"reviewId" : 2,
"score" : 4.5,
"content" : "리뷰 내용",
"userAccount" : "test1234"
}, {
"reviewId" : 3,
"score" : 4.5,
"content" : "리뷰 내용",
"userAccount" : "test1234"
} ]
}
}
리뷰 수정
request
PUT /api/v1/reviews/members/1/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: JWT_TOKEN
Content-Length: 53
Host: localhost:8080
{
"score" : 4.5,
"content" : "리뷰 내용"
}
response
-
201
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Content-Length: 64
{
"status" : "success",
"message" : null,
"data" : 1
}
-
404 (이전에 작성한 리뷰가 없을 때)
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
Content-Length: 115
{
"status" : "error",
"message" : "[1] restaurantId: 리뷰를 찾을 수 없습니다.",
"data" : null
}
리뷰 삭제
request
DELETE /api/v1/reviews/members/1/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: JWT_TOKEN
Host: localhost:8080
response
-
200
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 65
{
"status" : "success",
"message" : null,
"data" : ""
}
-
404 (이전에 작성한 리뷰가 없을 때)
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
Content-Length: 115
{
"status" : "error",
"message" : "[1] restaurantId: 리뷰를 찾을 수 없습니다.",
"data" : null
}