Skip to content

About

Python workflow example for retrieving structured Google Flights SERP data for travel research and flight comparison.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TalorData Google Flights SERP API for Python

TalorData Google Flights SERP API

TalorData SERP API helps you retrieve structured Google Flights SERP data through a Python workflow for travel market research, route monitoring, fare intelligence, competitor analysis, AI applications, and travel intelligence. The workflow extracts key result fields, including flight prices, airlines, routes, and departure times, so you can use the data in travel dashboards, fare monitoring reports, AI agents, data pipelines, and automation workflows.

TalorData Google Flights SERP

Prerequisites

To run this tool, you need Python 3.11 or newer and a TalorData SERP token.

Get your API key:Sign up at TalorData and get your API key from the dashboard.

Installation

python -m pip install poetry==1.8.2

poetry install

Getting the Google Flights input

This tool collects Google Flights results through TalorData SERP API. Provide departure_id, arrival_id, and outbound_date; add return_date for round trips.

The local Google Flights SERP preview looks like this:

Google Flights SERP page preview

The TalorData request parameters are summarized here:

TalorData Google Flights input example

Running the SERP request

Set your TalorData token first. Choose the command for your terminal.

On Windows Command Prompt:

set TALORDATA_SERP_API_TOKEN=<your_talordata_serp_token>

echo %TALORDATA_SERP_API_TOKEN%

On Windows PowerShell:

$env:TALORDATA_SERP_API_TOKEN="<your_talordata_serp_token>"

$env:TALORDATA_SERP_API_TOKEN

On macOS or Linux:

export TALORDATA_SERP_API_TOKEN=<your_talordata_serp_token>

echo "$TALORDATA_SERP_API_TOKEN"

Run a request:

poetry run talordata-google-flights-serp \
  --departure-id "HKG" \
  --arrival-id "LAS" \
  --outbound-date "2026-07-10" \
  --return-date "2026-07-13" \
  --output flights.json

To write a CSV file instead:

poetry run talordata-google-flights-serp \
  --departure-id "HKG" \
  --arrival-id "LAS" \
  --outbound-date "2026-07-10" \
  --return-date "2026-07-13" \
  --output flights.csv \
  --format csv

After running the command, the terminal output should look similar to this:

TalorData Google Flights terminal output

When the tool finishes, you should see a flights.json or flights.csv file in the directory where you ran it.

If you choose CSV, open flights.csv in Excel, Google Sheets, or any text editor. It should have these columns:

best,airline,price,total_duration,stops,carbon_emissions,departure_airport,arrival_airport,departure_time,arrival_time,flight_numbers,segments,booking_token,rank
True,United,$740,"17 hr 5 min",1,629000,HKG,LAS,"2026-7-10 11:45","2026-7-10 13:50","UA862 | UA2449","UA862: HKG 2026-7-10 11:45 -> SFO 2026-7-10 9:50 | UA2449: SFO 2026-7-10 12:00 -> LAS 2026-7-10 13:50","abc123",1

A generated CSV preview looks like this:

TalorData Google Flights CSV output

Each CSV row is one flight option. The segments column keeps the route readable for connecting flights, while JSON keeps the full nested response if you need every raw field.

Notes

This project does not fetch Google Flights HTML directly. TalorData SERP API handles upstream fetching, request routing, parsing, and structured JSON output.

TalorData Google Flights SERP API

TalorData Google Flights SERP API returns structured flight options such as prices, airlines, airport IDs, departure and arrival times, durations, and route details.

Request sample

The same API request is shown here as a quick visual reference:

import os
import requests

payload = {
    "engine": "google_flights",
    "departure_id": "HKG",
    "arrival_id": "LAS",
    "outbound_date": "2026-07-10",
    "return_date": "2026-07-13",
    "json": "2",
    "output_format": "json",
}

response = requests.post(
    "https://serpapi.talordata.net/serp/v1/request",
    headers={"Authorization": f"Bearer {os.environ['TALORDATA_SERP_API_TOKEN']}"},
    data=payload,
    timeout=30,
)
print(response.json())

Learn more

Explore TalorData SERP API integrations and use cases:

Quick Start

View Documentation

About

Python workflow example for retrieving structured Google Flights SERP data for travel research and flight comparison.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages