Track Vietnam Airlines Flights Live with Our Flight Info By Flight Number API (SJU).
You need to show live status for specific Vietnam Airlines flights by flight number, including gates, terminals, real-time progress and any delays, and you want a clean JSON API that your app can poll reliably. By the end of this guide, you will query FlightLabs’ flight info by flight number endpoint, parse the important fields, refresh status safely, and handle edge cases like cancellations or diversions for Vietnam Airlines (IATA: VN).
Vietnam Airlines at a glance
Vietnam Airlines (IATA: VN) is the flag carrier of Vietnam. Its primary hubs are Hanoi’s Noi Bai International Airport (HAN) and Ho Chi Minh City’s Tan Son Nhat International Airport (SGN). In this article we focus on programmatic tracking of VN flights by flight number using FlightLabs’ REST API.
Endpoint to use: flight info by flight number
For a point-in-time status of a single Vietnam Airlines flight, use FlightLabs’ Detailed Flight Info endpoint:
https://www.goflightlabs.com/flight-info-by-flight-number
Authentication uses an API key. If you don’t have one yet, register for free access on goflightlabs.com or go straight to Register.
Because parameter names vary per endpoint and plan, consult the Documentation for the exact query string keys (e.g., the parameter that accepts the IATA flight number). The example below shows a common pattern: pass your flight number (VN followed by digits) and the API key.
Example: cURL request for a Vietnam Airlines flight
curl -G "https://www.goflightlabs.com/flight-info-by-flight-number" \
--data-urlencode "flight_number=VN301" \
--data-urlencode "api_key=YOUR_API_KEY"
Replace VN301 with the specific Vietnam Airlines flight number you need to track, and set YOUR_API_KEY to your token. If your plan or environment requires a different parameter name (for example, flight_iata or access_key), use the exact names shown in the FlightLabs docs for your account.
Understanding the response: fields that matter for live status
Below is an official example response structure from the real-time family of endpoints. Your Detailed Flight Info response will expose the same core semantics: a flight object with status, departure/arrival sections (including scheduled and actual or estimated times), and optionally position when the flight is en-route.
{
"success": true,
"data": {
"flight": {
"iata": "AA123",
"icao": "AAL123",
"number": "123",
"status": "en-route",
"departure": {
"airport": "JFK",
"scheduled": "2024-03-20T10:00:00Z",
"actual": "2024-03-20T10:05:00Z",
"terminal": "8",
"gate": "B12"
},
"arrival": {
"airport": "LAX",
"scheduled": "2024-03-20T13:15:00Z",
"estimated": "2024-03-20T13:20:00Z",
"terminal": "4",
"gate": "45A"
},
"position": {
"latitude": 39.8729,
"longitude": -98.7372,
"altitude": 35000,
"speed": 495,
"heading": 270
}
}
}
}
How to read this for Vietnam Airlines flights:
- flight.iata / flight.number: For VN flights you’ll see values like iata: "VN301" and number: "301". Keep the alphanumeric IATA code for user-facing display and the numeric for internal logs if needed.
- flight.status: Expect states like scheduled, active/en-route, landed, cancelled, or diverted. Use this to drive your UI and alerts.
- departure.scheduled and arrival.scheduled: ISO-8601 times in UTC. Display them with the local airport timezone when rendering but store as UTC for computation.
- departure.actual and arrival.estimated: Actual/estimated timestamps help you compute departure delays or arrival ETAs. A positive difference between actual and scheduled indicates delay.
- terminal and gate: Present when provided by the data source. Useful for airport displays and passenger notifications.
- position: Latitude/longitude and performance metrics when the aircraft is airborne. Not all ground states include this block.
Codeshares and aircraft details: Depending on the specific flight and your plan, the response can include an aircraft object (e.g., type, registration) and a list of codeshares. Handle them defensively—display codeshare partners only if present and map aircraft fields to your fleet view when available.
Live refresh with JavaScript
The snippet below polls the flight info by flight number endpoint for a Vietnam Airlines flight and updates a simplified status model. Adjust the interval according to your plan’s rate limits and the user experience you need.
async function fetchFlightInfo(flightNumber) {
const params = new URLSearchParams({
flight_number: flightNumber,
api_key: "YOUR_API_KEY" // Check docs for the exact auth parameter if different
});
const url = "https://www.goflightlabs.com/flight-info-by-flight-number?" + params.toString();
const res = await fetch(url, { method: "GET" });
if (!res.ok) {
throw new Error("FlightLabs API error: " + res.status);
}
const json = await res.json();
if (!json.success || !json.data || !json.data.flight) {
throw new Error("Unexpected response structure");
}
const f = json.data.flight;
// Normalize fields you will display
return {
iata: f.iata, // e.g., "VN301"
status: f.status, // e.g., "en-route"
dep: {
airport: f.departure?.airport,
scheduledUtc: f.departure?.scheduled,
actualUtc: f.departure?.actual,
terminal: f.departure?.terminal,
gate: f.departure?.gate
},
arr: {
airport: f.arrival?.airport,
scheduledUtc: f.arrival?.scheduled,
estimatedUtc: f.arrival?.estimated,
terminal: f.arrival?.terminal,
gate: f.arrival?.gate
},
position: f.position || null
};
}
// Simple polling loop for a Vietnam Airlines flight
const VN_FLIGHT = "VN301";
let stop = false;
async function poll() {
if (stop) return;
try {
const info = await fetchFlightInfo(VN_FLIGHT);
console.log("Status:", info.status);
console.log("Departure scheduled (UTC):", info.dep.scheduledUtc, "Actual:", info.dep.actualUtc);
console.log("Arrival scheduled (UTC):", info.arr.scheduledUtc, "Estimated:", info.arr.estimatedUtc);
if (info.position) {
console.log("Position lat/lon:", info.position.latitude, info.position.longitude);
}
// Update your UI or cache here
} catch (e) {
console.error(e);
} finally {
// Poll every 30s while en-route; back off when scheduled or landed
setTimeout(poll, 30000);
}
}
poll();
// Later, call stop = true to end polling
VN-focused use cases you can ship quickly
- Flight status boards for specific VN routes: Use flight.status plus departure.terminal/gate and arrival.terminal/gate to keep passengers oriented at HAN and SGN. If position exists, show “en-route” with progress.
- Delay monitoring and alerts: Compare departure.actual to departure.scheduled to compute a departure delay, and arrival.estimated to arrival.scheduled for arrival delay. Trigger push notifications for material changes.
- Route analysis for operations teams: Combine this endpoint with schedules and historical data to analyze when specific VN flight numbers typically depart/arrive, and how often the status transitions to cancelled or diverted.
How this endpoint compares to related FlightLabs endpoints
For a complete VN workflow, you may pair Detailed Flight Info with other endpoints. Here’s a developer-focused comparison to help you decide when to call which:
| Endpoint | Primary purpose | Key fields you’ll use | Typical call timing | Notes for VN tracking |
|---|---|---|---|---|
| Flight Info by Flight Number | Single-flight status (by known flight number) | status, departure.scheduled/actual, arrival.scheduled/estimated, terminal/gate, position | When a user searches for a specific VN flight; frequent polling during day-of-travel | Best UX for “what’s happening now?” on VN flights |
| Real-time Flight Tracking | Live tracking with position data | status, position (lat/lon/altitude/speed/heading), times | During en-route phase; map views and live trackers | Use when you want higher-fidelity movement data for VN legs |
| Flight Schedules | Planned schedules for route planning | scheduled times, terminals, aircraft (when available), airline identifiers | Pre-travel planning; batch refresh daily | Seed your cache of VN flights you’ll later look up by number |
| Flight History | Past flights for analytics and audits | actual vs. scheduled times, status history | Overnight or weekly batch jobs | Compute average VN delays, typical gates, and historical trends |
| Future Flights | Upcoming flight predictions or planned legs | future schedules and identifiers | Trip building; itinerary assembly | Feed your lookups for upcoming VN segments |
Time zones, UTC and timestamps
- All timestamps in the examples are ISO-8601 with a Z suffix (UTC). Convert to local time zones like Asia/Ho_Chi_Minh (SGN) or Asia/Bangkok (if applicable for overflights) only in your presentation layer.
- Compute delays in UTC to avoid DST or offset issues. For example, delay_minutes = (actual - scheduled) / 60 seconds.
- When rendering both scheduled and actual/estimated, explicitly label them so customers understand what changed.
Polling, caching, and refresh strategy for VN flights
Live tracking has different refresh needs across the flight lifecycle:
- Pre-departure: Poll every 60–120 seconds to capture gate or terminal changes and push only deltas to clients.
- En-route: Poll every 15–30 seconds if you need a moving map or frequent ETA updates. If you only need milestone changes (e.g., “airborne,” “landed”), 60–120 seconds is usually sufficient.
- Post-arrival: Stop polling once status becomes landed and arrival.actual (or an equivalent final timestamp) stabilizes. Cache for at least 24 hours for user lookbacks.
Client-side backoff: If the API returns errors or the flight status remains unchanged for several polls, exponentially back off (e.g., double interval up to a max). Always respect your plan’s rate limits (see the Documentation for specifics).
Server-side caching: Keep a short-lived cache (e.g., 15–60 seconds) keyed by the IATA flight number (VN###) to avoid over-fetching when multiple clients watch the same flight simultaneously.
Handling cancelled or diverted Vietnam Airlines flights
- Cancelled: When flight.status is cancelled, hide gates and ETAs, surface cancellation messaging clearly, and stop frequent polling. Consider a longer cache TTL because the state will not change.
- Diverted: If status becomes diverted and arrival.airport differs from the planned destination, display both the planned and the diversion airports. Continue polling—terminal/gate at the diversion airport may appear later.
- Return to gate or long delays: departure.actual might be missing while status changes back to scheduled or delayed. Guard against nulls and render “TBD” where appropriate.
Connecting flight info with VN schedules and history
The flight-by-number lookup shines on the day of travel, but building robust VN experiences often means combining endpoints:
- Seed your system with Vietnam Airlines schedules (flights-schedules) for the next few days. Store flight_number, departure/arrival airports and scheduled timestamps.
- On the day of operation, look up the exact VN flight with the flight-info-by-flight-number endpoint to overlay real-time status, terminal and gate.
- After operation, persist final fields (status, actual/estimated timestamps) and backfill analytics with flights-history. This powers accuracy metrics and incident reviews.
Pagination for schedules: The schedules endpoint is designed for batch retrievals and may be paginated. Implement cursor or page/offset handling as directed in the docs, and store checkpoints so you can resume if a job is interrupted.
Field mapping checklist for VN implementations
- Identifiers: iata (e.g., VN301), number (“301”), and optionally icao for operational tools.
- Operational state: status transitions to drive UI states and notifications.
- Departure/Arrival blocks: scheduled vs. actual/estimated timestamps; terminal and gate.
- Position (if present): latitude/longitude for maps; altitude/speed/heading for telemetry panels.
- Codeshares (if present): maintain a list and normalize presentation (e.g., “Also marketed as XX1234”).
- Aircraft (if present): type and registration to enrich fleet views and seat maps.
Error handling and reliability tips
- Validate response.success and the presence of data.flight before dereferencing deeper fields.
- Gracefully handle missing position, gate, or terminal—these may be absent in certain phases or routes.
- Retry with jitter on 5xx network conditions and back off when repeated errors occur.
- Log raw JSON for incident analysis and to compare against later updates.
End-to-end example flow for a VN flight
- Identify the VN flight number from your schedules store (e.g., VN301 for a HAN–SGN sector).
- Call the flight info by flight number endpoint with that VN code and your API key.
- Show scheduled departure/arrival in local time and UTC labels in tooltips.
- When actual or estimated times appear, compute delay deltas and update UI and alerts.
- If the position object is present and status is en-route, render a moving map and an ETA countdown.
- When status becomes landed, stop frequent polling and persist final timestamps for history.
Operational guardrails for production
- Rate-aware polling: Centralize polling in a service that fans out to clients via WebSockets or SSE.
- Change detection: Only push updates when key fields change (status, times, terminal/gate, position).
- Audit trail: Keep a compact diff log for each VN flight to diagnose anomalies quickly.
- Fallback views: If real-time is temporarily unavailable, display scheduled data with a banner noting last update time.
Where to monitor and manage your access
Use the FlightLabs MCP to review your requests, inspect logs, and manage keys. Refer to the Documentation for endpoint-specific parameters and pagination mechanics. If you need an API key, you can obtain one at www.goflightlabs.com or go directly to Register.
FAQ
Which identifier should I use to query a Vietnam Airlines flight?
Use the IATA flight number format (e.g., “VN301”) with the flight info by flight number endpoint. Check the docs for the exact parameter name your plan expects.
How do I compute a delay?
Compare actual vs. scheduled for departure and estimated vs. scheduled for arrival. Compute in UTC and present both the delta and a human-readable label.
How often should I poll?
60–120 seconds pre-departure, 15–30 seconds during en-route if you need a live map, and stop frequent polling once the flight has landed. Use exponential backoff on repeated errors.
What happens if a VN flight is cancelled or diverted?
The status field will reflect cancelled or diverted. Hide gates and ETAs for cancelled flights; for diversions, display both planned and diversion airports and continue polling until stable.
Can I get historical VN flights and future schedules?
Yes. Use flights-history for past operations and flights-schedules or future-flights for planning and predictions. Implement pagination as described in the docs.
Ready to build or ship your VN flight status feature? Get your API key now and start integrating with FlightLabs. Visit goflightlabs.com or Register to begin.