Search⌘ K
AI Features

API Model for Booking and Availability Services

Explore how to model an Airbnb-like booking API, from versioned endpoints and core entities to search, availability, profiles, and reservations. Learn how caching, pagination, idempotency, atomic booking flows, concurrency controls, and consistent error responses create a reliable client-service contract.

Coordinating real-time availability and bookings across millions of listings is challenging due to concurrency issues like race conditions and double bookings. This lesson defines the API model for an Airbnb-like platform, covering core endpoints, data structures, and error handling for search, availability, and booking, with a focus on establishing a clear and reliable client-service contract.

Base URL and API endpoints

The booking platform API is served from a versioned base URL that acts as the root for all resource paths.

The base URL for a booking platform APIs
The base URL for a booking platform APIs

Embedding the version number directly in the URL path (/v1) ensures that breaking changes in future iterations (/v2) do not disrupt existing clients. In a rapidly evolving booking platform where new features ship frequently, this strategy provides backward compatibility without forcing all consumers to upgrade simultaneously.

We can use the following endpoints and methods to access different services of booking platform’s API.

Endpoints for multiple operations in booking platform API

Note: Since most of the above endpoints perform similar operations, we discuss details of selected endpoints based on their significance to avoid redundant request-response messages. The rest of the services are summarized in the table at the end of this lesson.

Data entities

Let's start by highlighting the core data entities that will be of use to us in the booking platform API.

YAML
type BookingPlatform
{
userID: string // User ID of the person who is a guest or a host
name: string // Full name of the user
email: string // Email address of the user
role: string // Role of the user: "guest" or "host"
verified: boolean // Whether the user's identity has been verified
listingID: string // Unique identifier for a bookable property
title: string // Display name of the listing
description: string // Full description of the property
hostID: string // User ID of the host who owns the listing
location: object // Latitude, longitude, and city of the property
pricePerNight: float // Base nightly price of the listing
propertyType: string // Type of property: "apartment", "house", "villa", etc.
amenities: list // List of amenities the property offers
images: list // List of image URLs for the listing
rating: float // Aggregate guest rating for the listing
availabilityDate: string // A specific calendar date (ISO 8601: YYYY-MM-DD)
isAvailable: boolean // Whether the listing is bookable on that date
priceOverride: float // Optional dynamic price that overrides pricePerNight
bookingID: string // Unique identifier for a reservation
checkIn: string // Check-in date of the booking (ISO 8601)
checkOut: string // Check-out date of the booking (ISO 8601)
totalPrice: float // Total cost for the entire stay
status: string // Booking status: "pending", "confirmed", "cancelled", or "completed"
guests: int // Number of guests for the reservation
page: int // Page number for paginated results
limit: int // Number of results per page
nextCursor: string // Cursor token used for cursor-based pagination
totalCount: int // Total number of results matching the query
}

Let’s begin with request and response of the APIs associated to the following services: ...