airport-data 1.0.2

A comprehensive Rust library for retrieving airport information by IATA codes, ICAO codes, and various other criteria
Documentation

airport-data

Crates.io Documentation License: CC BY 4.0

A comprehensive Rust library for retrieving airport information by IATA codes, ICAO codes, and various other criteria. Provides access to a dataset of 5,000+ airports worldwide with detailed information including coordinates, timezone, type, and external links.

All airport data is embedded directly into the compiled binary — no network requests or external files needed at runtime.

Website: airportdata.dev | GitHub: aashishvanand/airport-data-rust | Docs: docs.rs/airport-data

Installation

Add this to your Cargo.toml:

[dependencies]
airport-data = "0.1"

Quick Start

use airport_data::AirportData;

let db = AirportData::new();

// Look up by IATA code
let airport = db.get_airport_by_iata("SIN").unwrap();
assert_eq!(airport.airport, "Singapore Changi Airport");

// Look up by ICAO code
let airport = db.get_airport_by_icao("WSSS").unwrap();
assert_eq!(airport.country_code, "SG");

Features

Core Search

use airport_data::AirportData;

let db = AirportData::new();

// Single airport lookup
let airport = db.get_airport_by_iata("JFK").unwrap();
println!("{} ({})", airport.airport, airport.country_code);

// Search by name (case-insensitive substring match)
let results = db.search_by_name("heathrow");
println!("Found {} result(s)", results.len());

// Autocomplete suggestions
let suggestions = db.get_autocomplete_suggestions("sin", 5);

Geographic Queries

use airport_data::AirportData;

let db = AirportData::new();

// Find airports within 50 km of a point
let nearby = db.find_nearby_airports(1.3644, 103.9915, 50.0);

// Calculate distance between two airports (in km)
let distance = db.calculate_distance("SIN", "KUL").unwrap();

// Find the nearest airport to coordinates
let nearest = db.find_nearest_airport(51.4700, -0.4543).unwrap();

Filtering

use airport_data::{AirportData, AirportFilter};

let db = AirportData::new();

// By country, continent, type, or timezone
let sg_airports = db.get_airports_by_country_code("SG");
let asia_airports = db.get_airports_by_continent("AS");
let large = db.get_airports_by_type("large_airport");

// Advanced filtering
let filter = AirportFilter {
    country_code: Some("US".to_string()),
    airport_type: Some("large_airport".to_string()),
    has_scheduled_service: Some(true),
    min_runway_ft: Some(10000),
    ..Default::default()
};
let results = db.find_airports(&filter);

Statistics

use airport_data::AirportData;

let db = AirportData::new();

let stats = db.get_airport_stats_by_country("US").unwrap();
println!("Total airports: {}", stats.total);
println!("With scheduled service: {}", stats.with_scheduled_service);

let continent_stats = db.get_airport_stats_by_continent("EU").unwrap();

Distance Matrix

use airport_data::AirportData;

let db = AirportData::new();

let codes = vec!["SIN".to_string(), "KUL".to_string(), "BKK".to_string()];
let matrix = db.calculate_distance_matrix(&codes).unwrap();

Validation

use airport_data::AirportData;

let db = AirportData::new();

assert!(db.validate_iata_code("SIN"));
assert!(!db.validate_iata_code("ZZZ"));

assert!(db.validate_icao_code("WSSS"));

Airport Data Fields

Each Airport struct contains:

Field Type Description
iata String 3-letter IATA code
icao String 4-letter ICAO code
airport String Airport name
latitude f64 Latitude
longitude f64 Longitude
timezone String IANA timezone (e.g. "Asia/Singapore")
utc Option<f64> UTC offset
country_code String 2-letter country code
continent String 2-letter continent code
elevation_ft Option<i64> Elevation in feet
airport_type String Type (large_airport, medium_airport, small_airport, heliport, seaplane_base)
scheduled_service bool Has scheduled commercial service
runway_length Option<i64> Longest runway in feet
wikipedia String Wikipedia URL
website String Official website URL
flightradar24_url String FlightRadar24 URL
radarbox_url String RadarBox URL
flightaware_url String FlightAware URL

How It Works

The airport dataset (airports.json) is gzip-compressed at build time and embedded into the binary via include_bytes!. On first access, the data is decompressed and deserialized into memory, then cached for the lifetime of the process. The AirportData struct is zero-cost to construct.

License

This project is licensed under the Creative Commons Attribution 4.0 International License (CC-BY-4.0).