Google Flights Scraper API
Get Google Flights results as JSON with one HTTP request. The Google Flights Scraper API searches one-way and round-trip flights and returns each offer’s price, airlines, flight numbers, departure and arrival times, duration, stops and emissions, and a calendar endpoint returns the cheapest fare for each date in a range in one call. This repo has runnable Python, Node.js and cURL examples and the real response each one returned.
What does a Google Flights scraper do?
A Google Flights scraper runs a flight search on Google Flights for a route and dates and returns the offers it shows as structured data: price, airlines, flight numbers, times, duration, stops and layovers. Travel apps use it to compare fares, and analysts and travellers to track prices on a route over time. You send two airport codes and a date and get JSON back.
Contents
Quick start
-
Create a free ScrapeBadger account. You get 1,000 free credits, no card needed.
-
Copy your API key from the dashboard and export it:
export SCRAPEBADGER_API_KEY="your_api_key"
-
Make your first request: search round-trip flights.
cURL
curl -sS --max-time 120 -G "https://scrapebadger.com/v1/google/flights/search" \
-H "X-API-Key: $SCRAPEBADGER_API_KEY" \
--data-urlencode 'departure_id=JFK' \
--data-urlencode 'arrival_id=LHR' \
--data-urlencode "outbound_date=$(date -u -d '+45 days' +%F 2>/dev/null || date -u -v+45d +%F)" \
--data-urlencode "return_date=$(date -u -d '+52 days' +%F 2>/dev/null || date -u -v+52d +%F)"
Python (pip install requests)
import json
import os
from datetime import date, timedelta
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/flights/search",
headers={"X-API-Key": API_KEY},
params={
"departure_id": "JFK",
"arrival_id": "LHR",
"outbound_date": (date.today() + timedelta(days=45)).isoformat(),
"return_date": (date.today() + timedelta(days=52)).isoformat(),
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js (18+, no dependencies)
const params = new URLSearchParams({
departure_id: 'JFK',
arrival_id: 'LHR',
outbound_date: new Date(Date.now() + 45 * 864e5).toISOString().slice(0, 10),
return_date: new Date(Date.now() + 52 * 864e5).toISOString().slice(0, 10),
});
const response = await fetch(`https://scrapebadger.com/v1/google/flights/search?${params}`, {
headers: { 'X-API-Key': process.env.SCRAPEBADGER_API_KEY },
signal: AbortSignal.timeout(120000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
Every endpoint below has the same three versions in examples/, and the real response it returned is in output-samples/.
Endpoints
Base URL: https://scrapebadger.com. Authenticate with the X-API-Key header. Credits are charged only for successful requests.
Common parameters
| Parameter |
Description |
Default |
departure_id |
Departure airport IATA code, e.g. JFK. |
|
arrival_id |
Arrival airport IATA code, e.g. LHR. |
|
currency |
Currency for prices (ISO 4217), e.g. USD, EUR. |
USD |
travel_class |
economy, premium_economy, business or first. |
economy |
Examples by endpoint
Each example prints the JSON response. The Python versions are below; Node.js and cURL versions are linked under each one.
Search round-trip flights
Search Google Flights for available itineraries.
GET /v1/google/flights/search · Credits: 20 · Docs
| Parameter |
Required |
Type |
Default |
Description |
departure_id |
Yes |
string |
|
Departure airport IATA code, e.g. JFK |
arrival_id |
Yes |
string |
|
Arrival airport IATA code, e.g. LHR |
outbound_date |
Yes |
string |
|
Departure date, YYYY-MM-DD |
return_date |
|
string |
|
Return date, YYYY-MM-DD (round trips) |
trip_type |
|
string |
round_trip |
round_trip or one_way (search also takes multi_city) |
adults |
|
integer |
1 |
Number of adults |
children |
|
integer |
0 |
Number of children |
infants_in_seat |
|
integer |
0 |
Infants with their own seat |
infants_on_lap |
|
integer |
0 |
Infants on a lap |
travel_class |
|
string |
economy |
economy, premium_economy, business or first |
currency |
|
string |
USD |
Currency for prices, e.g. USD, EUR, GBP |
gl |
|
string |
us |
Country of the search, e.g. us, gb |
hl |
|
string |
en |
Language code, e.g. en |
stops |
|
string |
any |
any, nonstop, one_stop or two_stops |
max_price |
|
integer |
|
Highest price, in currency |
departure_token |
|
string |
|
departure_token of a round-trip offer, to get the return flights for that outbound |
import json
import os
from datetime import date, timedelta
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/flights/search",
headers={"X-API-Key": API_KEY},
params={
"departure_id": "JFK",
"arrival_id": "LHR",
"outbound_date": (date.today() + timedelta(days=45)).isoformat(),
"return_date": (date.today() + timedelta(days=52)).isoformat(),
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (302 KB)
Search one-way nonstop flights
A one-way search from San Francisco to Tokyo Narita, nonstop flights only.
GET /v1/google/flights/search · Credits: 20 · Docs
| Parameter |
Required |
Type |
Default |
Description |
departure_id |
Yes |
string |
|
Departure airport IATA code, e.g. JFK |
arrival_id |
Yes |
string |
|
Arrival airport IATA code, e.g. LHR |
outbound_date |
Yes |
string |
|
Departure date, YYYY-MM-DD |
trip_type |
|
string |
round_trip |
round_trip or one_way (search also takes multi_city) |
stops |
|
string |
any |
any, nonstop, one_stop or two_stops |
max_price |
|
integer |
|
Highest price, in currency |
currency |
|
string |
USD |
Currency for prices, e.g. USD, EUR, GBP |
Plus 9 more parameters in the docs.
import json
import os
from datetime import date, timedelta
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/flights/search",
headers={"X-API-Key": API_KEY},
params={
"departure_id": "SFO",
"arrival_id": "NRT",
"outbound_date": (date.today() + timedelta(days=30)).isoformat(),
"trip_type": "one_way",
"stops": "nonstop",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (10 KB)
Search business class flights
A one-way business class search from London Heathrow to Dubai, priced in pounds for a UK searcher.
GET /v1/google/flights/search · Credits: 20 · Docs
| Parameter |
Required |
Type |
Default |
Description |
departure_id |
Yes |
string |
|
Departure airport IATA code, e.g. JFK |
arrival_id |
Yes |
string |
|
Arrival airport IATA code, e.g. LHR |
outbound_date |
Yes |
string |
|
Departure date, YYYY-MM-DD |
trip_type |
|
string |
round_trip |
round_trip or one_way (search also takes multi_city) |
travel_class |
|
string |
economy |
economy, premium_economy, business or first |
adults |
|
integer |
1 |
Number of adults |
currency |
|
string |
USD |
Currency for prices, e.g. USD, EUR, GBP |
gl |
|
string |
us |
Country of the search, e.g. us, gb |
Plus 8 more parameters in the docs.
import json
import os
from datetime import date, timedelta
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/flights/search",
headers={"X-API-Key": API_KEY},
params={
"departure_id": "LHR",
"arrival_id": "DXB",
"outbound_date": (date.today() + timedelta(days=60)).isoformat(),
"trip_type": "one_way",
"travel_class": "business",
"currency": "GBP",
"gl": "gb",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (333 KB)
Get the cheapest fare per date
Returns the cheapest one-way fare for each departure date in a range, up to 200 dates in one call, and the cheapest date. The prices match the flight search.
GET /v1/google/flights/calendar · Credits: 20
| Parameter |
Required |
Type |
Default |
Description |
departure_id |
Yes |
string |
|
Departure airport IATA code, e.g. JFK |
arrival_id |
Yes |
string |
|
Arrival airport IATA code, e.g. LHR |
outbound_date_from |
Yes |
string |
|
First departure date to price, YYYY-MM-DD |
outbound_date_to |
Yes |
string |
|
Last departure date to price, YYYY-MM-DD (at most 200 days after the first) |
trip_type |
|
string |
one_way |
round_trip or one_way (search also takes multi_city) |
trip_length_days |
|
integer |
|
Nights between departure and return for round trips |
return_date_from |
|
string |
|
Date-grid mode: first return date. With return_date_to, returns the full outbound x return matrix (each range at most 14 days). Round-trip only. |
return_date_to |
|
string |
|
Date-grid mode: last return date |
adults |
|
integer |
1 |
Number of adults |
children |
|
integer |
0 |
Number of children |
infants_in_seat |
|
integer |
0 |
Infants with their own seat |
infants_on_lap |
|
integer |
0 |
Infants on a lap |
travel_class |
|
string |
economy |
economy, premium_economy, business or first |
currency |
|
string |
USD |
Currency for prices, e.g. USD, EUR, GBP |
gl |
|
string |
us |
Country of the search, e.g. us, gb |
hl |
|
string |
en |
Language code, e.g. en |
import json
import os
from datetime import date, timedelta
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/flights/calendar",
headers={"X-API-Key": API_KEY},
params={
"departure_id": "JFK",
"arrival_id": "LAX",
"outbound_date_from": (date.today() + timedelta(days=14)).isoformat(),
"outbound_date_to": (date.today() + timedelta(days=74)).isoformat(),
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (24 KB)
Get the cheapest round-trip fare per date
The same calendar for round trips of a fixed length (trip_length_days), here 5 nights from Boston to Miami.
GET /v1/google/flights/calendar · Credits: 20
| Parameter |
Required |
Type |
Default |
Description |
departure_id |
Yes |
string |
|
Departure airport IATA code, e.g. JFK |
arrival_id |
Yes |
string |
|
Arrival airport IATA code, e.g. LHR |
outbound_date_from |
Yes |
string |
|
First departure date to price, YYYY-MM-DD |
outbound_date_to |
Yes |
string |
|
Last departure date to price, YYYY-MM-DD (at most 200 days after the first) |
trip_type |
|
string |
one_way |
round_trip or one_way (search also takes multi_city) |
trip_length_days |
|
integer |
|
Nights between departure and return for round trips |
return_date_from |
|
string |
|
Date-grid mode: first return date. With return_date_to, returns the full outbound x return matrix (each range at most 14 days). Round-trip only. |
return_date_to |
|
string |
|
Date-grid mode: last return date |
currency |
|
string |
USD |
Currency for prices, e.g. USD, EUR, GBP |
Plus 7 more parameters.
import json
import os
from datetime import date, timedelta
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/flights/calendar",
headers={"X-API-Key": API_KEY},
params={
"departure_id": "BOS",
"arrival_id": "MIA",
"outbound_date_from": (date.today() + timedelta(days=20)).isoformat(),
"outbound_date_to": (date.today() + timedelta(days=50)).isoformat(),
"trip_type": "round_trip",
"trip_length_days": 5,
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (14 KB)
Example output
A real response from GET /v1/google/flights/search, trimmed to the first items of each list. The full response is in output-samples/search.json.
{
"best_flights": [
{
"legs": [
{
"departure_airport": "JFK",
"departure_airport_name": "John F. Kennedy International Airport",
"departure_time": "2027-01-16T18:25",
"arrival_airport": "LHR",
"arrival_airport_name": "Heathrow Airport",
"arrival_time": "2027-01-17T06:20",
"duration_minutes": 415,
"airline": "American",
"airline_logo": null,
"flight_number": "AA 100",
"aircraft": "Boeing 777",
"travel_class": "economy",
"legroom": "31 in",
"extensions": [
"Average legroom (31 in)"
],
"overnight": true,
"often_delayed_by_over_30_min": false,
"plane_and_crew_by": null,
"ticket_also_sold_by": [
"Iberia"
]
}
],
"layovers": [],
"total_duration_minutes": 415,
"price": 622.0,
"currency": "USD",
"price_type": "total",
"booking_token": "CjRIVlpPZ3VkZXNzQklBQVZObWdCRy0tLS0tLS0tbG1iZ2s0MEFBQUFBR3NQWVk0Slc1MVlBEgVBQTEwMBoLCJ3lAxACGgNVU0Q4HHCd5QM=",
"booking_url": "https://www.google.com/travel/flights/search?tfs=CBwQAho_EgoyMDI3LTAxLTE2Ih8KA0pGSxIKMjAyNy0wMS0xNhoDTEhSKgJBQTIDMTAwagcIARIDSkZLcgcIARIDTEhSGh4SCjIwMjctMDEtMjNqBwgBEgNMSFJyBwgBEgNKRktAAUgBcAGCAQsI____________AZgBAQ&hl=e…",
"selection_token": "CBwQAho_EgoyMDI3LTAxLTE2Ih8KA0pGSxIKMjAyNy0wMS0xNhoDTEhSKgJBQTIDMTAwagcIARIDSkZLcgcIARIDTEhSGh4SCjIwMjctMDEtMjNqBwgBEgNMSFJyBwgBEgNKRktAAUgBcAGCAQsI____________AZgBAQ",
"departure_token": "CBwQAho_EgoyMDI3LTAxLTE2Ih8KA0pGSxIKMjAyNy0wMS0xNhoDTEhSKgJBQTIDMTAwagcIARIDSkZLcgcIARIDTEhSGh4SCjIwMjctMDEtMjNqBwgBEgNMSFJyBwgBEgNKRktAAUgBcAGCAQsI____________AZgBAQ",
"carbon_emissions_grams": 446000,
"carbon_emissions_diff_typical": 15000,
"airline_logo": null,
"extensions": [
"Iberia"
]
}
],
"other_flights": [
{
"legs": [
{
"departure_airport": "JFK",
"departure_airport_name": "John F. Kennedy International Airport",
"departure_time": "2027-01-16T09:33",
"arrival_airport": "LHR",
"arrival_airport_name": "Heathrow Airport",
"arrival_time": "2027-01-16T21:40",
"duration_minutes": 427,
"airline": "JetBlue",
"airline_logo": null,
"flight_number": "B6 1107",
…
Use it with AI agents (MCP)
ScrapeBadger runs a hosted MCP server, so Claude, Cursor, ChatGPT and other agents can call the Google Flights endpoints as tools, with no code.
- Claude (claude.ai or Claude Desktop): Settings → Connectors → Add custom connector →
https://mcp.scrapebadger.com/mcp, then sign in. No API key needed.
- Cursor, VS Code, Windsurf and other clients: add this server to your MCP config:
{
"mcpServers": {
"scrapebadger": {
"url": "https://mcp.scrapebadger.com/mcp?apis=google",
"headers": { "Authorization": "Bearer YOUR_SCRAPEBADGER_API_KEY" }
}
}
}
Then ask:
Find the cheapest day to fly from New York to Los Angeles in the next two months on Google Flights, then list the nonstop options on that day with their prices.
Setup guides for each client are in the MCP docs.
Use cases
| Use case |
What you collect |
Endpoints |
| Fare tracking |
The price of a route and dates over time, to alert when it drops |
Search round-trip flights, Get the cheapest fare per date |
| Cheapest dates |
The lowest fare for every day in a range, one-way or round trip |
Get the cheapest fare per date, Get the cheapest round-trip fare per date |
| Travel apps and agents |
Flight options with times, stops and prices for a trip, as JSON for an app or AI agent |
Search round-trip flights, Search one-way nonstop flights |
| Airline and route analysis |
Which airlines fly a route, nonstop or not, in each cabin, and at what price |
Search one-way nonstop flights, Search business class flights |
Pricing
- Each endpoint’s credit cost is listed in the endpoints table.
- Only successful requests are billed. Blocked, empty and failed results cost nothing.
- New accounts get 1,000 free credits. After that, pay as you go or pick a monthly plan. Credits on pay-as-you-go never expire.
See ScrapeBadger pricing for the price per credit on each plan.
Errors
Errors come back as JSON with a detail field (and an error code on some).
| Status |
Meaning |
What to do |
400 / 422 |
A parameter is missing or invalid |
Check the parameter table for the endpoint |
401 |
Missing, invalid or expired API key |
Send the key in the X-API-Key header |
402 |
Out of credits |
Top up or upgrade in the dashboard |
403 |
The key can’t call this API, or the request came from an IP the key doesn’t allow |
Check the key’s scopes and IP allowlist |
404 |
The item, page or profile doesn’t exist (or is no longer public) |
Check the ID; not billed |
429 |
Over your account’s max concurrency |
Wait Retry-After (1 s) and retry; run fewer calls in parallel (concurrency) |
502 / 503 / 504 |
The target site failed or timed out on this attempt |
Not billed. Retry with backoff |
Long calls can run asynchronously: send Prefer: respond-async and poll the returned request_id (async requests).
FAQ
Is it legal to scrape Google Flights?
Flight prices and schedules on Google Flights are public, and collecting public data is generally lawful in most jurisdictions. Check the rules that apply to your use case and ask a lawyer if you’re unsure.
What does the price include?
price is the price as Google Flights shows it: the total for all passengers, including mandatory taxes and fees, without optional extras such as checked bags. For a round trip, each offer lists the outbound flights and the lowest round-trip total with that outbound. The calendar’s prices match the search’s.
How much does it cost?
Each request costs a fixed number of credits, shown in the endpoints table, and only successful requests are billed. A calendar call prices up to 200 dates for one request. You get 1,000 free credits when you sign up, then pay as you go or pick a plan on the pricing page.
Which routes, currencies and countries are supported?
Any route Google Flights covers: pass airport IATA codes in departure_id and arrival_id. Set currency for prices and gl and hl for the country and language of the search.
How fast is it, and are there rate limits?
Half of all flight searches and fare calendars answer in about a second, and almost all searches within 8 seconds. There’s no per-minute cap: you can run as many requests in parallel as your plan’s max concurrency allows, and a request over it gets 429 without being billed.
Other languages
These examples use plain HTTP. Official SDKs wrap every endpoint with types and retries:
There is also a CLI (pip install scrapebadger-cli) and an n8n node.
Learn more
Disclaimer
ScrapeBadger is an independent tool and is not affiliated with, endorsed by, or sponsored by Google LLC or any of its subsidiaries or affiliates. “Google” and “Google Flights” are trademarks of Google LLC, used here only to describe the platform this scraper works with. This repository only covers publicly available data. You are responsible for how you use the data you collect and for following the laws that apply to you.
License
MIT. The examples are free to copy into your own projects.
评论