# Cheapest Flights Scraper — Trip.com Split Plane Tickets (`data_fate/cheapest-plane-tickets-scraper`) Actor

Finds cheaper flights by pricing a trip two ways on Trip.com: as one ticket, and as two tickets split at a hub (TPE→HKG→PRG). Returns the cheapest of each with total and per-ticket prices, every leg's flights and times, stopover hours, and self-transfer flags. USD by default; $3 per 1,000 results.

- **URL**: https://apify.com/data_fate/cheapest-plane-tickets-scraper.md
- **Developed by:** [Data Fate](https://apify.com/data_fate) (community)
- **Categories:** Travel, Agents
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $2.10 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Cheapest Flights Scraper — Trip.com Split Plane Tickets

**Find cheap flights that search engines never show you.** The Cheapest Flights Scraper compares
plane ticket prices on [Trip.com](https://www.trip.com/) two ways: the standard fare on one ticket
against **multi-city routings through a hub** — the kind of split-ticket combination that regularly
beats the single-ticket price by thousands. Enter where you are flying from, where you are going,
and which cities to test as stopovers. You get the cheapest plane tickets Trip.com has for each —
single ticket and split — with full flight details for every leg.

This is a flight price comparison, not an exhaustive listing, by design. Trip.com returns its
cheapest fares first, so the search takes the first handful of each route rather than everything
on offer: the bargain is at that end, and paging past it for more flight prices costs money
without finding anything better.

Run it from the Apify Console, on a [schedule](https://docs.apify.com/platform/schedules), through
the **[API](https://docs.apify.com/api/v2) in Python or JavaScript**, or as an **MCP tool** from
Claude or any AI agent — and export every flight to JSON, CSV or Excel.

### Custom requirements?

We build custom scrapers generally — any site, prices, listings, whatever you need
scraped — and this Actor is one case of that. Open an issue on the Actor's **Issues** tab
describing what you want, whether it is a feature this Actor lacks or a different scraping need
entirely, and the reply lands there too.

### Why splitting the ticket finds cheaper flights

Airlines price each origin-destination pair separately, and those prices have little to do with
distance. A round trip from Taipei to Prague can cost far more than a Taipei-Hong Kong round trip
plus a Hong Kong-Prague round trip booked separately — even though you fly the same route.

Flight search engines rarely surface these combinations, because they look for one ticket. This
Actor deliberately searches for two.

**Example:** Taipei to Prague, about $1,090 on one ticket. Routed through Hong Kong as two
separate bookings: **about $900** — around 18% cheaper on a real search (priced in TWD, dollar
figures illustrative).

### What data does the Cheapest Flights Scraper extract?

Every result is one priced itinerary — single ticket or split — with the fields that decide
whether the split is worth it. The key ones at a glance, with values from the real TPE→PRG run
shown in full under [Output](#output):

| Field                                                 | Example                                                                                  |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `pattern` / `splitAtCity`                             | `SPLIT_TICKET` / `HKG` — or a `SINGLE_TICKET` baseline on the same dates                 |
| `totalPrice`                                          | `{ "amount": 905, "currency": "USD" }` — every ticket added up                           |
| `tickets[]`                                           | one entry per booking: `positioning` TPE⇄HKG $127 + `main` HKG⇄PRG $778                  |
| `flights[]`                                           | every leg: airports, times, airline, flight number, duration, which ticket it belongs to |
| `selfTransfer` / `stopoverHours` / `hubAirportChange` | `true` / `[7.5, 5]` / `false` — what the connection asks of you                          |
| `stopsAt` / `totalTimeMinutes` / `totalFlights`       | `["HKG", "DOH"]` / `3000` / `6`                                                          |

### Who uses this flight scraper

#### Budget and long-haul travellers

Long-haul routes have the widest price spreads, so they benefit most from splitting.
If your trip is Asia to Europe, Asia to the Americas, or anywhere with an obvious hub in the
middle, this is where the savings live.

#### Flexible travellers comparing hubs

"Is it cheaper through Hong Kong, Seoul, Bangkok, or Singapore?" List several stopover cities and
the Actor prices every one of them in the same run, so you compare like for like on the same
dates.

#### Travel agencies and fare analysts

Track how the gap between single-ticket and split fares moves across seasons, routes and carriers.
Every run writes a structured dataset you can export or feed into a spreadsheet.

#### Price monitoring over time

Flight prices move daily. Scheduled runs turn a one-off search into a price history you can act
on — see the automation section below.

### How to scrape Trip.com flight prices

1. Enter **Departure City** and **Destination City** as IATA codes, e.g. `TPE` and `PRG`.
2. Add one or more **Split Tickets at These Hub Cities** — the hubs to test, as city codes, e.g. `HKG` or
   `SEL`. Leave it empty to price single tickets only.
3. Set your **Travel Dates** — an outbound date, plus a return date if you want a round trip.
   Leave the return date empty to search one-way instead.
4. Click **Start**, then read the results from the **Output** tab. They are in the order they were
   found, not sorted: sort by `totalPrice.amount`, or read the run's status message, which names
   the cheapest of each kind.

Optionally restrict results with **Filter by Airlines**, choose a **Cabin Class**, or set the
**Number of Passengers**.

#### One-way or round trip

Leave a period's return date empty and it is searched as a one-way flight. Each period is
independent, so a single run can price a one-way outbound alongside a round trip.

**One-way is where splitting tends to pay off most.** On a real TPE→PRG search, routing
through Hong Kong saved about 24% one-way against roughly 7% on the equivalent round trip — one-way
fares are priced less consistently, which is exactly the gap this Actor looks for.

Every result records its `tripType`, and the run summary compares one-way and round-trip
separately, since their prices are not comparable.

#### Why a search sometimes returns fewer results than you asked for

Return options are not evenly available. A popular nonstop flight might offer a dozen ways to come
back; a multi-leg itinerary through two hubs often has one or two. Asking for more results means
reaching further down those lists, and on some flights there is simply nothing further down.

So the number you set is an upper bound. A run that returns 34 where you asked for 40 is telling
you something real: **that is how much choice exists at those prices on those dates.**

Raising the number does not find cheaper flights. Trip.com returns its cheapest options first, so
the lowest price shows up even at a low setting — a higher one buys more options, not better ones.

#### Currency

Prices come back in whichever of the 31 supported currencies you pick — Trip.com does the
conversion, and every result records its own currency so exported data stays readable.

One caveat if you are **tracking prices over time**: a non-local currency adds exchange-rate
movement on top of fare movement, so a 3% drop may just be the rate. Pick the currency you would
actually pay in.

#### Filtering by airline

When you pick airlines, **Airline Match Mode** decides how strict the match is — checked
separately for the outbound and the return journey:

- **All legs** — every flight is on your chosen airlines. Strictest, fewest results.
- **Longest leg** — the long-haul flight is on your airline, while a short connecting hop may
  not be. Usually what you want when you are chasing a specific carrier for the main flight.
- **At least one leg** — widest. Includes itineraries where only a short hop matches.

Coverage is anything Trip.com sells — any airline, any destination it lists.

### How to automate flight price tracking

A single search tells you today's price. Scheduled searches tell you whether today's price is
actually good — which is what you need before booking.

**Recommended setup:**

1. **Schedule a daily run.** In Apify Console, open
   [Schedules](https://docs.apify.com/platform/schedules), add your saved task, and set
   it to run once a day. Early morning tends to catch fare updates from the previous night.
2. **Search a date range, not a single date.** Add several entries to Travel Dates —
   shifting departure by a few days often moves the price more than changing the route does.
3. **Compare hubs in one run.** Listing three or four stopover cities costs one run instead of
   four, and the results are directly comparable because the dates match.
4. **Send results where you will see them.** Connect the run to Slack, email, or Google Sheets
   through [Apify Integrations](https://docs.apify.com/platform/integrations), so a new low price
   reaches you instead of waiting in a dataset.
5. **Keep the history.** Each run stores its own dataset. After a couple of weeks you can tell a
   genuine drop from normal fluctuation — the single most useful thing for timing a booking.
6. **Start small.** Use a low **Max Results per Search** while you tune the inputs, then raise it
   once the searches return what you expect.

### Use it as a flight price API

The same search runs from code: call the
[Actor](https://apify.com/instinctive_headphone/cheapest-plane-tickets-scraper) through the
[Apify API](https://docs.apify.com/api/v2) and read the dataset back, in any language. In Python,
with the `apify-client` package:

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("instinctive_headphone/cheapest-plane-tickets-scraper").call(run_input={
    "departureCity": "TPE", "destinationCity": "PRG",
    "transitCities": ["HKG"],
    "travelDates": [{"departureDate": "2027-02-01", "returnDate": "2027-02-10"}],
    "currency": "USD", "maxResultsPerSearch": 20,
})
rows = list(client.dataset(run["defaultDatasetId"]).iterate_items())
baseline = min((row for row in rows if row["pattern"] == "SINGLE_TICKET"),
               key=lambda row: row["totalPrice"]["amount"])
split = min((row for row in rows if row["pattern"] == "SPLIT_TICKET"),
            key=lambda row: row["totalPrice"]["amount"])
print("one ticket:", baseline["totalPrice"], "— split at", split["splitAtCity"], ":", split["totalPrice"])
```

Or as one curl call that starts the run, waits, and returns the flights directly:

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/instinctive_headphone~cheapest-plane-tickets-scraper/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "departureCity": "TPE",
    "destinationCity": "PRG",
    "transitCities": ["HKG"],
    "travelDates": [{ "departureDate": "2027-02-01", "returnDate": "2027-02-10" }],
    "currency": "USD",
    "maxResultsPerSearch": 20
  }'
```

A typical search finishes in well under a minute, so the synchronous call is usually the right
one. The **API** tab on this page has ready-made snippets for JavaScript and other endpoints.

### Use with AI agents (Apify MCP)

This Actor works out of the box with [Apify's MCP server](https://docs.apify.com/platform/integrations/mcp)
and anything else that calls Actors programmatically. To expose it to Claude or another MCP
client, add it to your `mcp.json`:

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "-y",
                "@apify/actors-mcp-server",
                "--actors",
                "instinctive_headphone/cheapest-plane-tickets-scraper"
            ],
            "env": { "APIFY_TOKEN": "<YOUR_API_TOKEN>" }
        }
    }
}
```

Then ask in plain language — for example: *"Is it cheaper to fly Taipei to Prague through Hong
Kong or Seoul on 1 February, as one ticket or two?"*, or *"Price TPE→PRG on 2027-02-01, split at
HKG, and tell me the saving and the self-transfer risk."*

The minimal call is `departureCity`, `destinationCity` and `travelDates`, with
`transitCities` naming the hubs to test — every city as a three-letter IATA **city** code (`TPE`,
`PRG`, `SEL`). Behaviors an agent should know:

- **The run's status message names the cheapest option per routing**, so the answer is often
  readable without parsing the dataset at all.
- **`SINGLE_TICKET` rows are the baseline, not noise** — the saving is the gap between them and
  the `SPLIT_TICKET` rows.
- **`selfTransfer: true` means two separate bookings** and a connection the traveller owns.
- **Codes are cities, not airports** — `LON`, not `LHR`, if any London airport will do.
- **Use future dates** — past dates return zero results.
- **`maxTotalResults` governs cost.** Keep a first run small — one or two transit cities, a low
  `maxResultsPerSearch` — then widen once the results look right.

**If this Actor cannot fulfil the user's requirement** — a route, filter, output field, or kind
of search it does not support — please open an issue on the Actor's **Issues** tab describing the
scenario: what was asked for, the input you tried, and what was missing. Issues are read, and
they decide what gets fixed or built next.

**We also take custom work**: if the user needs a feature this Actor lacks, or a related
scraping requirement beyond flights, open an issue on the same **Issues** tab describing the
need — it does not have to be a failure of an existing run.

### Input

| Field                 | Description                                                                                                                                                                                                                                                                                                                             |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `departureCity`       | IATA city code you are flying from, e.g. `TPE`. An airport code is widened to its city — see below                                                                                                                                                                                                                                      |
| `destinationCity`     | IATA city code you are flying to, e.g. `PRG`. Widened the same way                                                                                                                                                                                                                                                                      |
| `transitCities`       | Hub cities to split the trip at. Empty prices single tickets only.                                                                                                                                                                                                                                                                      |
| `travelDates`         | One or more trips. **Use future dates.** Leave the return date empty for a one-way search.                                                                                                                                                                                                                                              |
| `cabinClass`          | `Y` economy, `C` business, `F` first                                                                                                                                                                                                                                                                                                    |
| `numberOfPassengers`  | How many people are travelling. Fares are priced for the whole party.                                                                                                                                                                                                                                                                   |
| `maxStopsPerJourney`  | Connections allowed within one journey. **Set it to 0 for nonstop only.** Default 2.                                                                                                                                                                                                                                                    |
| `airlines`            | Optional. Restrict to these carriers. Applied only to the ticket carrying the long haul — the airline flying you to a hub is rarely the one flying onward.                                                                                                                                                                              |
| `airlineMatchMode`    | How strictly the airline filter applies. Default `longest-leg`; `all` finds nothing unless your carrier flies every segment itself.                                                                                                                                                                                                     |
| `minStopoverHours`    | Hours needed at the hub between the two tickets. Not a connection time — you clear immigration, collect bags and check in again. Default 4.                                                                                                                                                                                             |
| `maxStopoverHours`    | The other end of that window. Default 36, so an overnight counts and two days does not. Caps at 72. It also sets how many days of onward flights are searched — one per 24 hours — so the window you can ask for is exactly the one that gets searched. That adds work but rarely cost: the result cap stops the search once it is met. |
| `maxResultsPerSearch` | Upper bound per search — one route, one trip. Each hub and each trip gets its own, so totals multiply. Some searches return fewer; see below.                                                                                                                                                                                           |
| `maxTotalResults`     | Upper bound for the whole run, across every route and trip. **This is the field that governs what a run costs.** Default 200.                                                                                                                                                                                                           |

```json
{
    "departureCity": "TPE",
    "destinationCity": "PRG",
    "transitCities": ["HKG"],
    "cabinClass": "Y",
    "currency": "USD",
    "numberOfPassengers": 1,
    "travelDates": [{ "departureDate": "2027-02-01", "returnDate": "2027-02-10" }],
    "maxResultsPerSearch": 20
}
```

#### These are cities, not airports

`LHR` does not mean Heathrow. Trip.com widens an airport code to the city it serves, so a search
for `LHR` becomes a search for London and can come back with a departure from Gatwick or
Southend — and the result will say `LON`, because that is what was actually searched.

This matters most with **Max Stops per Journey set to 0**: you can get a genuine nonstop that
leaves from an airport you did not have in mind. Measured examples — asking for Gatwick returned
Heathrow, Orly returned Charles de Gaulle, and Gimpo returned Incheon. If only one airport in a
city works for you, filter the results after exporting. The search itself cannot be narrowed
below the city.

**City codes are the safest way to name a hub** — `SEL`, `TYO`, `LON`. An airport code works
too, and for the 13 measured so far (`ICN`, `NRT`, `LHR` among them) it is treated as its city, so
a stopover can land at one airport and leave from the other. Any other airport code matches only
flights through that airport.

### Output

Each dataset item is one flight option. Results are written as they are found, so the dataset is
in discovery order rather than price order — sort it after exporting if you need it ranked. The
run's status message already names the cheapest of each routing, so a glance at the Runs list
answers "did splitting win" without opening the dataset at all.

#### A run returns two kinds of row, and you need both

Asking to split the trip at Hong Kong does **not** mean every row goes through Hong Kong. A run
prices the trip both ways, because a saving means nothing without something to compare it to:

| `pattern`       | `splitAtCity` | what the row is                                                                                       |
| --------------- | ------------- | ----------------------------------------------------------------------------------------------------- |
| `SINGLE_TICKET` | `null`        | **the baseline** — the cheapest way to fly this route on one ticket, routed however the airline likes |
| `SPLIT_TICKET`  | `HKG`         | **the experiment** — the same trip bought as two tickets meeting at Hong Kong                         |

So a baseline row connecting in Doha is not a mistake or a missed filter. It is the number that
tells you whether splitting at Hong Kong was worth it. Without it, `1,062` is just a price.

Two more fields are easy to confuse, and mean different things:

- **`splitAtCity`** — where *we split the ticket*. `null` on a baseline row.
- **`stopsAt`** — where the aircraft actually stops, including the airline's own
  connections. A baseline row can transit Hong Kong all by itself, which is the best outcome of
  all: one ticket, bags checked through, and no connection of your own to make.

`selfTransfer` is the field to read before comparing prices. When it is `true` the itinerary is
two separate bookings and a missed connection is yours to solve.

`tickets` is where the money is broken down: one entry per booking you would actually make, each
with its own price. A single-ticket row has one entry with `role: "main"`; a split row adds a
`role: "positioning"` entry, which is the ticket bought only to get you to the hub and back — so
you can see what reaching the hub costs and what the fare onward from it costs. Every leg in
`flights` carries a `ticket` index pointing back into that list, so you can see exactly where one
booking ends and the next begins.

A split round trip is **two round trips**: positioning from home to the hub and back, and the
main ticket from the hub to the destination and back. The positioning ticket comes home the **day
after** `returnDate`, so you get home a day later than you would on a single ticket. The row's
`returnDate` is the main ticket's.

**The run's status message answers the question directly**, comparing each stopover against the
cheapest single ticket:

```
✅ 23 results · one ticket 972 USD · via SEL 830 (-142) · via HKG 905 (-67)
```

So a glance at the Runs list tells you which routing won and by how much, without opening the
dataset. The full comparison, including every stopover city, is in the run log.

#### What does the output look like?

One split-ticket row from a real TPE→PRG run, trimmed to one leg for length:

```json
{
    "pattern": "SPLIT_TICKET",
    "tripType": "round-trip",
    "departureCity": "TPE",
    "destinationCity": "PRG",
    "splitAtCity": "HKG",
    "departureDate": "2026-11-10",
    "returnDate": "2026-11-20",
    "totalPrice": { "amount": 905, "currency": "USD" },
    "totalTimeMinutes": 3000,
    "totalFlights": 6,
    "selfTransfer": true,
    "stopoverHours": [7.5, 5],
    "hubAirportChange": false,
    "tickets": [
        {
            "role": "positioning",
            "from": "TPE",
            "to": "HKG",
            "price": { "amount": 127, "currency": "USD" },
            "productId": "...",
            "policyId": "..."
        },
        {
            "role": "main",
            "from": "HKG",
            "to": "PRG",
            "price": { "amount": 778, "currency": "USD" },
            "productId": "...",
            "policyId": "..."
        }
    ],
    "stopsAt": ["HKG", "DOH"],
    "flights": [
        {
            "ticket": 0,
            "departureCityCode": "TPE",
            "departureAirport": "TPE",
            "departureTime": "2026-11-10 23:45:00",
            "arrivalCityCode": "HKG",
            "arrivalAirport": "HKG",
            "arrivalTime": "2026-11-11 01:30:00",
            "flightSegment": { "airline": "CI", "flightNumber": "CI601" },
            "durationTimeMinutes": 105
        }
    ]
}
```

**Visual report** — Every run that finds results also saves an interactive HTML report to the
Output tab. It groups results by search combination (route, dates, trip type), highlights the
cheapest routing in each group, and shows a timeline bar for every journey with leg-by-leg flight
details. Open it from the Output tab after the run finishes.

You can download the dataset as JSON, CSV, Excel, or HTML.

| Field              | Type   | Description                                                                           |
| ------------------ | ------ | ------------------------------------------------------------------------------------- |
| `pattern`          | string | `SINGLE_TICKET` or `SPLIT_TICKET`                                                     |
| `tripType`         | string | `one-way` or `round-trip`. A run can mix both, and their prices are not comparable    |
| `departureCity`    | string | Origin IATA code                                                                      |
| `destinationCity`  | string | Destination IATA code                                                                 |
| `splitAtCity`      | string | Hub the trip is split at, `null` on a single ticket                                   |
| `departureDate`    | string | Outbound date                                                                         |
| `returnDate`       | string | Return date of the main ticket, `null` on a one-way                                   |
| `totalPrice`       | object | `{ amount, currency }` — what the whole itinerary costs, every ticket added up        |
| `totalTimeMinutes` | number | Total travel time including connections                                               |
| `totalFlights`     | number | How many flights you take in all                                                      |
| `selfTransfer`     | bool   | `true` when the itinerary is two tickets and the connection is yours to make          |
| `stopoverHours`    | array  | Hours waiting at the hub, one per handover between tickets                            |
| `hubAirportChange` | bool   | `true` when you must travel between two airports at the hub, so allow extra time      |
| `tickets`          | array  | One entry per booking: `role`, `from`, `to`, `price` as `{ amount, currency }`        |
| `stopsAt`          | array  | Every airport the journey stops at that is not an end, each named once                |
| `flights`          | array  | Every leg in order: airports, times, airline, flight number, duration, `ticket` index |

### Before you book: read this

**This is a price discovery tool, not a booking system.**

Split tickets are **two separate bookings**, which is exactly why they can be cheaper — and
exactly what you are taking on:

- **A delay on the first ticket does not protect the second.** Nobody rebooks you, and the
  second fare is simply lost. This is the real cost of the saving, and no search can remove it.
- **Baggage does not transfer** between separate tickets. You collect it and check in again,
  and each ticket has its own baggage allowance and fees.
- **You enter the hub country.** Collecting bags and checking in again means passing immigration,
  so check the hub's transit-visa and entry requirements for your passport before booking.
- **Availability moves** between the search and your booking.

Every result reports what it is asking of you: `selfTransfer` says whether the connection is
yours, `stopoverHours` says how long you have, and `hubAirportChange` says whether you also have
to get from one hub airport to another. Itineraries that cannot connect are not
returned — the run checks every handover against your stopover window and says so in a
`SEARCH_ERROR` row when nothing fits. Choosing a longer `minStopoverHours` buys margin against
a delay; four hours is the shortest that is realistic.

### How much does it cost to scrape Trip.com flight prices?

|                    |                         |
| ------------------ | ----------------------- |
| Starting the Actor | $0.005 per run          |
| Each result        | $0.003, so $3 per 1,000 |

A default search — one hub, one trip — is two searches of up to 20 results each, so at most
about **$0.13**. Nothing else is charged: the Actor queries flight data directly rather than
driving a browser, and a typical search finishes in well under a minute.

**`maxTotalResults` is the field to set if the bill matters.** Results multiply with travel
periods and hub cities, so three periods and three hubs at 100 per search asks for 1,200 results
without looking like it. The default cap of 200 keeps any single run under about $0.61.

**Explanation rows are billed too.** A search that finds nothing writes one `SEARCH_ERROR` row
naming the reason, charged like a result. These rows are not counted against `maxTotalResults`,
but a search writes one only when it wrote no results, so the run still stays within the cap.

### Finding outstation tickets (外站票)

An **outstation ticket** is when flying from a cheaper origin city through your home city to
a destination costs less than flying from your home city directly. For example, a Hong Kong →
Tokyo ticket routed through Taipei can be cheaper than a Taipei → Tokyo ticket — even though
you board the same onward flight in Taipei. This happens because airlines price each
origin-destination pair independently, and fares out of hub cities like Hong Kong, Bangkok or
Singapore are often lower.

The idea is the same split-ticket logic this Actor already uses, but flipped: instead of
splitting a long-haul at a cheaper hub, you start from a cheaper city and pass through home.

#### How to compare with two runs

You need two runs: one prices the outstation route, the other prices the route from home.

**Run 1 — outstation route (HKG → NRT, splitting at TPE):**

```json
{
    "departureCity": "HKG",
    "destinationCity": "NRT",
    "transitCities": ["TPE"],
    "travelDates": [{ "departureDate": "2027-03-01", "returnDate": "2027-03-10" }],
    "currency": "USD",
    "maxResultsPerSearch": 20
}
```

This searches Hong Kong to Tokyo, split at Taipei. The `SPLIT_TICKET` rows in the results
are the outstation fares: a cheap HKG→TPE ticket plus a TPE→NRT ticket onward from your home
city.

**Run 2 — baseline from home (TPE → NRT, direct):**

```json
{
    "departureCity": "TPE",
    "destinationCity": "NRT",
    "travelDates": [{ "departureDate": "2027-03-01", "returnDate": "2027-03-10" }],
    "currency": "USD",
    "maxResultsPerSearch": 20
}
```

No `transitCities` needed — you just want the single-ticket price from Taipei.

Compare the cheapest `SPLIT_TICKET` from Run 1 against the cheapest `SINGLE_TICKET` from
Run 2. If the outstation split is cheaper, the saving pays for the extra leg to the hub city
and back.

#### What to watch for

- **You fly to the hub first.** On a round trip, the positioning leg is HKG→TPE before your
  flight and TPE→HKG after you return — so you add travel time and a self-transfer at your
  home airport.
- **Same self-transfer rules apply.** The outstation split is two separate bookings, with the
  same connection risks described in [Before you book](#before-you-book-read-this).
- **One-way outstations can be especially good.** The price gap on one-way fares tends to be
  wider, and you only need the positioning leg in one direction.

### FAQ

#### How is this different from Google Flights or Skyscanner scrapers?

They price a trip as one ticket. This Actor also prices it as two tickets split at a hub, and
tells you whether the split wins — the single-ticket baseline is searched in the same run, so the
flight price comparison is on the same dates, like for like.

#### What is split-ticketing, and is it allowed?

Buying one trip as two separate tickets that meet at a hub. It is ordinary ticket buying — each
booking is a normal fare bought at its normal price; the trade-off is that nobody protects the
connection between them, which is what the `selfTransfer` field warns about.

#### Can I book a split ticket as one booking?

No. They are separate bookings — that is the source of the saving, and the source of the risk.
The run does check that every handover fits your stopover window, so what you see can be flown.
What no search can do is protect you when the first flight is late.

#### Does Trip.com have a public flight API?

No. Trip.com has no public flights API; this Actor is the practical Trip.com flight API
alternative — a documented JSON input and output over the same fare data the site shows,
callable from Python, JavaScript or any MCP agent.

#### Can I use the Cheapest Flights Scraper with the Apify API or Python?

Yes — see the [flight price API section](#use-it-as-a-flight-price-api) above, or the **API** tab
for ready-made JavaScript, Python and curl snippets. The `run-sync-get-dataset-items` endpoint
returns the flights in one call.

#### Can I integrate it with Google Sheets, n8n, Make or Zapier?

Yes — through [Apify integrations](https://docs.apify.com/platform/integrations): schedule a run
and send new lows to Slack, email or a sheet.

#### How far ahead should I search?

Long-haul fares usually settle two to four months out. Scheduled runs across that window are the
most reliable way to spot a genuine drop.

#### Is scraping flight prices legal?

The Actor reads publicly available prices. How you use the data is your responsibility — review
Trip.com's Terms of Service before running at scale.

Found a problem, or need something this Actor does not do yet? Open an issue in the **Issues**
tab describing your scenario — issues decide what gets fixed and built next.

# Changelog

This Actor's version history is a separate document: https://apify.com/data_fate/cheapest-plane-tickets-scraper/changelog.md

# Actor input Schema

## `departureCity` (type: `string`):

Three-letter IATA code for where the trip starts — TPE for Taipei, HKG for Hong Kong, SIN for Singapore. Lower case is fine. This is a city, not a terminal: an airport code is widened to the city it serves, so LHR searches all of London and can return a flight from Gatwick or Southend. Where a city has several airports and you only want one of them, filter the results afterwards — the search cannot be narrowed to a single airport.

## `destinationCity` (type: `string`):

Three-letter IATA code for where the trip ends — PRG for Prague, LON for London, PAR for Paris. Lower case is fine. Widened to the city the same way the departure is, so asking for CDG searches every Paris airport.

## `transitCities` (type: `array`):

Hub cities to test as the split point of a split-ticket itinerary — the meeting point between two separate tickets — as three-letter IATA codes (lower case is fine). City codes (SEL, TYO, LON) are the safest choice: an airport code works too, but outside the measured ones (ICN, NRT, LHR among them) it matches only flights through that exact airport. Each city multiplies the work, so start with one or two; a city that is already an end of the route is ignored. A city is worth trying when it sits on the way, or when its own market is cheaper — a fare starting in Bangkok or Seoul can undercut the same trip starting at home even after paying to get there. Two tickets mean no through-checked baggage and no protection if the first flight is late, which is what the stopover window below is for.

## `travelDates` (type: `array`):

One or more trips. Each is searched separately, and each can be one-way or return. Leave the list empty to search a single round trip about two months out, which is a real search rather than a placeholder.

## `cabinClass` (type: `string`):

Cabin class to search: Y = Economy, C = Business, F = First.

## `numberOfPassengers` (type: `integer`):

How many people are travelling. Every fare is priced for the whole party, not per person — a group of three sees the total for three.

## `maxStopsPerJourney` (type: `integer`):

Connections allowed within a single journey. **Set this to 0 for nonstop flights only**, which is what most people mean by a direct flight. Lowering it finds fewer results, since the cheapest fares are usually the ones with the most stops. Applied to each journey of each ticket separately, so a split-ticket trip cannot quietly accumulate four times the limit — left unbounded, one search produced Taipei–Bangkok–Vienna–Prague out and Prague–London–Bangkok–Taipei back, six flights on four airlines.

## `airlines` (type: `array`):

Restrict results to specific airlines by IATA code (e.g. CI, BR). Leave empty to search all airlines. Use Airline Match Mode to control how strictly they must match.

## `airlineMatchMode` (type: `string`):

How strictly the airline filter applies; ignored when no airlines are selected. Checked separately for the outbound and the return journey, and only on the ticket carrying the long haul — the carrier flying you to a hub is rarely the one flying onward. "Longest leg" (the default) lets a short connecting hop be on another carrier. "All legs" is strictest and finds nothing unless your airline flies every segment itself. "Any leg" is widest and includes itineraries where only a short hop matches.

## `minStopoverHours` (type: `integer`):

How long the traveller must have at the transit city between the two separate tickets. This is not an airline connection time: two tickets mean no through-checked baggage and no protection if the first flight is late, so the gap has to cover immigration, baggage reclaim, a fresh check-in that closes an hour before departure, and security again. Four hours is the shortest that is realistic; an overnight is what most people actually do.

## `maxStopoverHours` (type: `integer`):

The other end of the same window: the longest gap allowed at the transit city between the two tickets. It also decides how many days of onward departures are searched — one day per 24 hours — because a stopover allowed to last until the day after next has to be looked for there. The search cost depends on the gap between min and max (not max alone), capped at three extra days, so raising the ceiling does not add work when the minimum is high enough to narrow the window. Without this limit a “connection” can turn into days of waiting: gaps of 45 hours were measured before it existed.

## `currency` (type: `string`):

Currency prices are reported in. This is sent with the search, so Trip.com does the conversion. Note that if you schedule runs to track prices over time, a non-local currency adds exchange-rate movement on top of fare movement — a 3% drop may just be the rate. Every result records its currency, so exported data stays readable.

## `maxResultsPerSearch` (type: `integer`):

Upper bound on results from each search, where one search is a single route, trip and trip type. A run searches the direct route plus one per transit city, for each trip, so totals multiply — Max Results per Run caps the whole. Raising this does not find cheaper flights: Trip.com returns its cheapest options first, so the lowest price appears even at a low value — it buys more options, not better ones. Expect fewer than you ask for on some searches: a popular direct flight offers a dozen return options while a multi-leg one often has only one or two, and there is no way to build combinations that the airline does not sell.

## `maxTotalResults` (type: `integer`):

Upper bound on results from the whole run, across every route and trip. Cannot be lower than the number of searches — one per trip, plus one per transit city per trip — because every search needs at least one result. This is the limit that governs what a run costs: Max Results per Search is multiplied by the number of searches, so three trips and three transit cities at 100 per search quietly asks for 1,200 results, and this caps that. Whichever of the two limits works out lower decides the per-search budget, and the budget is set before searching rather than trimmed afterwards.

## Actor input object example

```json
{
  "departureCity": "TPE",
  "destinationCity": "PRG",
  "transitCities": [
    "HKG"
  ],
  "cabinClass": "Y",
  "numberOfPassengers": 1,
  "maxStopsPerJourney": 2,
  "airlines": [],
  "airlineMatchMode": "longest-leg",
  "minStopoverHours": 4,
  "maxStopoverHours": 36,
  "currency": "USD",
  "maxResultsPerSearch": 20,
  "maxTotalResults": 200
}
```

# Actor output Schema

## `visualReport` (type: `string`):

No description

## `flightResults` (type: `string`):

No description

## `allData` (type: `string`):

No description

# 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 = {
    "departureCity": "TPE",
    "destinationCity": "PRG",
    "transitCities": [
        "HKG"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("data_fate/cheapest-plane-tickets-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 = {
    "departureCity": "TPE",
    "destinationCity": "PRG",
    "transitCities": ["HKG"],
}

# Run the Actor and wait for it to finish
run = client.actor("data_fate/cheapest-plane-tickets-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 '{
  "departureCity": "TPE",
  "destinationCity": "PRG",
  "transitCities": [
    "HKG"
  ]
}' |
apify call data_fate/cheapest-plane-tickets-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data_fate/cheapest-plane-tickets-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/KzsWmdVn1lan25m6a/builds/nZZMHnBIwtnP8OKlZ/openapi.json
