Skip to content

API 문서 ver.3

Poogle edited this page Jul 3, 2020 · 12 revisions

API 문서 - airbnb 5조

메인 화면 접속 후 github으로 로그인하기 버튼

github OAuth 로그인 후 jwt 토큰이 발급될 scheme

  • airbnbfive://oauth?token=
  • token 뒤에 나오는 값이 로그인한 해당 유저의 jwt 토큰입니다.
  • 모든 요청 시 jwt 토큰을 헤더에 담아서 보내주세요.

API 구현 상황

  • 지도 api의 경우 숙소의 위도, 경도 정보를 메인 화면에 제공하는 것으로 대체합니다.

API 요청 주소

  • {url} : 54.227.20.96:8080

시나리오

  • Github Login - OAuth
  • 로그인 완료 후 도시 선택 화면
  • 도시 선택 후 해당 도시 (10) 간략정보 요청 (메인 화면)
  • 스크롤 내릴 때마다 (10) 데이터 더 요청
  • 날짜. 인원 필터링 탭 완료 버튼 누를 때의 조건으로 필터링된 정보 제공
  • 가격 탭 클릭 시 필터링된 숙소 리스트의 평균 가격을 제공
  • 하트 클릭 시 Patch 요청으로 해당 유저의 즐겨찾기 숙소 등록/해제
  • 즐겨찾기 탭 클릭 시 해당 유저의 즐겨 찾기 숙소 목록 반환
  • 숙소 클릭 시 상세 정보 제공
  • 숙소 상세 화면에서 예약하기
  • 예약 탭에서 예약한 숙소 정보 확인
  • 예약 탭에서 예약 취소 요청하기
  • 지도 제공

추가 확인 사항

도시 별 숙소 개수

  • 1: 290
  • 2: 287
  • 3: 252
  • 4: 281
  • 5: 284
  • 6: 300
  • 7: 251
  • 8: 282
  • 9: 342
  • 10: 328
  • 11: 210
  • 12: 314

총: 3421

숙소 최저, 최고 가격

  • 최저: 9230원 (room_id: 2734, 유일한 10000원 이하 숙소)
  • 최고: 9227830원 (room_id: 2372)

필터링을 하지 않을 때 필터의 기본 값들

  • guests: 1
  • minPrice: 0
  • maxPrice: 9227830
  • checkIn: 1900-01-01
  • checkOut: 2021-12-31

변수명 설명

이름 설명
offset 시작하는 레코드 몇 번째인지
limit 몇 개의 레코드인지
  • path variable, request parameter 제외 response 변수 명은 단어 구분 시 '_' 추가
  • 변수명 오류 있으면 알려주세요!

api 설명

  • 모든 Request Header에 발급한 토큰 넣어서 요청
number method url 설명 참고
1 GET /cities 도시 리스트 조회
2 GET /cities/{cityId}/rooms?limit=10&offset=0&checkIn=2020-05-09&checkOut=2020-05-18&guests=1&minPrice=10000&maxPrice=100000 숙소 필터링 후 간략 정보 제공, default 10개 제공 숙소 정보 10개씩 0번부터 (0, 10, 20, ... ) 도시 별 약 300개 숙소
3 GET /cities/{cityId}/prices?checkIn=2020-05-09&checkOut=2020-05-18&guests=1 가격 필터링 탭 평균값 날짜, 인원 수 선택적으로 요청
4 GET /cities/{cityId}/rooms/{roomId} 방 상세 정보 페이지
5 POST /bookmarks/{roomId} 즐겨찾기 등록 요청
6 DELETE /bookmarks/{roomId} 즐겨찾기 해제 요청
7 GET /bookmarks 즐겨찾기 목록
8 POST /reservation 예약하기 날짜와 인원 정보 담아서 요청(필수)
9 DELETE /reservation/{reservationId} 예약 취소하기 path variable
11 GET /reservation 예약 조회하기

Json 형태

1. 도시 리스트

GET {url}/cities

  • Response
{
    "status_code": 200,
    "data": [
        {
            "city_id": 1,
            "city_name": "Asheville"
        },
        {
            "city_id": 2,
            "city_name": "Austin"
        },
        ...생략
        ]
}

2. 조건 필터링, 7. 즐겨찾기 목록

  • 같은 형식의 response가 갈 것
    1. 즐겨찾기 목록의 경우 favorite 항목이 무조건 true

GET {url}/cities/{cityId}/rooms?checkIn=2020-05-09&checkOut=2020-05-18&guests=1&minPrice=10000&maxPrice=100000

GET {url}/bookmarks

{
    "status_code": 200,
    "data": [
        {
            "room_id": 2,
            "room_name": "French Chic Loft",
            "room_thumbnail": "https://a0.muscache.com/im/pictures/29807425/62a6b073_original.jpg?aki_policy=large",
            "is_super_host": true,
            "room_type": "Entire home/apt",
            "beds": 6,
            "scores": 4.8,
            "reviews": 108,
            "favorite": true,
            "image_lists": [
                "https://a0.muscache.com/im/pictures/2ee5c482-c48f-4108-9c18-e17c1951b1a0.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/5e771b01-3412-4873-99df-e74f89c3126e.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/84577734/93ca63b3_original.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/f5d54435-d02a-40be-b3e5-7decc398b5d8.jpg?aki_policy=large"
            ],
            "latitude": 5.5978,
            "longitude": -82.5554
        },
        {
            "room_id": 18,
            "room_name": "Private Asheville Cabin Apartment",
            "room_thumbnail": "https://a0.muscache.com/im/pictures/10501426/e1dc2455_original.jpg?aki_policy=large",
            "is_super_host": false,
            "room_type": "Entire home/apt",
            "beds": 2,
            "scores": 4.95,
            "reviews": 30,
            "favorite": true,
            "image_lists": [
                "https://a0.muscache.com/im/pictures/4322757/37fe7f19_original.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/17b3140b-ed1b-4273-825a-65eef65d8d56.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/78b3e1eb-d3a4-4e5f-b17a-fc1403f20441.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/12308008/a02886b7_original.jpg?aki_policy=large"
            ],
            "latitude": 35.6284,
            "longitude": -82.4799
        },
        {
            "room_id": 22,
            "room_name": "City Vibe Loft",
            "room_thumbnail": "https://a0.muscache.com/im/pictures/457f21d9-6ae2-4924-8071-e8229948aca7.jpg?aki_policy=large",
            "is_super_host": true,
            "room_type": "Entire home/apt",
            "beds": 4,
            "scores": 4.85,
            "reviews": 85,
            "favorite": false,
            "image_lists": [
                "https://a0.muscache.com/im/pictures/6508250/9123726c_original.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/852ccc25-0e51-4522-af71-d7d11f3b3880.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/692b8862-c2b6-4692-bbaf-6e22b5b1a02f.jpg?aki_policy=large",
                "https://a0.muscache.com/im/pictures/81795975-09f1-4607-ad74-bc9c08c28bc0.jpg?aki_policy=large"
            ],
            "latitude": 35.5979,
            "longitude": -82.5534
        }
    ]
}

3. 가격 필터링 탭 화면

GET {url}/cities/{cityId}/prices?check_in=2020-06-16&check_out=2020-06-18&guests=1

  • 가격 필터링 탭 평균값, 해당 범위 숙소 전체 가격 배열(오름차순), 50개 구간 개수 배열
  • 날짜, 인원 수 선택적으로 요청
  • 필터 조건 없을 때는 default 값으로 필터(전체 날짜 선택, 인원 1명)
{
    "status_code": 200,
    "data": {
        "average": 132976.97,
        "sale_prices": [
            40910,
            40910,
            41840,
            46140,
            46760,
            47190,
            47990,
            49840,
            50200,
...
            626510,
            729070,
            1753460
        ],
        "count_list": [
            0,
            0,
            25,
            47,
            41,
            31,
            14,
...
            0,
            1
        ]
    }
}
  • average: 평균가
  • sale_price: 해당 가격 전체 리스트 오름차순
  • count_list: 50개 구간 별 가격에 해당하는 숙소의 개수

5. 즐겨찾기 등록

POST {url}/bookmarks/{roomId}

성공 시 Response

{
    "status_code": 200,
}

6. 즐겨찾기 해제

DELETE {url}/bookmarks/{roomId}

성공 시 Response

{
    "status_code": 200,
}

4. 방 상세 정보 페이지

GET {url}/cities/{cityId}/rooms/{roomId}

{
    "status_code": 200,
    "data":
        {
            "room_id": 1,
            "room_name": "French Chic Loft",
            "address": "Asheville, NC, United States",
            "room_thumbnail": "https://a0.muscache.com/im/pictures/29807425/62a6b073_original.jpg?aki_policy=large",
            "image_lists": [
            "https://a0.muscache.com/im/pictures/29807425/62a6b073_original.jpg?aki_policy=large",
            "https://a0.muscache.com/im/pictures/29807425/62a6b073_original.jpg?aki_policy=large",
            "https://a0.muscache.com/im/pictures/29807425/62a6b073_original.jpg?aki_policy=large",
            "https://a0.muscache.com/im/pictures/29807425/62a6b073_original.jpg?aki_policy=large"
            ]
            "is_super_host": true,
            "host_name": "Evelyne"
            "host_thumbnail": "https://a0.muscache.com/im/users/165529/profile_pic/1313449545/original.jpg?aki_policy=profile_small"
            "room_type": "Private room",
            "beds": 2,
            "original_price": 61530,
            "sale_price": 55370,
            "scores": 4.33,
            "reviews": 138,
            "amenities": "Internet,Wifi,"Air conditioning",Kitchen,"Free parking on premises",Breakfast,"Pets live on this property",Cat(s),"Indoor fireplace",Heating,Washer,Dryer,"Smoke detector","Carbon monoxide detector","First aid kit","Fire extinguisher",Essentials,Shampoo,Hangers,"Hair dryer",Iron,"translation missing: en.hosting_amenity_49","translation missing: en.hosting_amenity_50","Hot water","Bed linens","Extra pillows and blankets","Patio or balcony","Garden or backyard","Host greets you"",
            "cleaning_fee": 18460,
            "maximum_guests": 5,
            "favorite": false
        }
}
        

8. 예약하기

POST {url}/reservation

  • Request Body에 날짜(체크인, 체크아웃), 인원 수 정보를 필수로 요청을 보냄

Request Body

{
	"checkIn": "2020-05-06",
	"checkOut": "2020-05-11",
	"guests": 3
}

Response

{
    "status_code": 200,
}

10. 예약 취소하기

DELETE {url}/reservation/{reservationId}

Response

{
    "status_code": 200,
}

11. 예약 조회하기

GET {url}/reservation

{
    "status_code": 200,
    "data":
        {
            "room_id": 1,
            "room_name": "French Chic Loft",
            "room_type": "Private room",
            "original_price": 61530,
            "sale_price": 55370,
            "scores": 4.33,
            "reviews": 138,
            "check_in": "2020-03-29",
            "check_out": "2020-03-31",
            "guests": 1,
            "nights": 2,
            "cleaning_fee": 18460,
            "tax": 3080,
            "total_fee": 132280
        }
}