[Google Flights API] Convert Location Names to Airport Codes
A customer requested support for converting location names to airport codes.
We might be able to scrape this using Google Flights Autocomplete:
Potentially we could also compile a list or serve these as a separate API, similar to our Locations API or Walmart Stores Locations.
Potentially we could also get kgmids from the Wikidata Rest API. I've suggested that as a workaround for the customer.
Intercom | Wikidata Rest API
One way to convert a city name to IATA code is using our Google answer box API. We can use this as a temporary suggestion to a customer.
Here is an example: Playground: search for airport code for Beirut
Another user requested this:
For context, the user was trying to perform a search using the departure ID BUE. BUE is not actually a specific airport code, but instead a generic code for all Buenos Aires Metropolitan airports (source).
Currently, the Google Flights API does not return any flights for this:
https://serpapi.com/playground?engine=google_flights&departure_id=BUE&arrival_id=PDX¤cy=USD&outbound_date=2024-12-30&return_date=2025-01-17&adults=2
Opening the google_flights_url returns flights in Google:
https://www.google.com/travel/flights?hl=en&gl=us&curr=USD&tfs=CBwQAhoeEgoyMDI0LTEyLTMwagcIARIDQlVFcgcIARIDUERYGh4SCjIwMjUtMDEtMTdqBwgBEgNQRFhyBwgBEgNCVUVCAgEBSAFwAZgBAQ==
Typing BUE into Google Flights returns Buenos Aires, Argentina (or the equivalent of the location kgmid).
As @schaferyan suggested, using data from a Google Flights Autocomplete API would likely resolve this user's issue.