SerpApi Official icon

SerpApi Official

Get live Google Search data and more from SerpApi's official node

Overview

The node provides an interface to perform live flight searches using Google Flights data via the SerpApi service. It allows users to query flight information such as departure and arrival airports, dates, flight types (round trip, one way, multi-city), travel class, number of passengers, and various filters like airlines, stops, price limits, and sorting preferences.

This node is beneficial for travel agencies, booking platforms, or any application that needs to fetch up-to-date flight options programmatically without scraping Google Flights manually. For example, a travel app can use this node to display available flights between two cities on specified dates, filter by preferred airlines, or sort results by price or duration.

Properties

Name Meaning
Departure airport code / location kgmid (departure_id) Defines the departure airport(s) using 3-letter IATA codes or location kgmids (starting with /m/). Multiple entries can be comma-separated. Default: "AUS".
Arrival airport code / location kgmid (arrival_id) Defines the arrival airport(s) using 3-letter IATA codes or location kgmids. Multiple entries can be comma-separated. Default: "CDG".
Outbound Date (outbound_date) The outbound flight date in YYYY-MM-DD format (e.g., 2025-03-14).
Return Date (return_date) The return flight date in YYYY-MM-DD format (required if flight type is round trip).
Flight Type (type) Type of flight search: Round trip (1), One way (2), Multi-city (3). For multi-city, use multi_city_json to specify details. Default: Round trip (1).
Additional Fields Collection of optional parameters including:
- Country (gl) Country code to localize the search (e.g., "us", "fr"). Default: "us".
- Language (hl) Language code for the search results (e.g., "en" for English). Default: "en".
- Currency (currency) Currency code for prices (e.g., "USD", "EUR"). Default: "USD".
- Travel Class (travel_class) Travel class: Economy (1), Premium economy (2), Business (3), First (4). Default: Economy (1).
- Parameters for Multi-city (multi_city_json) JSON string defining multiple flight legs with required fields: departure_id, arrival_id, date, and optional time ranges.
- Show hidden results (show_hidden) Boolean to include hidden flight results. Default: false.
- Deep search (deep_search) Boolean to enable deep search for more comprehensive results but longer response times. Default: false.
- Number of Adults (adults) Number of adult passengers. Default: 1.
- Number of Children (children) Number of child passengers. Default: 0.
- Number of Infants in seat (infants_in_seat) Number of infants occupying seats. Default: 0.
- Number of Infants on lap (infants_on_lap) Number of infants on laps. Default: 0.
- Sort By (sort_by) Sorting order of results: Top flights (1), Price (2), Departure time (3), Arrival time (4), Duration (5), Emissions (6). Default: Top flights (1).
- Stops (stops) Number of stops allowed: Any (0), Nonstop only (1), 1 stop or fewer (2), 2 stops or fewer (3). Default: Any (0).
- Exclude airlines (exclude_airlines) Comma-separated airline codes or alliance names to exclude from results. Cannot be used with include_airlines.
- Include airlines (include_airlines) Comma-separated airline codes or alliance names to include. Cannot be used with exclude_airlines.
- Bags (bags) Number of carry-on bags. Default: 0.
- Max price (max_price) Maximum ticket price limit. Default: "unlimited".
- Outbound times (outbound_times) Time range filter for outbound flights (see SerpApi docs for format).
- Return times (return_times) Time range filter for return flights.
- Emissions (emissions) Filter for emission levels; currently supports "Less emissions only" (1). Default: 1.
- Layover duration (layover_duration) Layover duration range in minutes (e.g., "90,330" for 1.5 to 5.5 hours).
- Exclude connecting airports (exclude_conns) Comma-separated list of connecting airport codes to exclude.
- Max duration (max_duration) Maximum total flight duration in minutes (e.g., 1500 for 25 hours).
- Departure flight token (departure_token) Token to select a specific flight and get returning flights or next leg flights. Cannot be used with booking_token.
- Booking token (booking_token) Token to get booking options for selected flights. Cannot be used with departure_token.
- Disable Caching (no_cache) Boolean to force fresh results instead of cached ones. Default: false.
- Async (async) Boolean to perform asynchronous search submission. Requires separate retrieval of results later. Default: false.
- ZeroTrace Mode (zero_trace) Enterprise-only mode to skip storing search metadata on servers. Default: false.
- Output (output) Format of output: JSON (default) or raw HTML. Default: JSON.
- JSON Restrictor (json_restrictor) Restricts returned JSON fields to specified paths (e.g., organic_results[0:3].{title,snippet}).

Output

The node outputs a structured JSON object containing the flight search results returned by the SerpApi Google Flights engine. This includes detailed flight information such as itineraries, prices, airlines, timings, stops, and booking tokens.

If the output parameter is set to "html," the node returns the raw HTML content retrieved from the search instead of JSON.

No binary data output is indicated for this operation.

Dependencies

  • Requires an active API key credential for SerpApi to authenticate requests.
  • Internet access to call the SerpApi endpoint at https://serpapi.com/search.json.
  • Proper configuration of the API key credential within n8n.

Troubleshooting

  • Missing or invalid API key: The node will fail if the SerpApi API key is not provided or invalid. Ensure the API key credential is correctly configured.
  • Invalid date formats: Dates must be in YYYY-MM-DD format. Incorrect formats may cause errors or no results.
  • Conflicting parameters: Using both include_airlines and exclude_airlines simultaneously will cause errors. Use only one.
  • Missing required parameters: For round-trip flights, return_date is required. Omitting it may result in errors.
  • Async and no_cache conflict: Both cannot be true simultaneously. Set only one to true if needed.
  • Multi-city JSON format errors: When using multi-city flights, ensure multi_city_json is a valid JSON string with required fields.
  • Rate limits or quota exceeded: If the API usage exceeds the allowed quota, requests will fail. Monitor usage accordingly.

Links and References

Discussion