Hotel API

This document outlines the API operations for retrieving hotel data. The information with images may not unmatched. Below are the typical operations you can perform.

Base URL: https://fdelux.globeapp.dev/api

Endpoint Summary

Method Path Description
GET: /api/hotels Fetch All Hotels
GET: /api/hotels/popular Fetch Popular Hotels
POST: /api/hotels/nearby Fetch Nearby Hotels
GET: /api/hotels/bed-types Fetch Bed Types
POST: /api/hotels/filter Filter Hotels
GET: /api/hotels/{id} Find Hotel by ID
GET: /api/hotels/{id}/rooms Fetch Rooms by Hotel ID
GET: /api/hotels/{id}/reviews Fetch Reviews by Hotel ID

Fetch All Hotels

  • Method: GET
  • Endpoint: /hotels

Example Request URL: https://fdelux.globeapp.dev/api/hotels

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}

Responses

200 OK
{
  "message": "All hotels fetched successfully",
  "data": {
    "hotels": [
      {
        "id": 1002,
        "name": "Seaside Boutique Hotel",
        "rating": 4.7,
        "lowest_price": 76.8,
        "highest_price": 115.2,
        "location": {
          "street_address": "78 Oceanfront Drive",
          "city": "Bali",
          "state_province": "Bali",
          "postal_code": "80361",
          "country": "Indonesia",
          "latitude": -8.4095,
          "longitude": 115.1889
        },
        "cover": "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-261388.jpg"
      }
    ]
  }
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while fetching all hotels.",
  "details": "Error message details here."
}

Fetch Nearby Hotels

  • Method: POST
  • Endpoint: /hotels/nearby

Example Request URL: https://fdelux.globeapp.dev/api/hotels/nearby

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}
body
{
  "latitude": 51.5074,
  "longitude": -0.1278,
  "radius": 500.0 // in kilometers
}

Responses

200 OK
{
  "message": "Found 1 nearby hotels",
  "data": {
    "hotel_count": 1,
    "hotels": [
      {
        "id": 1002,
        "name": "Seaside Boutique Hotel",
        "rating": 4.7,
        "lowest_price": 76.8,
        "highest_price": 115.2,
        "location": {
          "street_address": "78 Oceanfront Drive",
          "city": "Bali",
          "state_province": "Bali",
          "postal_code": "80361",
          "country": "Indonesia",
          "latitude": -8.4095,
          "longitude": 115.1889
        },
        "cover": "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-261388.jpg"
      }
    ]
  }
}
400 Bad Request
{
  "message": "Invalid parameters for nearby search.",
  "details": "Please provide valid 'latitude', 'longitude' (numeric), and 'radius' (positive numeric) in the request body."
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
404 Not Found
{
  "message": "No nearby hotels found",
  "details": "Try adjusting your coordinates or increasing the search radius."
}
405 Method Not Allowed
{
  "message": "Method Not Allowed",
  "details": "Only POST requests are supported for this endpoint when using a request body."
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while fetching nearby hotels.",
  "details": "Error message details here."
}

Fetch Bed Types

  • Method: GET
  • Endpoint: /hotels/bed-types

Example Request URL: https://fdelux.globeapp.dev/api/hotels/bed-types

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}

Responses

200 OK
{
  "message": "Bed types fetched successfully",
  "data": {
    "bed_types": [
      "All",
      "King",
      "Queen",
      "Twin",
      "Double"
    ]
  }
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while fetching bed types.",
  "details": "Error message details here."
}

Filter Hotels

  • Method: POST
  • Endpoint: /hotels/filter

Example Request URL: https://fdelux.globeapp.dev/api/hotels/filter

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}
body
{
  "capacity": 2,
  "max_price": 500, // USD
  "bed_type": "King"
}

Responses

200 OK
{
  "message": "Hotels filtered successfully",
  "data": {
    "hotel_count": 1,
    "hotels": [
      {
        "id": 1001,
        "name": "Grand Imperial Hotel",
        "rating": 4.7,
        "lowest_price": 317.50,
        "highest_price": 476.25,
        "location": {
          "street_address": "123 Royal Avenue",
          "city": "London",
          "state_province": "England",
          "postal_code": "SW1A 0AA",
          "country": "United Kingdom",
          "latitude": 51.5074,
          "longitude": -0.1278
        },
        "cover": "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-258154.jpg"
      }
    ]
  }
}
400 Bad Request
{
  "message": "Missing required parameters.",
  "details": "Please provide all of \"capacity\" (int), \"minPrice\" (double), and \"bedType\" (string) in the request body."
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
404 Not Found
{
  "message": "No hotels found matching the criteria",
  "details": "Try adjusting your filter parameters."
}
405 Method Not Allowed
{
  "message": "Method Not Allowed",
  "details": "Only POST requests are supported for this endpoint when using a request body."
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while filtering hotels.",
  "details": "Error message details here."
}

Find Hotel by ID

  • Method: GET
  • Endpoint: /hotels/{id}

Example Request URL: https://fdelux.globeapp.dev/api/hotels/1001

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}

Responses

200 OK
{
  "message": "Hotel fetched successfully",
  "data": {
    "hotel": {
      "id": 1002,
      "name": "Seaside Boutique Hotel",
      "description": "A charming boutique hotel with stunning ocean views, perfect for a relaxing getaway.",
      "rating": 4.7,
      "lowest_price": 76.8,
      "highest_price": 115.2,
      "location": {
        "street_address": "78 Oceanfront Drive",
        "city": "Bali",
        "state_province": "Bali",
        "postal_code": "80361",
        "country": "Indonesia",
        "latitude": -8.4095,
        "longitude": 115.1889
      },
      "contact": {
        "phone": "+62 361 123456",
        "email": "[email protected]",
        "website": "https://www.seasidebali.com"
      },
      "cover": "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-261388.jpg",
      "images": [
        "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-261388.jpg",
        "https://fdelux.globeapp.dev/images/hotels/pexels-thelazyartist-1488515.jpg",
        "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-261181.jpg",
        "https://fdelux.globeapp.dev/images/hotels/pexels-thorsten-technoman-109353-338504.jpg"
      ],
      "image_sources": [
        "https://www.pexels.com/"
      ],
      "amenities": [
        "Free Wi-Fi",
        "Outdoor Pool",
        "Beach Access",
        "Restaurant",
        "Spa Services",
        "Airport Shuttle"
      ],
      "policies": {
        "check_in_time": "14:00",
        "check_out_time": "12:00",
        "cancellation_policy": "Cancellation fee applies within 7 days of check-in.",
        "pet_friendly": true
      }
    }
  }
}
400 Bad Request
{
  "message": "Invalid ID parameter",
  "details": "ID must be a valid integer."
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
404 Not Found
{
  "message": "Hotel not found",
  "details": "No hotel found with the provided ID: 1001"
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while finding the hotel.",
  "details": "Error message details here."
}

Fetch Rooms by Hotel ID

  • Method: GET
  • Endpoint: /hotels/{id}/rooms

Example Request URL: https://fdelux.globeapp.dev/api/hotels/1001/rooms

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}

Responses

200 OK
{
  "message": "Rooms fetched successfully",
  "data": {
    "rooms": [
      {
        "id": 1,
        "name": "Standard King Room",
        "description": "Comfortable room with a king-sized bed and city views.",
        "capacity": 2,
        "bed_type": "King",
        "price_per_night": 317.50,
        "image": "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-271624.jpg",
        "hotel_id": 1001
      },
      {
        "id": 2,
        "name": "Deluxe Double Room",
        "description": "Spacious room with a double bed and modern amenities.",
        "capacity": 2,
        "bed_type": "Double",
        "price_per_night": 381.00,
        "image": "https://fdelux.globeapp.dev/images/hotels/pexels-pixabay-164595.jpg",
        "hotel_id": 1001
      }
    ]
  }
}
400 Bad Request
{
  "message": "Invalid hotel ID parameter",
  "details": "Hotel ID must be a valid integer."
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
404 Not Found
{
  "message": "No rooms found for this hotel",
  "details": "No room data available for hotel ID: 1001"
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while fetching rooms.",
  "details": "Error message details here."
}

Fetch Reviews by Hotel ID

  • Method: GET
  • Endpoint: /hotels/{id}/reviews

Example Request URL: https://fdelux.globeapp.dev/api/hotels/1001/reviews

Request

headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer your-access-token"
}

Responses

200 OK
{
  "message": "Reviews fetched successfully",
  "data": {
    "reviews": [
      {
        "id": 1,
        "user_id": 11,
        "user_name": "Sarah Chen",
        "rating": 4.8,
        "comment": "An absolutely magnificent hotel! The service was truly five-star and the rooms were incredibly luxurious.",
        "created_at": "2025-06-28T10:15:30",
        "hotel_id": 1001
      },
      {
        "id": 2,
        "user_id": 12,
        "user_name": "Michael Davis",
        "rating": 4.5,
        "comment": "Excellent location in London, making it easy to explore. The dining options were superb.",
        "created_at": "2025-06-29T14:30:00",
        "hotel_id": 1001
      }
    ]
  }
}
400 Bad Request
{
  "message": "Invalid hotel ID parameter",
  "details": "Hotel ID must be a valid integer."
}
401 Unauthenticated
{
  "message": "Authentication required. Please provide a Bearer token.",
  "details": "Include a valid Bearer token in the Authorization header."
}
404 Not Found
{
  "message": "No reviews found for this hotel",
  "details": "No review data available for hotel ID: 1001"
}
500 Internal Server Error
{
  "message": "An unexpected error occurred while fetching reviews.",
  "details": "Error message details here."
}