# Google Flights Scraper (`searchapi/google-flights-scraper`) Actor

Scrapes Google Flights for any origin/destination. Extracts airline, flight numbers, airports, departure/arrival times, duration, stops, price, cabin class, booking site, emissions, aircraft, and more.

- **URL**: https://apify.com/searchapi/google-flights-scraper.md
- **Developed by:** [Search API](https://apify.com/searchapi) (community)
- **Categories:** Travel, Automation, Developer tools
- **Stats:** 3 total users, 1 monthly users, 97.1% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.99 / 1,000 search results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Google Flights Scraper

Search the interactive Google Flights website by airport, date, trip type, passenger count, cabin, country, and language. The Actor maps only source-backed itinerary-card data and never invents booking details that Google does not expose.

### Input modes

- `single`: use the top-level route fields.
- `batch`: provide up to 20 objects in `searches`; `maxItems` is allocated fairly across routes and requests run with bounded concurrency.

Each search accepts `departure`, `arrival`, `departureDate`, optional `returnDate`, `tripType`, `passengers`, and `cabinClass`. Global controls include `gl`, English `hl` locales, `maxItems`, `maxConcurrency`, bounded retries/timeouts, debug logging, and Apify/custom proxy configuration.

`GOOGLE_SERP` is intentionally rejected. It is an HTTP search-results transport, while Google Flights is an interactive JavaScript application. Direct access is the verified default; Apify Residential or user-provided proxies can be selected when needed.

### Dataset

The typed 65-field contract includes:

- Stable identity, global/route positions, Google flight ID, and flight number.
- Airline name/code/logo and origin/destination codes and airport names.
- Departure/arrival labels and times, duration, stops, stop airports, and layover labels.
- Displayed and numeric price, currency, baggage allowance, and emissions.
- Cabin, passengers, trip type, requested dates, locale, source URLs, and consistent search metadata.

Optional fields are omitted when the current card does not expose them. Nulls, empty strings/arrays, embedded data URLs, challenge pages, secrets, and fabricated records are not stored. Results are deduplicated by a stable SHA-256 identity and pushed in deterministic route/card order.

### Reliability

- Validates calendar dates, round-trip chronology, IATA codes, filters, limits, locale, and proxy compatibility.
- Validates HTTP status and HTML content type before parsing.
- Detects CAPTCHA/challenge pages, marks the session bad, and fails closed after bounded retries.
- Uses persistent per-session cookies and one internally consistent desktop Chrome fingerprint per session.
- Blocks image, media, and font downloads without blocking scripts, styles, or flight-card completeness.
- Expands Google's `View more flights` control only when the requested per-route quota exceeds the cards already loaded.
- Distinguishes explicit no-results pages from selector drift.

### Local verification

```sh
npm ci
npm test
apify validate-schema
npm audit --omit=dev
apify run --purge --input-file INPUT.json
node test/audit-dataset.js --expected=20
```

Representative fixtures under `qa-inputs` cover minimal, batch/round-trip, invalid, no-results, direct, and Residential-proxy runs.

# Actor input Schema

## `mode` (type: `string`):

Run one top-level route or multiple routes from the searches array.

## `departure` (type: `string`):

Three-letter IATA airport code.

## `arrival` (type: `string`):

Three-letter IATA airport code.

## `departureDate` (type: `string`):

Date in YYYY-MM-DD format.

## `returnDate` (type: `string`):

Required for round-trip searches; YYYY-MM-DD.

## `tripType` (type: `string`):

Choose a one-way or round-trip itinerary.

## `passengers` (type: `integer`):

Number of adult passengers in each search unless overridden in batch mode.

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

Cabin preference used for each search unless overridden in batch mode.

## `searches` (type: `array`):

Routes to run concurrently in batch mode. Omitted values inherit the top-level trip, passenger, and cabin defaults.

## `gl` (type: `string`):

Two-letter lowercase country code used by Google Flights.

## `hl` (type: `string`):

English Google interface locale: en or en-XX.

## `maxItems` (type: `integer`):

Global limit, allocated fairly across batch routes.

## `maxConcurrency` (type: `integer`):

Maximum flight searches processed at the same time.

## `maxRequestRetries` (type: `integer`):

Bounded retries for temporary network, browser, rate-limit, or proxy failures.

## `navigationTimeoutSecs` (type: `integer`):

Maximum time allowed for the initial page navigation.

## `requestHandlerTimeoutSecs` (type: `integer`):

Maximum total processing time for one route.

## `resultSelectorTimeoutSecs` (type: `integer`):

Maximum time to wait for a flight card or no-results state.

## `maxLoadMoreClicks` (type: `integer`):

Maximum View more flights expansions per route when the requested quota exceeds visible cards.

## `loadMoreDelayMs` (type: `integer`):

Short stabilization delay after each View more flights expansion.

## `proxyConfiguration` (type: `object`):

Use direct access, Apify Residential, or custom proxy URLs. GOOGLE\_SERP is not compatible with this interactive page.

## `debug` (type: `boolean`):

Enable additional non-sensitive diagnostics.

## Actor input object example

```json
{
  "mode": "single",
  "departure": "JFK",
  "arrival": "LAX",
  "departureDate": "2026-09-15",
  "tripType": "one-way",
  "passengers": 1,
  "cabinClass": "economy",
  "gl": "us",
  "hl": "en",
  "maxItems": 20,
  "maxConcurrency": 2,
  "maxRequestRetries": 2,
  "navigationTimeoutSecs": 60,
  "requestHandlerTimeoutSecs": 120,
  "resultSelectorTimeoutSecs": 30,
  "maxLoadMoreClicks": 5,
  "loadMoreDelayMs": 750,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "debug": false
}
```

# 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 = {
    "departureDate": "2026-09-15"
};

// Run the Actor and wait for it to finish
const run = await client.actor("searchapi/google-flights-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 = { "departureDate": "2026-09-15" }

# Run the Actor and wait for it to finish
run = client.actor("searchapi/google-flights-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 '{
  "departureDate": "2026-09-15"
}' |
apify call searchapi/google-flights-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,searchapi/google-flights-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/T1cLaLgbTlUxI80OC/builds/t2Mx4d4LVHPyKH8SH/openapi.json
