airbnb_listing_details
Retrieve comprehensive details about a specific Airbnb listing, including availability, pricing, and direct links, by providing listing ID and optional stay parameters.
Instructions
Get detailed information about a specific Airbnb listing. Provide direct links to the user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| adults | No | Number of adults | |
| checkin | No | Check-in date (YYYY-MM-DD) | |
| checkout | No | Check-out date (YYYY-MM-DD) | |
| children | No | Number of children | |
| id | Yes | The Airbnb listing ID | |
| ignoreRobotsText | No | Ignore robots.txt rules for this request | |
| infants | No | Number of infants | |
| pets | No | Number of pets |
Implementation Reference
- index.ts:335-468 (handler)The handler function that executes the tool logic: constructs the listing URL, checks robots.txt, fetches the page, parses JSON data from script tag, filters and extracts relevant sections (location, policies, highlights, description, amenities), and returns structured details.async function handleAirbnbListingDetails(params: any) { const { id, checkin, checkout, adults = 1, children = 0, infants = 0, pets = 0, ignoreRobotsText = false, } = params; // Build listing URL const listingUrl = new URL(`${BASE_URL}/rooms/${id}`); // Add query parameters if (checkin) listingUrl.searchParams.append("check_in", checkin); if (checkout) listingUrl.searchParams.append("check_out", checkout); // Add guests const adults_int = parseInt(adults.toString()); const children_int = parseInt(children.toString()); const infants_int = parseInt(infants.toString()); const pets_int = parseInt(pets.toString()); const totalGuests = adults_int + children_int; if (totalGuests > 0) { listingUrl.searchParams.append("adults", adults_int.toString()); listingUrl.searchParams.append("children", children_int.toString()); listingUrl.searchParams.append("infants", infants_int.toString()); listingUrl.searchParams.append("pets", pets_int.toString()); } // Check if path is allowed by robots.txt const path = listingUrl.pathname + listingUrl.search; if (!ignoreRobotsText && !isPathAllowed(path)) { return { content: [{ type: "text", text: JSON.stringify({ error: robotsErrorMessage, url: listingUrl.toString() }, null, 2) }], isError: true }; } const allowSectionSchema: Record<string, any> = { "LOCATION_DEFAULT": { lat: true, lng: true, subtitle: true, title: true }, "POLICIES_DEFAULT": { title: true, houseRulesSections: { title: true, items : { title: true } } }, "HIGHLIGHTS_DEFAULT": { highlights: { title: true } }, "DESCRIPTION_DEFAULT": { htmlDescription: { htmlText: true } }, "AMENITIES_DEFAULT": { title: true, seeAllAmenitiesGroups: { title: true, amenities: { title: true } } }, //"AVAILABLITY_CALENDAR_DEFAULT": true, }; try { const response = await fetchWithUserAgent(listingUrl.toString()); const html = await response.text(); const $ = cheerio.load(html); let details = {}; try { const scriptElement = $("#data-deferred-state-0").first(); const clientData = JSON.parse($(scriptElement).text()).niobeMinimalClientData[0][1]; const sections = clientData.data.presentation.stayProductDetailPage.sections.sections; sections.forEach((section: any) => cleanObject(section)); details = sections .filter((section: any) => allowSectionSchema.hasOwnProperty(section.sectionId)) .map((section: any) => { return { id: section.sectionId, ...flattenArraysInObject(pickBySchema(section.section, allowSectionSchema[section.sectionId])) } }); } catch (e) { console.error(e); } return { content: [{ type: "text", text: JSON.stringify({ listingUrl: listingUrl.toString(), url: listingUrl.toString(), details: details }, null, 2) }], isError: false }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), listingUrl: listingUrl.toString() }, null, 2) }], isError: true }; } }
- index.ts:77-118 (schema)Defines the Tool metadata including name, description, and input schema with required 'id' and optional parameters for dates and guests.const AIRBNB_LISTING_DETAILS_TOOL: Tool = { name: "airbnb_listing_details", description: "Get detailed information about a specific Airbnb listing. Provide direct links to the user", inputSchema: { type: "object", properties: { id: { type: "string", description: "The Airbnb listing ID" }, checkin: { type: "string", description: "Check-in date (YYYY-MM-DD)" }, checkout: { type: "string", description: "Check-out date (YYYY-MM-DD)" }, adults: { type: "number", description: "Number of adults" }, children: { type: "number", description: "Number of children" }, infants: { type: "number", description: "Number of infants" }, pets: { type: "number", description: "Number of pets" }, ignoreRobotsText: { type: "boolean", description: "Ignore robots.txt rules for this request" } }, required: ["id"] } };
- index.ts:120-123 (registration)Adds the airbnb_listing_details tool to the array of available tools, which is returned by the ListTools request handler.const AIRBNB_TOOLS = [ AIRBNB_SEARCH_TOOL, AIRBNB_LISTING_DETAILS_TOOL, ] as const;
- index.ts:504-506 (registration)In the CallTool request handler, dispatches calls to 'airbnb_listing_details' to the handleAirbnbListingDetails function.case "airbnb_listing_details": { return await handleAirbnbListingDetails(request.params.arguments); }