How to Get Airport Departures and Arrivals with an API
If you are building an arrivals or departures display for John F. Kennedy International Airport, you need to turn flight records into a board that stays useful as times and gates change. JFK is in New York, United States; its ICAO code is KJFK. This guide shows how to interpret JFK flight data, process a tracking response and design the update logic for a reliable display.
Choose the data for a JFK board
Use flight schedules to establish the planned movements on a board, and real-time tracking data to update the operational details available for individual flights. A scheduled time answers when a flight was planned to leave or arrive; it should not be presented as proof that the movement occurred.
For a JFK departure, look for JFK in the flight’s departure airport. For an arrival, look for it in the arrival airport. Keep these directions separate in your application: the departure terminal and gate belong to the origin, while the arrival terminal and gate belong to the destination.
| Data | Response fields | Use on a JFK board |
|---|---|---|
| Flight identity | flight.iata, flight.icao, flight.number |
Identify the flight and distinguish the displayed designator from the numeric portion. |
| Direction | departure.airport, arrival.airport |
Decide whether JFK is the departure or arrival airport. |
| Operational state | flight.status |
Display the returned status alongside the time, rather than inferring it from the clock. |
| Times | scheduled, actual, estimated |
Show planned and available operational times with clear labels. |
| Location in the airport | terminal, gate |
Show the terminal and gate associated with the JFK side of the flight. |
The supplied tracking example uses en-route as a status and includes a JFK departure. Treat example values as illustrations, not as current operating information. A schedule response and a tracking response also have different structures: the schedule example uses data.schedules, while the tracking example uses data.flight.
Retrieve and process a tracking response
Before making the request, use the Documentation to check the current request URL, API-key authentication, airport filtering and pagination syntax. Keep the API key on your server rather than embedding it in a public airport display.
The following Python example starts after an authenticated request has returned JSON. It reads the real-time response from standard input, checks whether JFK is the departure or arrival airport, and prints the fields relevant to that side of the flight. It deliberately leaves the HTTP request separate so you can use the documented request syntax for your integration.
import json
import sys
from datetime import datetime
from zoneinfo import ZoneInfo
AIRPORT = "JFK"
LOCAL_ZONE = ZoneInfo("America/New_York")
def local_time(value):
if not value:
return "not available"
try:
parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
except ValueError:
return "unrecognized timestamp"
if parsed.tzinfo is None:
return "timezone not specified"
return parsed.astimezone(LOCAL_ZONE).isoformat()
def show_side(label, side):
print(label)
print(" Airport:", side.get("airport") or "not available")
print(" Scheduled:", local_time(side.get("scheduled")))
print(" Actual:", local_time(side.get("actual")))
print(" Estimated:", local_time(side.get("estimated")))
print(" Terminal:", side.get("terminal") or "not available")
print(" Gate:", side.get("gate") or "not available")
def main():
response = json.load(sys.stdin)
if response.get("success") is not True:
raise SystemExit("The response did not indicate success.")
data = response.get("data") or dict()
flight = data.get("flight") or dict()
departure = flight.get("departure") or dict()
arrival = flight.get("arrival") or dict()
print("Flight:", flight.get("iata") or "not available")
print("Status:", flight.get("status") or "not available")
if departure.get("airport") == AIRPORT:
show_side("JFK departure", departure)
if arrival.get("airport") == AIRPORT:
show_side("JFK arrival", arrival)
if departure.get("airport") != AIRPORT and arrival.get("airport") != AIRPORT:
print("This response does not identify JFK as either airport.")
if __name__ == "__main__":
main()
Supply the response body from your API client on standard input. The script expects the tracking response shape, not the schedules array. In production, also handle HTTP errors, invalid JSON and unexpected response types before updating a display.
The supplied example includes success, data.flight, a flight designator, status, and departure and arrival objects. Its JFK departure has a scheduled time, an actual time, a terminal and a gate. Those fields are enough to illustrate a departure row, but their presence in an example does not guarantee that every response will contain them.
Display times without losing their meaning
JFK’s airport information identifies its time zone as America/New_York. The sample flight timestamps end in Z, indicating UTC. Parse those timestamps as timezone-aware values, retain the original UTC value for storage and comparisons, and convert to the airport’s local time for a passenger-facing JFK board.
Use a time-zone database rather than a fixed UTC offset, because New York’s offset changes with daylight saving time. Include a local date where a converted flight time could otherwise be mistaken for a different day. For integrations that serve users elsewhere, make the displayed time zone explicit.
Keep the labels distinct. scheduled is the planned time, estimated is an estimate, and actual records a reported actual time. An absent actual time does not by itself mean a flight is late or cancelled. Likewise, do not replace a scheduled time with an estimate without retaining enough information to explain the change.
If both a scheduled and an estimated or actual time are available, your application can calculate a difference after parsing them into timezone-aware instants. Label that result as a calculation and keep the underlying times available. The supplied tracking example does not define a separate delay field or its units.
Keep the board current
Polling frequency is a trade-off between freshness and request usage. Choose an interval appropriate to the display and your FlightLabs plan, cache the most recent successful result, and share that cache across viewers rather than making a separate API request for every screen or browser refresh. Check the current plan and API guidance before setting the interval.
Record when your application last successfully refreshed the data. If a request fails, you can temporarily serve the cached board with a visible last-updated indicator instead of silently presenting old data as live. Avoid overwriting a good cached response with an error or an incomplete parse.
Handle status as returned data, not as a value inferred solely from times. If a flight is reported as cancelled, preserve the scheduled entry and show its reported state rather than removing it without explanation. For a reported diversion, surface the information the response actually provides; the fields shown here do not define a dedicated diversion indicator or explain how a changed destination is represented.
Terminals and gates can also change. Update them from fresh responses, but treat missing values as unknown rather than displaying an empty value as a confirmed assignment. The same applies to an estimate that disappears or has not yet been supplied.
Build practical JFK workflows
Arrival and departure boards
Build separate views by checking arrival.airport and departure.airport for JFK. Show flight.iata, flight.status, the relevant scheduled time and any available terminal or gate. When an estimate or actual time is present, show it with its own label so viewers can distinguish it from the original plan.
Change and delay alerts
Compare successive successful observations for the same flight. Changes to status, estimated, terminal or gate can be useful triggers, provided the relevant field is present. Send an alert only after you have defined how your application distinguishes a genuine change from a previously missing value becoming available.
The supplied fields do not include codeshare details. If an integration needs to group or label codeshares, check the applicable documentation and returned data before treating two designators as the same operation. Do not infer a codeshare relationship from matching times alone.
Schedule synchronization
Use the schedule response’s data.schedules array to process planned records, including flight_number and the departure and arrival scheduled fields. Keep the schedule representation separate from the tracking representation until your application has a reliable way to associate their records.
For a paginated schedule query, process every page before treating a synchronization as complete. Follow the documented pagination parameters and response metadata rather than assuming that the first page contains every JFK movement. Make repeated synchronization safe for your application, and retain the previous successful data if a later page fails.
FAQ
Should a JFK display use UTC or local time?
Store and compare timezone-aware instants in UTC, then display JFK times in America/New_York with a clear local-time label.
Does an estimated time mean the flight has arrived or departed?
No. An estimate is not an actual time. Show estimated and actual separately when they are available.
What should I do if a gate is missing?
Display it as unavailable or omit it until a response supplies one. Continue checking for updates without treating the missing value as a confirmed assignment.
Can I use the tracking parser for schedules?
Not unchanged. The example parser reads data.flight; the supplied schedule example uses data.schedules. Handle each response shape explicitly. For an MCP-based workflow, see MCP.
Ready to build the JFK integration? Register for a FlightLabs API key, then check the documentation for the request and pagination details your implementation needs.