Skip to content

API documentation (Outdated)

이준혁 edited this page Jul 11, 2023 · 1 revision

정확한 API 엔드포인트 확인 및 테스팅은 다음 Link에서 확인할 수 있다.

LINK

모든 request, response form format은 JSON이다.

Possible Success Status-Code(HTTP):

  • 200 OK: 요청이 성공적으로 처리되었음.
  • 201 Created: 클라이언트가 리소스를 생성하도록 요청했고, 요청이 성공적으로 처리되었음.
  • 204 No Content: 요청이 성공적으로 처리되었지만 응답 본문에 추가적인 콘텐츠가 없음.
  • 400 Bad Request: 잘못된 자원을 사용하여 API를 호출했을 때 나오는 Err.
  • 401 Unauthorize: 유저 정보를 파악할 수 없을 때 나오는 Err.(보통 헤더에 유저 access_token을 미포함 혹은 잘못된 형식으로 제공했을 때 나옴)
  • 404 Not Found: API URL이 잘못되었을 때 나오는 Err.
  • 500 Internal Server Error: 서버가 작동하지 않을 때 나오는 Err.

User Application

User Login

유저의 로그인에 사용되는 API.

[POST] api/v1/user/login

  • request
{
    "email": string,
    "password": string,
}
  • response
 > 200 OK
{
    "access_token": string,
    "refresh_token": string,

    "user": {
        "user_id": string,
        "username": string,
        "email": string,
        "profile_image": Object[Image],
        "followers": int,
        "followings": int,
    }
}

User Logout

유저의 로그아웃에 사용되는 API.

[POST] api/v1/user/logout

  • request
{
    "refresh": string  // 유저의 refresh token. 로그아웃이 되고 나면 해당 token은 black list db에 업로드 된다.
}
  • response
 > 200 OK
{
    "detail": "Successfully logged out."
}

JWT Verify

JWT(JSON Web Token)을 검증하는데 사용되는 API.

[POST] api/v1/user/token/verify

  • request
{
    "token": string
}
  • response
 > 200 OK

JWT Refresh

JWT(JSON Web Token)을 새로 발급받을 때 사용하는 API.

[POST] api/v1/user/token/refresh

  • request
{
    "refresh": string
}
  • response
 > 200 OK
{
    "access": string,
    "refresh": string,
}

User Register

회원가입 시 사용되는 API.

[POST] api/v1/user/register

  • request
{
    "username": string,
    "email": string,
    "password": string,
}
  • response
 > 201 Created
{
    "is_success": True,
    "detail": register success,
}

 > 400 Bad Request
{
    "is_success": False,
    "detail": User exist.,
}

Get User Profile

개별 유저의 프로필을 검색하는데 사용되는 API.
여기서 사용되는 user_id는 1, 2, 3... 씩 늘어나는 autoincrease 속성을 가진 컬럼이 아니라 as1qQWnD4lsAA 형식같이 uuid를 가지는 컬럼이다.

[GET] api/v1/user/{user_id}/profile

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "user_id": string,
    "username": string,
    "profile_image": Object[Image],
    "followers": int,
    "followings": int,
}

Search User

유저를 검색하는데 사용되는 API.

[GET] api/v1/user/search

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "username": string,
}
  • response
 > 200 OK
{
    "searched_users": [
        {
            "user_id": string,
            "username": string,
            "profile_image": Object[Image],
            "followers": int,
            "followings": int,
        },
        {
            "user_id": string,
            "username": string,
            "profile_image": Object[Image],
            "followers": int,
            "followings": int,
        },
        ...
    ]
}

Edit User Profile

유저의 프로필을 수정하는데 사용되는 API.
본인의 프로필만 변경 가능함.

[PUT] api/v1/user/{user_id}/profile

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "username": string,
    "profile_image": Object[Image],
}
  • response
 > 200 OK
{
    "is_success": True,
    "detail": profile edit success,
}

User Delete

유저 탈퇴 시 사용되는 API.
본인 계정만 탈퇴 가능.

[DELETE] api/v1/user/{user_id}/withdrawal

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 204 No Content
{
    "is_success": True,
    "detail": user deleted,
}

Follow User

특정 유저를 팔로우 할 때 사용되는 API. 여기서, 팔로우할 특정 유저는 {user_id}가 가리키는 유저이다.

