Skip to main content
This page documents the TypeScript types you can use when integrating the OpenBookings API in a TypeScript project. Copy them directly into your codebase or import them from a shared types package. ResolvedRoom is the authoritative shape of every object in the array returned by GET /api/query.

HotelSearchInput

The parameter object that maps to the query string of GET /api/query. Use this type to build and validate your search request before sending it to the API.
/** Input parameters for the hotel/room search query */
export interface HotelSearchInput {
  lat: number;
  lon: number;
  checkin: string;   // YYYY-MM-DD
  checkout: string;  // YYYY-MM-DD
  adults: number;
  children: number | null;
  rooms: number;
}
FieldTypeRequiredNotes
latnumberYesLatitude of the search center
lonnumberYesLongitude of the search center
checkinstringYesCheck-in date, YYYY-MM-DD
checkoutstringYesCheck-out date, YYYY-MM-DD
adultsnumberYesNumber of adult guests
childrennumber | nullNoNumber of child guests; null treated as 0
roomsnumberYesNumber of rooms

HotelSearchResult

A simplified type that represents a basic room result. The live API returns ResolvedRoom objects, not HotelSearchResult objects. This type is retained for reference but you should use ResolvedRoom when typing API responses.
/** Simplified room result — use ResolvedRoom for live API responses */
export interface HotelSearchResult {
  property_id: string;
  property_name: string;
  city: string;
  country: string;
  room_id: string;
  room_name: string;
  room_description: string;
  price_per_night: number;
  total_price: number;
  currency: string;
}
HotelSearchResult is a simplified type. The live GET /api/query endpoint returns ResolvedRoom objects, which include pricing detail, modifier fields, rate plan data, and occupancy constraints not present here.

ResolvedRoom

The actual response type returned by GET /api/query. Every element of the response array conforms to this interface.
export interface ResolvedRoom {
  // Hotel
  hotel_id: string;
  hotel_name: string;
  hotel_slug: string;
  city: string;
  country: string;

  // Room
  room_id: string;
  room_name: string;
  room_description: string;
  base_occupancy: number;
  max_adults: number;
  max_children: number;

  // Rate plan
  rate_plan_id: string;
  rate_plan_name: string;
  currency: string;
  is_refundable: boolean;
  cancellation_policy: string;
  min_stay: number;
  max_stay: number | null;

  // Pricing (calculated)
  subtotal: number;           // sum of nightly base prices
  total_price: number;        // after all modifiers applied
  applied_modifiers: ModifierType[];
}

ModifierType

A union of the rate modifier categories the pricing engine supports. These strings appear in ResolvedRoom.applied_modifiers.
type ModifierType =
  | 'day_of_week'
  | 'length_of_stay'
  | 'early_bird'
  | 'last_minute'
  | 'extra_guest'
ValueDescription
day_of_weekSurcharge applied to nights that fall on specific days of the week
length_of_stayDiscount for stays that meet a minimum night threshold
early_birdDiscount for bookings made a set number of days before arrival
last_minuteAdjustment applied when booking close to the arrival date
extra_guestPer-night surcharge for each guest above base_occupancy
Only one discount modifier (length_of_stay or early_bird) can fire per room. The eligible modifier with the lowest configured sort_order takes precedence. Surcharge modifiers can all fire simultaneously.

AdjustmentType

Specifies whether a modifier’s adjustment_value is a fixed currency amount or a percentage of the subtotal.
type AdjustmentType = 'flat' | 'percent'
ValueDescription
flatA fixed currency amount added to or subtracted from the price
percentA percentage of the relevant base or subtotal amount