Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to access flights information in GMail API?

When you buy a flight and receive a confirmation email, GMail recognizes it's a flight and adds departure/return tabs at the top of the message.

Using GMail API, I would like to use that information to get all flights from my inbox. Is this possible?

like image 995
SteakOverflow Avatar asked Sep 14 '25 01:09

SteakOverflow


1 Answers

Content that is outside the message body of an email is not accessible from the GMail API. So you won't be able to access the info in any auto-generated tabs.

However, GMail may have auto-labeled the messages as "Travel". If that's the case then you can leverage the GMail API to filter messages using the "Travel" label.

You'll then have to parse the email message for the desired information.

Writing a custom parser can be difficult. However, if the message is annotated so that it conforms to specifications outlined by Google and Schema.org, parsing flight information will be considerably easier. One can assume that flight confirmation messages that trigger the auto-generation of those tabs have flight/reservation specific mark-up embedded within them (but you should probably verify that the email contains said mark-up all the same).

The following links discuss how vendors should embed these special mark-up into their messages: https://developers.google.com/gmail/markup/getting-started https://developers.google.com/gmail/markup/reference/flight-reservation#basic_flight_confirmation

You should be able to use those docs to build a custom parser that can detect and parse the required mark-up schema or better yet leverage an open-source library to do so.

like image 69
TheAddonDepot Avatar answered Sep 16 '25 07:09

TheAddonDepot