[Google Flights API] Missing booking options compared to actual Google Flights
A user reported a flight search where we only returned 1 booking option whereas the same search in actual Google Flights returned several.
Google Flights API:
Actual Google Flights:
Public links: Playground
Internal links: Intercom | Search Inspect
I have researched the above query and with the current Google Flights implementation we won't be able to support that. We will need some significant change in the scraping approach in order to make it work.
tldr:
- Google Flights API is currently stateless and does not support session management across requests
- That prevents Google from matching OTAs to the session
Detailed description:
- To each session google assigns a session identifier
f.sid, this identifier determines the user's details (likely location, preferences, etc.) - The gathered information is then used to match to certain OTAs (online travel agencies). Different OTAs have different location limits where they are supported, languages they work in, etc. So if you make 1 query to a given flight from region X, you will see one set of OTAs, if you query it from another, you could get a completely different set of OTAs.
- In order to get the OTA you need to generate session IDs and track sessions, so that every Google Flights request has a session ID attached to it.
You can reproduce this behaviour by opening a new tab and making a request to the booking details. Google Flights won't return any OTAs on the first request. Only if you retry the request in the same window, then it will show the OTAs (specific to your location / session). So in order to enable the OTAs we will need to re-engineer the Google Flights to manage the state, maybe something similar to how GoogleTokens are computed, and then use those session IDs properly. It also could be hard to implement, because it seems OTAs are tied to location of the first request, so afaik you'll need to tag those session IDs with location and match to them to what the user queries.
I think at this point we want to evaluate about how important this feature request is and if we want to invest the effort to re-structure the Google Flights to make it a stateful service (which will increase likely maintenance costs too).
Screen from incognito request:
Another report: Intercom
This example is very similar to the previous example. However in this case there were only 2 results through our APIs then in the browser (on the first load of a new incognito window) there was more immediately. Does this change what you saw previously @vladm-serpapi?
Another report: Intercom
This example is very similar to the previous example. However in this case there were only 2 results through our APIs then in the browser (on the first load of a new incognito window) there was more immediately. Does this change what you saw previously @vladm-serpapi?
Sorry for the late reply here, been prioritizing some other work. I will re-check the error again tomorrow and see if anything changed since the last update, as we have merged quite a few PRs since then.