Members of the Cloverly team will use the Cloverly API to offset or avoid the carbon impact of their flights when they travel next week to the IATA Airline Industry Retailing Hackathon in Frankfurt, Germany.
Users of the Cloverly Slack app can green their flights, too. To find out how, click here. To see the documentation of the ability to offset air travel directly with our API, click here. For more details of how it works, read on.
Our flight endpoint calculates the typical fuel burn per passenger on a typical flight of that distance. Thus, the API requests require a distance. But when dealing with flights, people don’t typically talk distance. They talk departure and arrival airports. So we broke down the API to accept IATA airport codes (short codes). An example cURL command of a flight leaving SFO (San Francisco) and arriving at ATL (Atlanta) is below:
Given that there are often connecting flights, we knew the array may be longer. Below is an example of a flight leaving SFO, connecting at ATL, and heading to Frankfurt (FRA):
Thus, in a single command, you could calculate how to offset a round trip from SFO -> ATL -> FRA -> ATL -> SFO:
Getting excited about data structures and API design
Our tech team got incredibly excited about the array structure for transmitting flight data (so much so that they asked that we include it in our blog). The team at first looked at ways to do “departure” and “arrival” codes, but then suggested multiple API calls for connecting flights. At that point, someone said, “Why not an array?” Everyone agreed that the array data structure provided the easiest, most fluid description of the trip.
Long story short, we nerd out on data structures and API design.