Guide · Python · SDK · REST API

IATA Flight Number Validation in Python — Airline Lookup & Parsing

Flight numbers like AA100 or LH438B appear in booking confirmations, airport displays, and flight-tracking APIs. Learn how to validate, parse, and enrich them in a single call.

1. What is an IATA flight number?

An IATA flight number (also called a flight designator) is a code assigned to a scheduled airline service. It consists of a 2-character airline code followed by a 1- to 4-digit number and an optional single-letter suffix. These identifiers appear on boarding passes, airport departure boards, flight-tracking apps, and GDS booking systems.

Some well-known examples: AA100 (American Airlines), LH438 (Lufthansa), BA15 (British Airways), EK1 (Emirates).

ℹ️The airline code portion is a 2-character IATA designator that can contain letters and digits (e.g. AA, LH, 2G, U2). Do not confuse it with the 3-letter ICAO airline code (e.g. AAL for American Airlines).

2. Structure breakdown

An IATA flight number has three parts. Understanding this structure helps when parsing user input, validating API payloads, or building flight search interfaces.

PartFormatExampleDescription
Airline code2 charactersAAIATA 2-character airline designator (letters or digits)
Flight number1-4 digits100Numeric portion identifying the specific service
Suffix0-1 letterBOptional letter suffix for operational variants

Combined, a flight number like LH438B breaks down as: airline code LH (Lufthansa), flight number 438, suffix B.

The IsValid API parses the flight number for you and returns each component separately — no need to write your own regex or parsing logic.

3. Why flight number validation matters

Booking systems

Users enter flight numbers when booking ancillary services (lounge access, parking, transfers). A malformed flight number causes downstream lookup failures. Validating the format at input time prevents errors before they propagate through the system.

Flight tracking

Flight-tracking applications query external APIs (FlightAware, AviationStack, Cirium) using flight numbers. Sending an invalid flight number wastes API quota and returns empty results. Validating and parsing the input first saves round-trips.

API and data pipeline integrity

ETL pipelines and data warehouses that ingest flight data need to normalise and validate flight numbers at ingestion time. Splitting the airline code, numeric part, and suffix enables proper indexing, deduplication, and join operations.


4. The right solution: one API call

The IsValid IATA Flight API validates the flight number format, parses it into its component parts, and enriches it with airline metadata — airline name, country, ICAO callsign, and more — all from a single GET request.

Format validation
Checks airline code + 1-4 digit number + optional suffix
Component parsing
Splits into airlineCode, flightNumber, and suffix
Airline lookup
Resolves airline name, country, and ICAO callsign
Single request
Validate, parse, and enrich in one API call

Get your free API key at isvalid.dev — 100 calls per day, no credit card required.

Full parameter reference and response schema: IATA Flight Validation API docs →


5. Python code example

Using the isvalid SDK package or the requests library.

# flight_validator.py
import os
from isvalid import IsValid

iv = IsValid(api_key=os.environ["ISVALID_API_KEY"])

# ── Example usage ────────────────────────────────────────────────────────────

result = iv.iata.flight("AA100")

print(result["valid"])        # True
print(result["airlineCode"])  # 'AA'
print(result["flightNumber"]) # 100
print(result["airlineName"])  # 'American Airlines'
print(result["suffix"])       # None

if result["valid"]:
    print(f"Flight {result['airlineCode']}{result['flightNumber']} — {result['airlineName']}")
    # → Flight AA100 — American Airlines

For batch validation — processing a list of flight numbers from a schedule or import file:

# flight_batch.py — validate multiple flight numbers
from typing import Any


def validate_flights(flight_list: list[str]) -> list[dict[str, Any]]:
    """Validate a list of IATA flight numbers and return enriched results."""
    results = []

    for flight in flight_list:
        try:
            data = validate_flight(flight)
            results.append({"flight": flight, **data})
        except Exception as exc:
            results.append({"flight": flight, "valid": False, "error": str(exc)})

    return results


# ── Example ──────────────────────────────────────────────────────────────────

flights = ["AA100", "LH438B", "BA15", "INVALID", "123"]
results = validate_flights(flights)