[POST] api/v1/user/{user_id}/follow

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "is_success": True,
    "detail": user follow success,
}

Unfollow User

팔로우한 특정 유저를 언팔로우 할 때 사용되는 API. 여기서, 언팔로우할 특정 유저는 {user_id}가 가리키는 유저이다.

[POST] api/v1/user/{user_id}/unfollow

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "is_success": True,
    "detail": user unfollow success,
}

Followers Check

특정 유저의 팔로워를 확인할 때 사용되는 API.

[GET] api/v1/user/{user_id}/followers

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "followers_list": [
        {
            "username": string,
            "profile_image": Object[Image],
        },
        {
            "username": string,
            "profile_image": Object[Image],
        },
        ...
    ]
}

Followings Check

특정 유저가 팔로우한 계정들을 확인할 때 사용되는 API.

[GET] api/v1/user/{user_id}/followings

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "followings_list": [
        {
            "username": string,
            "profile_image": Object[Image],
        },
        {
            "username": string,
            "profile_image": Object[Image],
        },
        ...
    ]
}

Save user's FCM Device Token

로그인한 유저의 디바이스에 대한 정보를 Firebase와 연동하여 DB에 저장하는 API.

[POST] api/v1/user/device

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "fcmToken": string
}
  • response
 > 200 OK
{
    "is_success": True,
    "detail": "FCM Token saved"
}

Post Application

Make Post

Post를 작성할 때 사용되는 API.

[POST] api/v1/post/{post_id}

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "post_title": string,
    "post_content": string,
    "post_image": [
        Object[Image],
        Object[Image],
        ...
    ],
    "landmark_name": string,
}
  • response
 > 201 Created
{
    "is_success": True,
    "detail": post success,
}

Get Post

특정 post를 불러올 때 사용되는 API.

[GET] api/v1/post/{post_id}

  • request
  • response
 > 200 OK
{
    "post_id": int,
    "user_id": string,
    "post_title": string,
    "post_content": string,
    "post_image": [
        Object[Image],
        Object[Image],
        ...
    ],
    "landmark_name": string,
    "landmark_latitude": float,
    "landmark_longitude": float,
    "created_at": Datetime,
    "likes": int,
    "comments": int,
}

Edit Post

특정 게시물을 수정할 때 사용되는 API.
자신이 작성한 게시물만 수정 가능.

[PUT] api/v1/post/{post_id}

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "post_title": string,
    "post_content": string,
    "post_image": [
        Object[Image],
        ...
    ],
}
  • response
 > 200 OK
{
    "post_id": int,
    "user_id": string,
    "post_title": string,
    "post_content": string,
    "post_image": [
        Object[Image],
        Object[Image],
        ...
    ],
    "landmark_name": string,
    "landmark_latitude": float,
    "landmark_longitude": float,
    "created_at": Datetime,
    "likes": int,
    "comments": int,
}

Delete Post

특정 게시물을 삭제할 때 사용되는 API.
자신이 작성한 게시물만 삭제 가능.

[DELETE] api/v1/post/{post_id}

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 204 No Content
{
    "is_success": True,
    "detail": post delete success,
}

Get User's Posts

특정 유저가 작성한 게시물들을 불러올 때 사용되는 API.

[GET] api/v1/post/posts/{user_id}

{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "user_posts": [
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        ...
    ]
}

Get Posts

메인 페이지에 표시되는 유저 피드 게시물들을 불러올 때 사용되는 API.
Backend -> trending, following, recommend 포스트들을 불러올 알고리즘 및 cache기능 구현 필요.

[GET] api/v1/post/feed

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 200 OK
{
    "followed_posts": [
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        ...
    ],
    "trending_posts": [
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        ...
    ],
    "recommended_posts": [
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        ...
    ]
}

// Example response:

{
    "followed_posts": [
        {
            "post_id": 1,
            "user_id": "as1qQWnD4lsAA",
            "post_title": "post title",
            "post_content": "post content",
            "post_image": [
                "http://example.com/media/images/post1.jpg"
                ...
            ],
            "landmark_name": "name of location",
            "landmark_latitude": "76.5",
            "landmark_longitude": "123",
            "created_at": "2022-10-10T14:48:00.000Z",
            "likes": 100,
            "comments": 50,
        },
        // more posts...
    ],
    "trending_posts": [
        // similar structure as followed_posts...
    ],
    "recommended_posts": [
        // similar structure as followed_posts...
    ]
}

