# Trip.com Scraper (`one-api/trip-com-scraper`) Actor

Scrape Trip.com hotels, train routes, and attractions worldwide. Hotels: autocomplete a city, search by location / coordinates / Trip.com URL, get full hotel details by ID or URL. Trains: search routes between cities + per-train details. Attractions: search things-to-do by city + per-POI details.

- **URL**: https://apify.com/one-api/trip-com-scraper.md
- **Developed by:** [ONE API](https://apify.com/one-api) (community)
- **Categories:** Travel, Lead generation
- **Stats:** 33 total users, 6 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Trip.com Scraper

Scrape **Trip.com** hotels, train routes, and attractions worldwide via the realtyapi.io Trip.com API.

### What it does

- **🏨 Hotel Details** — auto-detects each input as `hotelId` (digits) or `trip.com` URL; returns the full record (rooms, amenities, policies, location, reviews summary, full image list, nearby POIs).
- **🔎 Hotel Search** — 3 modes: by location name, by `lat,lng[,radius_km]` coordinates, or by Trip.com listing URL. All filters (dates / guests / price / star / sort) apply.
- **🔤 Destination Autocomplete** — resolve free-text city/destination → `cityId` + Trip.com city URL.
- **🚄 Trains** — route search (`Origin → Destination [date]`) returns one row per departure; per-train detail row by `trainNo`.
- **🎢 Attractions** — things-to-do search by city keyword + per-POI detail by `poiId`.

### Output

- **One flat dataset row per result** — hotel / train / POI / autocomplete row.
- Columns: `Mode`, `Input Given`, `ID`, `Name`, `City`, `Country`, `Address`, `Price`, `Currency`, `StarRating`, `Rating`, `ReviewCount`, `Latitude`, `Longitude`, `Extra`, `Cover Photo`, `Listing URL`.
- Full upstream JSON kept in the `Raw` column for power users (rooms, amenities, segments, photos, etc.).

### Inputs

- Each section is independent — fill only the ones you need.
- Multiple inputs per section: one per line.
- The 🗓 Hotel Filters block (check-in/out, adults, children, rooms, sort, price, star, resultCount, page) applies to every hotel search and detail call.

### Pricing

- Pay per result: **$3 per 1,000 dataset items** — same rate on every Apify plan tier.
- Apify start fee: $0.00005 per run.

### Notes

- Trip.com SSR caps each hotel search page at ~12 hotels; this actor stitches multiple SSR + SEO sources per city to deliver up to 100 unique hotels per query.
- Date format is `YYYY-MM-DD`; leave check-in / check-out blank to default to ~30 days out.
- Train routes work best on European (Eurostar, France, Spain) and Chinese networks — those are the corridors with full SEO route pages on Trip.com.
- Attraction detail by arbitrary `poiId` works for POIs in Trip.com's SEO feeds (~350 well-known attractions across the top ~25 cities); deep-tail POIs may return a 404.

### Errors

- Failures land in the dataset as rows with `Mode = "ERROR"` and the upstream error message in `Name` — nothing is silently dropped.

# Actor input Schema

## `property_inputs` (type: `array`):

Auto-detects each entry and calls the right endpoint:
• Digits only (e.g. `2985758`) → `/details/byid`
• `https://www.trip.com/hotels/...` → `/details/byurl`
• Anything else → treated as a hotel name / address (resolved via search).

Each row in the dataset = one full hotel record (rooms, amenities, policies, reviews, location, full image list — JSON in `Raw`).

## `search_inputs` (type: `array`):

Auto-detects each entry and routes to the right `/search/*` endpoint:
• `https://www.trip.com/hotels/...` → `/search/byurl`
• `lat,lng` or `lat,lng,radius_km` (e.g. `13.7563,100.5018,5`) → `/search/bycoordinates`
• Anything else (city / location name, e.g. `Bangkok`) → `/search/bylocation`

Filters below (check-in/out, guests, price, star, sort) apply to every search call. Each hit returns one dataset row per hotel.

## `autocomplete_inputs` (type: `array`):

Free-text city/destination lookup. Each query returns up to `Autocomplete results per query` rows with `cityId`, `slug`, and the Trip.com city URL — handy when you want the cityId before running a hotel search.

## `autocomplete_result_count` (type: `integer`):

How many city suggestions to keep per autocomplete query.

## `train_inputs` (type: `array`):

Search train routes between two cities/stations. Format examples:
• `Paris → London`
• `London > Amsterdam`
• `Beijing -> Shanghai 2026-08-15`
• `Paris,Lyon` (comma-separated also works)

Each result row = one departure (depart/arrival time, duration, fare, carrier).

## `train_detail_inputs` (type: `array`):

Look up a specific train by its trainNo on a known route. Format:
• `Paris → London | 9024`
• `Beijing → Shanghai | G1`

Returns the enriched detail row for that single train.

## `attraction_inputs` (type: `array`):

Free-text city / region keyword (e.g. `London`, `Tokyo`). Leave a row blank to fetch the global SEO feed.

Each hit returns one dataset row per POI (name, rating, price, image, ranking).

## `attraction_result_count` (type: `integer`):

How many POIs per attraction-search query (Trip.com SSR caps at ~12 per page).

## `attraction_detail_inputs` (type: `array`):

Look up a Trip.com attraction by `poiId` (e.g. `78693` = Westminster Abbey, `78696` = British Museum, `81747` = London Eye). One row per poiId.

## `checkIn` (type: `string`):

YYYY-MM-DD. Defaults to ~30 days out when blank.

## `checkOut` (type: `string`):

YYYY-MM-DD. Defaults to ~2 days after check-in when blank.

## `adults` (type: `integer`):

Adults per room.

## `children` (type: `integer`):

Children per room.

## `rooms` (type: `integer`):

Number of rooms.

## `sortOrder` (type: `string`):

Trip.com hotel sort order.

## `priceRange` (type: `string`):

Format: `min:80,max:300` — or just `min:80` / `max:300`. Leave blank for no price filter.

## `starRating` (type: `string`):

Pipe-separated star ratings, e.g. `4|5` (4★ + 5★). Leave blank for all.

## `resultCount` (type: `integer`):

How many hotels per `/search/*` query (capped at 100 by Trip.com).

## `page` (type: `integer`):

1-based page index for hotel search (each page = `Hotel results per query` rows).

## `train_result_count` (type: `integer`):

How many train departures per route query.

## Actor input object example

```json
{
  "property_inputs": [
    "2985758",
    "https://www.trip.com/hotels/detail?cityid=338&hotelid=2132268"
  ],
  "search_inputs": [
    "Bangkok",
    "London"
  ],
  "autocomplete_inputs": [],
  "autocomplete_result_count": 10,
  "train_inputs": [
    "Paris → London 2026-08-15"
  ],
  "train_detail_inputs": [],
  "attraction_inputs": [
    "London"
  ],
  "attraction_result_count": 12,
  "attraction_detail_inputs": [],
  "checkIn": "2026-08-10",
  "checkOut": "2026-08-12",
  "adults": 2,
  "children": 0,
  "rooms": 1,
  "sortOrder": "0",
  "priceRange": "",
  "starRating": "",
  "resultCount": 30,
  "page": 1,
  "train_result_count": 30
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "property_inputs": [
        "2985758",
        "https://www.trip.com/hotels/detail?cityid=338&hotelid=2132268"
    ],
    "search_inputs": [
        "Bangkok",
        "London"
    ],
    "autocomplete_inputs": [],
    "train_inputs": [
        "Paris → London 2026-08-15"
    ],
    "train_detail_inputs": [],
    "attraction_inputs": [
        "London"
    ],
    "attraction_detail_inputs": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("one-api/trip-com-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "property_inputs": [
        "2985758",
        "https://www.trip.com/hotels/detail?cityid=338&hotelid=2132268",
    ],
    "search_inputs": [
        "Bangkok",
        "London",
    ],
    "autocomplete_inputs": [],
    "train_inputs": ["Paris → London 2026-08-15"],
    "train_detail_inputs": [],
    "attraction_inputs": ["London"],
    "attraction_detail_inputs": [],
}

# Run the Actor and wait for it to finish
run = client.actor("one-api/trip-com-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "property_inputs": [
    "2985758",
    "https://www.trip.com/hotels/detail?cityid=338&hotelid=2132268"
  ],
  "search_inputs": [
    "Bangkok",
    "London"
  ],
  "autocomplete_inputs": [],
  "train_inputs": [
    "Paris → London 2026-08-15"
  ],
  "train_detail_inputs": [],
  "attraction_inputs": [
    "London"
  ],
  "attraction_detail_inputs": []
}' |
apify call one-api/trip-com-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,one-api/trip-com-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/O199kkGqcTHQXUaNu/builds/EbI8qR2SiBZcqb4q8/openapi.json
