How to Track Flights Between Airports With Google Sheet and FlightAPI
If you’re managing travel logistics, coordinating shipments, running a travel agency, or overseeing business operations where tracking flights between airports is needed. This tutorial is built for you.
In this tutorial, we’ll show you exactly how to create a simple tool to track flights between airports using Google Sheets and FlightAPI. No code, no tech headaches. Just a fully functional solution you can build from scratch and start using today.
Moreover, at the end of the tutorial, you will also get a ready-made blueprint. You can download it, plug in your details, and start pulling live flight data in minutes.
What You’ll Need:
- FlightAPI account
- Google Spreadsheet access
Step 1: Get Your API Key
- Head over to FlightAPI and sign up for a new account.
- Check your inbox and verify your email address.
- Once you’re in, go to your dashboard — your API key will be waiting for you there.
(In a free account, you will get 50 credits. Using the flight tracking between airport API costs 1 credit per response, which is pretty good for testing purposes. For more credits, you can upgrade your account as per your needs.)
Step 2: Prepare Your Spreadsheet
Before you set up your spreadsheet, you’ll want to review the API documentation here: Track Flights Between Airports API. This will show you which parameters you’ll need to send and what kind of data you’ll get back.
Now, based on that information, let’s set up two tabs in Google Sheets: Input and Output.
In the “Input” sheet:
You’ll create a simple table where you’ll add the details of the flights you want to track.
Here’s what you need:
- Departure Airport Code
- Arrival Airport Code
- Departure Date
In the “Output” sheet:
This is where the magic happens. This tab will show the flight data pulled directly from FlightAPI.
Here are the columns to include:
- Departure Airport
- Arrival Airport
- Departure Date
- Airline
- Flight Number
- Status
- Operated By
- Departure Time
- Arrival Time
Step 3: Edit Apps Script and Run It
With your spreadsheet ready, it’s time to make things work behind the scenes. This step will automate the process — pulling data from your Input sheet (your API parameters) and placing the results into the Output sheet.
Here’s what to do:
- In your Google Sheet, click on Extensions in the top menu.
- Select Apps Script from the dropdown.
- In the new tab that opens, you’ll see a file called Code.gs.
- Delete any existing code you see there — clear it out completely.
- Now, copy and paste the script provided below into the Code.gs file.
function fetchFlightData() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var inputSheet = ss.getSheetByName("Input");
var outputSheet = ss.getSheetByName("Output");
var apiKey = "your_api_key";
// Get input data starting from row 2 (skip header)
var inputData = inputSheet.getRange("A2:C" + inputSheet.getLastRow()).getValues();
// Loop through each row in the input
inputData.forEach(function(row, index) {
var departureCode = row[0]; // Column A
var arrivalCode = row[1]; // Column B
var departureDate = new Date(row[2]); // Column C
// Format date to YYYYMMDD
var formattedDate = Utilities.formatDate(departureDate, ss.getSpreadsheetTimeZone(), "yyyyMMdd");
// Construct API URL with API key in the path
var url = "https://api.flightapi.io/trackbyroute/" + apiKey +
"?date=" + formattedDate +
"&airport1=" + departureCode +
"&airport2=" + arrivalCode;
try {
// Fetch API response
var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true });
var json = JSON.parse(response.getContentText());
// Clear previous data for this row
outputSheet.getRange(index + 2, 1, 1, 9).clearContent();
// Write input data to columns A-C in the output sheet
outputSheet.getRange(index + 2, 1, 1, 3).setValues([row]);
if (json && json.length > 0) {
// Take the first flight from the response
var firstFlight = json[0];
var outputRow = [
firstFlight.Airline || "N/A",
firstFlight.FlightNumber || "N/A",
firstFlight.Status || "N/A",
firstFlight["Operated By"] || "N/A",
firstFlight.DepartureTime || "N/A",
firstFlight.ArrivalTime || "N/A"
];
// Write to output sheet (columns D-I)
outputSheet.getRange(index + 2, 4, 1, 6).setValues([outputRow]);
} else {
outputSheet.getRange(index + 2, 4, 1, 6).setValues([["No flights found", "", "", "", "", ""]]);
}
} catch (e) {
Logger.log("Error for row " + (index + 2) + ": " + e.toString());
outputSheet.getRange(index + 2, 4, 1, 6).setValues([["API Error", "", "", "", "", ""]]);
}
// Add delay to avoid rate limiting (reduced to 500ms)
Utilities.sleep(500);
});
// Apply uniform formatting to the output sheet
formatOutputSheet(outputSheet);
}
function formatOutputSheet(sheet) {
// Clear all bold formatting
sheet.getDataRange().setFontWeight("normal");
// Align all text to the left
sheet.getDataRange().setHorizontalAlignment("left");
// Set uniform font style and size
sheet.getDataRange().setFontFamily("Arial").setFontSize(10);
// Set header row to bold
sheet.getRange("A1:I1").setFontWeight("bold");
// Auto-resize columns to fit content
sheet.autoResizeColumns(1, 9);
}
6. In the script you just pasted, look for the placeholder text “your_api_key”. Delete “your_api_key” and replace it with your actual API key from the FlightAPI dashboard. This will authenticate your requests and allow the script to fetch live flight data.
7. After updating your API key, click Save (the floppy disk icon) in the Apps Script editor.
8. Next, hit Run from the toolbar.
The first time you run the script, Google will pop up a permissions window asking you to authorize the script to access your Google Sheet. This is standard when using Apps Script to automate tasks.
- Click Review Permissions.
- Choose your Google account.
- Then, click Allow to give the script permission to read and write to your spreadsheet.
9. Head back to your spreadsheet and check the Output tab — you’ll now see the live flight data neatly organized into columns. The tool will pull flight details like airline, flight number, status, times, and more, all arranged and ready for you to use.
Get Your Ready-to-Use Blueprint
If you’d rather skip building the tracker from scratch, we’ve got you covered.
Click the link below to access the Google Sheet template. Simply make a copy, enter your flight details in the Input tab, insert your API key into the Apps Script (as outlined in this guide), and run it. You’ll be ready to start pulling flight data in no time.
👉 Download Your Flight Tracker Template
Wrapping Up
You’ve now got a working flight tracking tool inside Google Sheets — no coding headaches, no extra software, just simple automation using FlightAPI. Whether you’re managing travel operations, tracking cargo movements, or supporting customer travel needs, this setup saves time and delivers real-time flight data exactly where you need it.
If you’re looking to extend your automation even further, check out these resources. You might need more than just flight tracking down the line — from real-time schedules to broader data sets, these guides have you covered:
- Explore the list of travel APIs to enhance your operations.
- Check out flight status APIs for deeper integration and automation options.