Make Comment

댓글을 작성할 때 사용되는 API.

[POST] api/v1/post/{post_id}/comments

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "comment_content": string
}
  • response
 > 201 Created
{
    "is_success": True,
    "detail": "comment create success",
}

Get Comment

특정 댓글을 불러올 때 사용되는 API.

[GET] api/v1/post/{post_id}/comments/{comment_id}

  • request
  • response
 > 200 OK
{
    "username": string,
    "comment_content": string,
    "created_at": Datetime,
}

Get All Comments

특정 게시물에 작성된 모든 댓글들을 불러올 때 사용되는 API.

[GET] api/v1/post/{post_id}/comments

  • request
  • response
 > 200 OK
{
    "comments": [
        {
            "username": string,
            "comment_content": string,
            "created_at": Datetime,
        },
        {
            "username": string,
            "comment_content": string,
            "created_at": Datetime,
        },
        ...
    ]
}

Edit Comment

특정 댓글을 수정할 때 사용되는 API.
자신이 작성한 댓글만 수정 가능.

[PUT] api/v1/post/{post_id}/comments/{comment_id}

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
{
    "comment_content": string,
}
  • response
 > 200 OK
{
    "is_success": True,
    "detail": "comment edit success"
}

Delete Comment

특정 댓글을 삭제할 때 사용되는 API.
자신이 작성한 댓글만 삭제 가능.

[DELETE] api/v1/post/{post_id}/comments/{comment_id}

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 204 No Content
{
    "is_success": True,
    "detail": "comment delete success"
}

Make Like

자신이 특정 게시물에 좋아요를 누를 때 사용되는 API.

[POST] api/v1/post/{post_id}/like

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 201 Created
{
    "is_success": True,
    "detail": "post like success"
}

Cancel Like

특정 게시물에 눌렀던 좋아요를 취소할 때 사용하는 API.

[POST] api/v1/post/{post_id}/unlike

  • header
{
    "Authorization": "Bearer <access_token>"
}
  • request
  • response
 > 204 No Content
{
    "is_success": True,
    "detail": "cancel post like success"
}

Landmark Application

Get 3 Random Landmarks

랜덤한 3개의 랜드마크의 이름, 썸네일, 위치를 띄울 때 사용되는 API.

[GET] api/v1/landmark/recommends

  • request
  • response
 > 200 OK
{
    "recommends": [
        {
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "landmark_thumbnail": Object[Image]
        },
        {
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "landmark_thumbnail": Object[Image]
        },
        {
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "landmark_thumbnail": Object[Image]
        },
    ]
}

Get Landmark

특정 랜드마크의 정보(게시물 수, 좋아요 수 포함)를 불러오는 API.

[GET] api/v1/landmark/{landmark_id}

  • request
  • response
 > 200 OK
{
    "landmark_name": string,
    "landmark_latitude": float,
    "landmark_longitude": float,
    "landmark_thumbnail": Object[Image],
    "landmark_likes": int,
    "landmark_posts": int,
}

Search Landmark

특정 랜드마크를 검색할 때 사용되는 API.

[GET] api/v1/landmark/search?landmark_name=<검색어>

  • request
  • response
 > 200 OK
{
    "searched_landmarks": [
        {
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "landmark_thumbnail": Object[Image],
            "landmark_likes": int,
            "landmark_posts": int,
        },
        {
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "landmark_thumbnail": Object[Image],
            "landmark_likes": int,
            "landmark_posts": int,
        },
        ...
    ]
}

Get All Posts at Landmark

특정 랜드마크에 pin 되어 있는 게시물들을 불러올 때 사용되는 API.

[GET] api/v1/landmark/{landmark_id}/posts

  • request
  • response
 > 200 OK
{
    "landmark_posts": [
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        {
            "post_id": int,
            "user_id": string,
            "post_title": string,
            "post_content": string,
            "post_image": [
                Object[Image],
                Object[Image],
                ...
            ],
            "landmark_name": string,
            "landmark_latitude": float,
            "landmark_longitude": float,
            "created_at": Datetime,
            "likes": int,
            "comments": int,
        },
        ...
    ]
}

Clone this wiki locally