# How to Give Your AI Agent Access to Booking.com Data

*Disclaimer: This guide covers accessing publicly available data. Always review a site's robots.txt and Terms of Service before automated access.*

## TL;DR
To give an AI agent access to Booking.com data, use a structured extraction API to convert raw HTML into JSON. This removes the need for the agent to parse complex DOM structures, allowing the LLM to receive clean, schema-validated data directly into its context window via a tool call or API request.

## Why AI agents need Booking.com data
Modern AI agents are moving from static knowledge bases to live, agentic search. For travel-focused agents, Booking.com provides the ground truth for hospitality data. Integrating this data enables three primary agentic workflows:

1. **Pricing Intelligence**: Agents can monitor competitor pricing in real-time, triggering alerts or adjusting internal pricing models when specific thresholds are met.
2. **Availability Monitoring**: RAG pipelines can be updated automatically when room availability changes, ensuring the LLM doesn't hallucinate "available" status for fully booked properties.
3. **Hospitality Data Pipelines**: Agents can aggregate property descriptions, amenities, and user ratings to build comprehensive knowledge bases for travel recommendation engines.

## Why raw HTTP requests fail for agents
If you attempt to use a standard `requests` or `axios` call to fetch Booking.com data, your agent will likely fail. The reasons are technical and systemic:

* **JavaScript Rendering**: Booking.com relies heavily on client-side rendering. A raw GET request returns a skeleton HTML page without the actual pricing or availability data.
* **Bot Detection**: Advanced anti-bot systems detect headless browsers and non-human traffic patterns, resulting in 403 Forbidden errors or CAPTCHAs.
* **Token Budget Waste**: Sending raw, messy HTML to an LLM wastes thousands of tokens on boilerplate code, noise, and CSS. This increases latency and cost while decreasing the accuracy of the extraction.
* **Rate Limiting**: Without rotating residential proxies, an agent making frequent requests will be IP-banned quickly, breaking the pipeline.

<div data-infographic="stats">
  <div data-stat data-value="99.2%" data-label="Request Success Rate"></div>
  <div data-stat data-value="<1s" data-label="Avg Structured Response"></div>
  <div data-stat data-value="0" data-label="HTML Parsing Required"></div>
</div>

## Connecting your agent to Booking.com via AlterLab
The most efficient way to connect an agent is through structured extraction. Instead of asking an LLM to "find the price in this HTML," you define a schema and receive a JSON object.

Follow the [Getting started guide](/docs/quickstart/installation) to set up your environment.

### Using the Extract API
The [Extract API docs](/docs/extract) explain how to use templates for consistent data retrieval. By defining a schema, you ensure the agent receives only the data it needs.

```python title="agent_booking_com.py" {6-10}
import alterlab

client = alterlab.Client("YOUR_API_KEY")

# Define the schema for the agent's tool call
schema = {
    "hotel_name": "string",
    "price_per_night": "string",
    "rating": "number",
    "availability": "boolean"
}

# Extract structured data directly
result = client.extract(
    url="https://www.booking.com/hotel/id/example-hotel.html",
    schema=schema
)

print(result.data) # Returns: {"hotel_name": "Grand Plaza", "price_per_night": "$200", ...}
```

For developers preferring a direct REST approach, use cURL to integrate into your pipeline:

```bash title="Terminal"
curl -X POST https://api.alterlab.io/api/v1/extract/templates/{template_id} \
  -H "X-API-Key: YOUR_KEY" \
  -d '{"url": "https://www.booking.com/hotel/id/example-hotel.html", "schema": {"hotel_name": "string", "price": "string"}}'
```

## Using the Search API for Booking.com queries
For agents that need to find properties based on a user's query (e.g., "Find me a 4-star hotel in Tokyo under $300"), the Search API is the optimal tool. This allows the agent to trigger a search and receive a list of results without navigating the UI.

You can schedule these searches to keep your knowledge base fresh using the `/api/v1/search/schedules/{schedule_id}/run` endpoint. This transforms a manual search into a programmatic data stream.

<div data-infographic="try-it" data-url="https://booking.com" data-description="Extract structured Booking.com data for your AI agent"></div>

## MCP integration
For those using Claude, GPT-4, or Cursor, the Model Context Protocol (MCP) is the gold standard for tool use. By using the [AlterLab for AI Agents](https://alterlab.io/for-ai-agents) MCP server, you can give your agent a "web search" tool that handles all the proxy and rendering logic automatically.

The agent simply calls the tool, and the MCP server returns the structured JSON. The LLM never sees the HTML, only the data.

## Building a pricing intelligence pipeline
Here is a practical end-to-end flow for a pricing agent. The goal is to monitor a specific property and notify a system if the price drops.

**The Pipeline Flow:**
1. **Trigger**: A cron job or agentic loop triggers a request.
2. **Fetch**: AlterLab fetches the page using a headless browser (T3+ tier) to ensure JS is rendered.
3. **Extract**: The Extract API filters the HTML into a JSON object.
4. **Analyze**: The LLM compares the new price against the stored price in the database.
5. **Action**: If the price is lower, the agent sends a notification.

<div data-infographic="steps">
  <div data-step data-number="1" data-title="Agent requests data" data-description="LLM agent calls AlterLab tool with target URL"></div>
  <div data-step data-number="2" data-title="AlterLab fetches + extracts" data-description="Handles anti-bot, returns structured JSON"></div>
  <div data-step data-number="3" data-title="Agent uses clean data" data-description="No parsing, no retries — data goes straight to LLM context"></div>
</div>

```python title="pricing_pipeline.py" {12-18}
import alterlab
import json

client = alterlab.Client("YOUR_API_KEY")
TARGET_URL = "https://www.booking.com/hotel/id/example-hotel.html"
PRICE_THRESHOLD = 150.00

def check_price():
    # Extract only the price field to save tokens
    data = client.extract(url=TARGET_URL, schema={"price": "string"})
    
    # Clean the price string (e.g., "$140" -> 140.0)
    current_price = float(data['price'].replace('$', '').replace(',', ''))
    
    if current_price < PRICE_THRESHOLD:
        return f"Price drop detected: {current_price}. Triggering alert."
    return "Price stable."

print(check_price())
```

## Key takeaways
* **Avoid raw HTML**: Never pass raw HTML to an LLM; use structured extraction to save tokens and increase accuracy.
* **Handle JS rendering**: Use high-tier rendering to ensure you are seeing the actual prices and availability.
* **Use MCP for Agents**: Integrate via MCP to allow LLMs to natively use web extraction as a tool.
* **Scale with API**: Use scheduled searches to maintain a real-time RAG pipeline for travel data.

For scaling your agentic workloads, review the [AlterLab pricing](/pricing) to choose the appropriate balance of request volume and browser rendering needs.