serpapi / public-roadmap

Public Roadmap for SerpApi, LLC (https://serpapi.com)
45 stars 3 forks source link

[Google Flights API] Return link to the selected flights page #1488

Open jho406 opened 3 months ago

jho406 commented 3 months ago

At the bookings screen (after you've selected your flights), there's a share button that can be clicked, I'd like to for the API to return the link that appears when the share button is clicked.

Screenshot 2024-03-19 at 1 12 10 PM
tanys123 commented 3 months ago

It is likely we need a new endpoint for this:

curl 'https://www.google.com/_/TravelFrontendUi/data/batchexecute?rpcids=A603Y&source-path=%2Ftravel%2Fflights%2Fbooking&f.sid=9024555003883451653&bl=boq_travel-frontend-ui_20240318.01_p0&hl=en-US&soc-app=162&soc-platform=1&soc-device=1&_reqid=2444454&rt=c' \
  --data-raw 'f.req=%5B%5B%5B%22A603Y%22%2C%22%5B%5C%22https%3A%2F%2Fwww.google.com%2Ftravel%2Fflights%2Fbooking%3Ftfs%3DCAIQAhpEEgoyMDI0LTA0LTE4Ih8KA0tVTBIKMjAyNC0wNC0xOBoDRFBTKgJRWjIDNTU1agwIAhIIL20vMDQ5ZDFyBwgBEgNEUFMaRBIKMjAyNC0wNC0yNCIfCgNEUFMSCjIwMjQtMDQtMjQaA0tVTCoCQUsyAzM3N2oHCAESA0RQU3IMCAISCC9tLzA0OWQxQAFIAXABggELCP___________wGYAQE%26source%3Dflre_fli_share%26utm_campaign%3Dsharing%5C%22%5D%22%2Cnull%2C%22generic%22%5D%5D%5D&' \
  --compressed
jho406 commented 3 months ago

Hmm.... I think what i'm really interested in is getting this URL from the booking page:

Screenshot 2024-03-20 at 9 02 02 AM

Right now, SerpApi returns a google_flights_url in the search_metadata. When used with the booking_token, that url looks like https://www.google.com/travel/flights?hl=en&gl=us&curr=USD&q=Flights+to+AUS+from+CDG+on+2024-03-21+through+2024-03-27. But I would like the API to return a link to the actual booking page as seen on the screenshot.

Would that be a better alternative? Would it make sense for me to close this issue and create a new one?

tanys123 commented 3 months ago

After looking more details into the new endpoint payload, they are actually the same thing. The new endpoint is to retrieve the shortened URL with tracking information.

Thus, we do not need a new endpoint but we have to generate the tfs value (which contains the info of the selected flights). The tfs query is a protobuf byte data encoded in base64, it could be challenging to reverse engineer.

Would that be a better alternative? Would it make sense for me to close this issue and create a new one?

That's fine, we could keep this open. Thanks for the reporting!