DEV Community

Cover image for Expedia Data API: Extract Structured JSON in 2026
AlterLab
AlterLab

Posted on • Originally published at alterlab.io

Expedia Data API: Extract Structured JSON in 2026

This guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping.

TL;DR

Use AlterLab's Extract API to get structured Expedia data as JSON. Provide a URL and a JSON schema describing the fields you need (e.g., property_name, price_per_night, rating). The API returns validated typed JSON — no HTML parsing or custom selectors required.

Why use Expedia data?

Travel teams build pricing intelligence models that need nightly rate trends across hotels. AI researchers train language models on structured travel descriptions to improve trip planning suggestions. Analysts monitor availability patterns to forecast demand and adjust inventory strategies.

What data can you extract?

Expedia listing pages expose several public fields that are useful for data pipelines:

  • property_name – the hotel or vacation rental name
  • price_per_night – the displayed rate for a selected date range
  • rating – aggregate guest score (often out of 5)
  • location – city, neighborhood or landmark proximity
  • availability – boolean or text indicating if rooms are open for stay

These fields are visible on the page without login, making them suitable for automated extraction under typical Terms of Service.

The extraction approach

Sending a raw HTTP request and parsing HTML with XPath or CSS selectors is fragile: Expedia frequently updates its markup, adds lazy‑loaded sections, and serves different HTML based on user agent or geography. Maintaining those selectors consumes engineering time and breaks pipelines without warning. A data API that accepts a schema and returns typed JSON removes the parsing layer entirely. AlterLab handles anti‑bot measures, renders JavaScript when needed, and validates the output against your schema so you receive clean data every time.

Quick start with AlterLab Extract API

First, install the Python client and set your API key. See the Getting started guide for installation details.

Python example

```python title="extract_expedia-com.py" {5-12}

client = alterlab.Client("YOUR_API_KEY")

schema = {
"type": "object",
"properties": {
"property_name": {
"type": "string",
"description": "The property name field"
},
"price_per_night": {
"type": "string",
"description": "The price per night field"
},
"rating": {
"type": "string",
"description": "The rating field"
},
"location": {
"type": "string",
"description": "The location field"
},
"availability": {
"type": "string",
"description": "The availability field"
}
}
}

result = client.extract(
url="https://expedia.com/example-hotel-page",
schema=schema,
)
print(result.data)



**Output (example)**


```json
{
  "property_name": "Grand Vista Hotel",
  "price_per_night": "$219",
  "rating": "4.6",
  "location": "Las Vegas Strip, NV",
  "availability": "Available"
}
Enter fullscreen mode Exit fullscreen mode

cURL example

```bash title="Terminal"
curl -X POST https://api.alterlab.io/v1/extract \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://expedia.com/example-hotel-page",
"schema": {"properties": {"property_name": {"type": "string"}, "price_per_night": {"type": "string"}, "rating": {"type": "string"}}}
}'




### Batch/async example (Python)


```python title="batch_expedia.py" {8-15}

client = alterlab.Client("YOUR_API_KEY")

urls = [
    "https://expedia.com/hotel-1",
    "https://expedia.com/hotel-2",
    "https://expedia.com/hotel-3"
]

async def fetch_all():
    tasks = []
    for u in urls:
        task = client.extract_async(
            url=u,
            schema={"type": "object", "properties": {"property_name": {"type": "string"}, "price_per_night": {"type": "string"}}}
        )
        tasks.append(task)
    results = await asyncio.gather(*tasks)
    for r in results:
        print(r.data)

asyncio.run(fetch_all())
Enter fullscreen mode Exit fullscreen mode

These snippets show how to call the extract endpoint, define a schema, and receive typed JSON. For full parameter reference, consult the Extract API docs.

Define your schema

The schema parameter drives the extraction. AlterLab uses the supplied JSON Schema to:

  1. Guide the AI model to locate relevant text on the page.
  2. Validate that each extracted value conforms to the declared type (string, number, boolean, etc.).
  3. Coerce output into plain JSON — leaving you with a ready‑to‑consume payload.

Keep the schema simple: list only the fields you need. Over‑specifying with unnecessary nested objects can reduce accuracy. If a field is sometimes missing, you can still include it; AlterLab will return null for that property when the data isn't present.

Handle pagination and scale

Expedia search results often span multiple pages. To collect data at scale:

  • Batching: Group URLs into chunks of 50‑100 requests and process them in parallel using asyncio or a worker pool.
  • Rate limiting: AlterLab automatically respects per‑second limits; you can also configure a lower rate via the rate_limit parameter if you need to stay under a specific threshold.
  • Job management: For very large jobs, use the asynchronous endpoint (/v1/extract_async) which returns a job ID. Poll the /v1/jobs/{id} endpoint until status is completed, then retrieve the results.

Check the pricing page to estimate cost based on your expected volume — AlterLab charges per successful extraction, so you only pay for the data you actually receive.

Key takeaways

  • Define a clear JSON schema to get typed Expedia data without writing parsers.
  • Use AlterLab's Extract API to bypass anti‑bot measures and JavaScript rendering challenges.
  • Scale with async requests, batching and rate‑limit controls while paying only for what you extract.
  • Always verify that your extraction target is public data and complies with the site's robots.txt and Terms of Service.

AlterLab // Web Data, Simplified.

Top comments (0)