for r in results:
    status = "✓" if r.get("valid") else "✗"
    airline = r.get("airlineName", "unknown")
    print(f"  {status}  {r['flight']:<10}  {airline}")
If you are validating flight numbers from user input in a search form, debounce the API call by 300-500ms to avoid unnecessary requests while the user is still typing. Use functools.lru_cache for simple in-process caching of repeated lookups.

6. cURL example

American Airlines flight 100:

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.isvalid.dev/v0/iata/flight?value=AA100"

Lufthansa flight with suffix:

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.isvalid.dev/v0/iata/flight?value=LH438B"

Invalid format:

curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.isvalid.dev/v0/iata/flight?value=INVALID"

7. Understanding the response

Response for AA100 (American Airlines):

{
  "valid": true,
  "airlineCode": "AA",
  "flightNumber": 100,
  "suffix": null,
  "airlineName": "American Airlines",
  "countryCode": "US",
  "countryName": "United States",
  "callsign": "AMERICAN",
  "icao": "AAL"
}

Response for an invalid flight number:

{
  "valid": false
}
FieldTypeDescription
validbooleanWhether the input matches a valid IATA flight number format
airlineCodestring2-character IATA airline designator
flightNumbernumberNumeric portion of the flight number (1-4 digits)
suffixstring | nullOptional single-letter suffix, or null if not present
airlineNamestring | nullFull airline name, or null if the airline code is not recognised
countryCodestring | nullISO 3166-1 alpha-2 country code of the airline's registration
countryNamestring | nullFull English country name of the airline's registration
callsignstring | nullICAO radiotelephony callsign (e.g. AMERICAN)
icaostring | null3-letter ICAO airline code (e.g. AAL)

8. Edge cases to handle

(a) Codeshare flights

A single physical flight can have multiple flight numbers from different airlines. For example, a flight operated by American Airlines as AA100 may also be sold by British Airways as BA1525. Both are syntactically valid IATA flight numbers. The API validates the format and resolves the marketing airline — it does not determine the operating carrier.

# Both codeshare partners have valid flight numbers
marketing = iv.iata.flight("BA1525")
operating = iv.iata.flight("AA100")

print(marketing["valid"])       # True
print(marketing["airlineName"]) # 'British Airways'
print(operating["airlineName"]) # 'American Airlines'

(b) Suffix letters

Airlines use suffix letters to distinguish operational variants of the same flight number — for example, different days of the week, aircraft substitutions, or diversions. The suffix is always a single letter appended to the numeric part.

result = iv.iata.flight("LH438B")

print(result["airlineCode"])  # 'LH'
print(result["flightNumber"]) # 438
print(result["suffix"])       # 'B'
print(result["airlineName"])  # 'Lufthansa'

(c) Leading zeros

Some systems pad flight numbers with leading zeros (e.g. AA0100 instead of AA100). The API normalises the numeric part, so the flightNumber field always returns the integer value without padding.

r1 = iv.iata.flight("AA0100")
r2 = iv.iata.flight("AA100")

print(r1["flightNumber"])  # 100
print(r2["flightNumber"])  # 100

(d) Case insensitivity

The API accepts flight numbers in any case — aa100, Aa100, and AA100 all return the same result. The response always returns the normalised uppercase form in the airlineCode field.

r1 = iv.iata.flight("aa100")
r2 = iv.iata.flight("AA100")

print(r1["airlineCode"])  # 'AA'
print(r2["airlineCode"])  # 'AA'

9. Summary

Validate the flight number format — airline code + 1-4 digits + optional suffix
Use the parsed fields (airlineCode, flightNumber, suffix) for indexing and lookups
Enrich with airline name, ICAO code, and callsign in the same request
Handle codeshare flights — the same physical flight can have multiple designators
Normalise leading zeros — the API returns the integer flight number
Accept any case — the API normalises to uppercase automatically

See also

Validate IATA flight numbers instantly

Free tier includes 100 API calls per day. No credit card required. Airline name, ICAO code, callsign, and country lookup included in every response.