# Google Flights API & Scraper — Fares & Price Insights (`westerly_breaker/google-flights-scraper`) Actor

Google Flights fares for any routes and dates: one-way or round trip, every itinerary with airlines, flight numbers, times, stops, layovers, aircraft, CO2, plus Google's low/typical/high price insight and price history.

- **URL**: https://apify.com/westerly_breaker/google-flights-scraper.md
- **Developed by:** [Daniel Posztos](https://apify.com/westerly_breaker) (community)
- **Categories:** Travel, Automation, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 dataset items

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?

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

## Google Flights API & Scraper — Fares, Schedules & Price Insights

**SEO title:** Google Flights API — fares, schedules, price insights
**SEO description:** Google Flights API for Python, JavaScript or no code: one-way and round-trip fares for any routes and dates, airlines, flight numbers, stops, CO2, plus Google's low/typical/high price verdict.

A Google Flights API you can call from Python, JavaScript, any HTTP client or an AI agent. Give it routes and dates and get every itinerary Google Flights shows, one row each:

- **Fare**: total for your passengers and cabin class, in your currency (round-trip total for round trips)
- **Schedule**: airlines, departure and arrival in local time, total duration, stops, layover airports and durations
- **Every segment**: flight number, aircraft, legroom, times
- **CO2**: Google's emission estimate vs. the typical flight on the route
- **Price insight**: Google's own verdict on the search ("prices are currently low / typical / high"), the typical price range, and optionally ~60 days of price history

Search many origins, destinations and dates in one run. Every combination is searched, so a list of dates gives you a fare calendar.

### Why this exists

Google Flights has no public API, and the most-used scraper bills per page plus per booking option, so a single route lookup can cost several cents. This actor reads the same data the Google Flights results page is built from, without a browser:

- **Searches are encoded the way the Google Flights app does it.** Natural-language searches return no flights from cloud servers most of the time; encoded searches return flights.
- **Fast:** the first attempt goes out directly. Only when Google answers with an error does a retry go through a fresh proxy session.
- **One flat row per itinerary**, ready for a spreadsheet, a database or an AI agent.

Cloud test: 3 origins × 2 destinations × 5 dates = 30 searches → 300 itineraries in 43 seconds. Every search returned flights; 6 of 36 requests needed a retry.

### Input

| Field | What it does | Default |
|---|---|---|
| `origins` | IATA codes: airports (`JFK`) or metro areas (`NYC`, `LON`) | — |
| `destinations` | Same format | — |
| `departureDates` | `YYYY-MM-DD` list; each date is a search | — |
| `tripLengthDays` | Empty = one-way; e.g. `7` = round trip returning 7 days later | one-way |
| `adults`, `children`, `infantsInSeat`, `infantsOnLap` | Passengers (max 9) | 1 adult |
| `cabinClass` | `economy`, `premium_economy`, `business`, `first` | `economy` |
| `maxStops` | `any`, `nonstop`, `1`, `2` | `any` |
| `maxResultsPerSearch` | Itineraries per search (Google lists ~10-40) | `30` |
| `currency` | `USD`, `EUR`, `GBP`... | `USD` |
| `includePriceHistory` | ~60-day price history on each search's first row | `false` |
| `language`, `countryCode` | Interface language, point of sale | `en-US`, `us` |
| `proxyConfiguration` | Proxy used for retries | Apify Proxy |

#### Worked example — input

```json
{
  "origins": ["JFK"],
  "destinations": ["LHR"],
  "departureDates": ["2026-11-20"],
  "maxResultsPerSearch": 10
}
```

#### Worked example — output (one row, real data)

```json
{
  "origin": "JFK",
  "destination": "LHR",
  "departureDate": "2026-11-20",
  "returnDate": null,
  "tripType": "one_way",
  "cabinClass": "economy",
  "passengers": {"adults": 1, "children": 0, "infantsInSeat": 0, "infantsOnLap": 0},
  "currency": "USD",
  "rank": 4,
  "category": "other",
  "price": 420,
  "airlines": ["Aer Lingus"],
  "departureAirport": "JFK",
  "departureTime": "2026-11-20T17:00",
  "arrivalAirport": "LHR",
  "arrivalTime": "2026-11-21T08:05",
  "durationMinutes": 605,
  "stops": 1,
  "layovers": [{"airport": "DUB", "airportName": "Dublin Airport", "city": "Dublin", "durationMinutes": 125}],
  "segments": [
    {"flightNumber": "EI 104", "airline": "Aer Lingus", "departureAirport": "JFK", "departureAirportName": "John F. Kennedy International Airport", "departureTime": "2026-11-20T17:00", "arrivalAirport": "DUB", "arrivalAirportName": "Dublin Airport", "arrivalTime": "2026-11-21T04:30", "durationMinutes": 390, "aircraft": "Airbus A330", "legroom": "31 inches"},
    {"flightNumber": "EI 152", "airline": "Aer Lingus", "departureAirport": "DUB", "departureAirportName": "Dublin Airport", "departureTime": "2026-11-21T06:35", "arrivalAirport": "LHR", "arrivalAirportName": "Heathrow Airport", "arrivalTime": "2026-11-21T08:05", "durationMinutes": 90, "aircraft": "Airbus A320neo", "legroom": "29 inches"}
  ],
  "emissions": {"grams": 394000, "typicalGrams": 432000, "differencePercent": -9},
  "priceInsights": {"priceLevel": "high", "priceLevelCode": 5, "lowestPrice": 420, "typicalPrice": 286, "typicalPriceRange": [170, 300]},
  "bookingToken": "CjRIOURJY3dQbEoxOTRB...",
  "googleFlightsUrl": "https://www.google.com/travel/flights/search?tfs=...",
  "hasData": true,
  "scrapedAt": "2026-10-12T15:13:02Z"
}
```

### Output notes

- **Times are local** to each airport (`2026-11-20T17:00` at JFK, `08:05` at LHR the next day), the same as on Google Flights.
- **`price`** is the total for all passengers. For round trips it is the **round-trip total**, and the row describes the outbound flight. Google only shows return-flight options after you pick an outbound flight, so they are not included.
- **`priceInsights`** describes the whole search and repeats on every row of it. `priceLevel` is Google's own verdict, `typicalPriceRange` is the range Google considers normal for the route. `priceHistory` (when requested) is only on rank 1.
- **`category`**: `best` is Google's "Best" list, `other` is everything else, ranked as Google ranks them.
- A search that fails or has no flights appears as one row with `hasData: false` and an `error`. That row is not charged.

### Use it from code or an AI agent

```bash
curl -X POST "https://api.apify.com/v2/acts/westerly_breaker~google-flights-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"origins": ["BUD"], "destinations": ["LON", "PAR"], "departureDates": ["2026-12-04", "2026-12-05"], "tripLengthDays": 3, "maxStops": "nonstop", "maxResultsPerSearch": 5}'
```

From Python (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("westerly_breaker/google-flights-scraper").call(
    run_input={"origins": ["NYC"], "destinations": ["LON"], "departureDates": ["2026-11-20", "2026-11-21"], "maxResultsPerSearch": 5}
)
for flight in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(flight["departureDate"], flight["price"], flight["airlines"], flight["stops"])
```

Common uses: fare monitoring (schedule a daily run and watch `price` and `priceLevel`), finding the cheapest day in a date range, comparing routes and airlines for travel tools and agents, and route and schedule research.

### Pricing (pay-per-event)

**$0.001 per itinerary delivered**, platform usage included. You control the cost with `maxResultsPerSearch`.

- 1 route × 14 dates × 10 itineraries = 140 × $0.001 = **$0.14**
- Searches that fail or have no flights are **not charged**.
- If you set a maximum cost per run, the actor stops cleanly at that limit. Every row you paid for is delivered, and you are never billed for a row you didn't get.

### Error messages

Bad input stops the run before any request, naming the field and the fix, for example:

- `'origins' entry 'London' is not a 3-letter IATA code. Use airport codes like 'JFK', 'LHR' or metro-area codes like 'NYC', 'LON' (they cover all of the city's airports).`
- `Each infant on lap needs an adult: 'infantsOnLap' cannot exceed 'adults'.`

### Known limitations

- **Return-flight details for round trips** and **per-site booking options** (airline vs. agencies) each need extra requests per itinerary and are not included yet.
- **Multi-city trips** are not supported yet (one-way and round trip only).
- Fares change constantly and can differ by `countryCode` (point of sale), the same as on google.com.

### Data source

Public Google Flights search results (google.com/travel/flights), the same data the web page shows. No login, no API key.

# Actor input Schema

## `origins` (type: `array`):

3-letter IATA codes. Airports like "JFK", or metro areas like "NYC" / "LON" to cover all of a city's airports.

## `destinations` (type: `array`):

3-letter IATA codes, same format as 'From'. Every origin is searched against every destination.

## `departureDates` (type: `array`):

One or more dates as YYYY-MM-DD. Each date is a separate search, so a list of dates gives you a fare calendar. Up to ~11 months ahead.

## `tripLengthDays` (type: `integer`):

Leave empty for one-way. Set e.g. 7 to search round trips returning 7 days after each departure date. Round-trip rows show the outbound flight and the round-trip total price.

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

1-9.

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

Age 2-11.

## `infantsInSeat` (type: `integer`):

Infants under 2 with their own seat.

## `infantsOnLap` (type: `integer`):

At most one per adult.

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

Economy, premium economy, business or first.

## `maxStops` (type: `string`):

Limit the number of stops per direction.

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

Google lists roughly 10-40 itineraries per search, best ones first. You pay per itinerary delivered.

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

3-letter ISO code, e.g. USD, EUR, GBP.

## `includePriceHistory` (type: `boolean`):

Add Google's ~60-day price history for the route to the first row of each search.

## `language` (type: `string`):

Language of airport and airline names, e.g. 'en-US', 'de'.

## `countryCode` (type: `string`):

2-letter code (gl), e.g. 'us', 'gb'. Fares can differ by point of sale.

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

The first attempt of each search goes out directly (fastest). If it fails, retries go through a fresh Apify Proxy session.

## Actor input object example

```json
{
  "origins": [
    "JFK",
    "EWR"
  ],
  "destinations": [
    "LHR"
  ],
  "departureDates": [
    "2026-11-20",
    "2026-11-21"
  ],
  "adults": 1,
  "children": 0,
  "infantsInSeat": 0,
  "infantsOnLap": 0,
  "cabinClass": "economy",
  "maxStops": "any",
  "maxResultsPerSearch": 30,
  "currency": "USD",
  "includePriceHistory": false,
  "language": "en-US",
  "countryCode": "us",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `itineraries` (type: `string`):

One row per itinerary: fare, airlines, times, stops, layovers, segments, emissions and the search's price insight, stored in the run's default dataset.

# 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 = {
    "origins": [
        "NYC"
    ],
    "destinations": [
        "LON"
    ],
    "departureDates": [
        "2026-11-20"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("westerly_breaker/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 = {
    "origins": ["NYC"],
    "destinations": ["LON"],
    "departureDates": ["2026-11-20"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("westerly_breaker/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 '{
  "origins": [
    "NYC"
  ],
  "destinations": [
    "LON"
  ],
  "departureDates": [
    "2026-11-20"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call westerly_breaker/google-flights-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,westerly_breaker/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/3ruUSHZCMX5VJUlpg/builds/Yab140XxYIyccnk7I/openapi.json
