Skip to main content

A python wrapper of the United States Federal Aviation Authority's National Airspace System API

Project description

NASSTAT - National AirSpace STATistics

#####################################################################
#####################################################################
#####███╗░░██╗░█████╗░░██████╗░██████╗████████╗░█████╗░████████╗#####
#####████╗░██║██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔══██╗╚══██╔══╝#####
#####██╔██╗██║███████║╚█████╗░╚█████╗░░░░██║░░░███████║░░░██║░░░#####
#####██║╚████║██╔══██║░╚═══██╗░╚═══██╗░░░██║░░░██╔══██║░░░██║░░░#####
#####██║░╚███║██║░░██║██████╔╝██████╔╝░░░██║░░░██║░░██║░░░██║░░░#####
#####╚═╝░░╚══╝╚═╝░░╚═╝╚═════╝░╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝░░░╚═╝░░░#####
#####################################################################
#####################################################################

Last updated: Fri March 21 2025

A python wrapper of the United States Federal Aviation Authority's National Airspace System API developed by Dariel Cruz Rodriguez.

Table of Contents

Dependencies

Run this command to install the required packages:

pip install requests xml.etree.ElementTree json re

NASSTAT uses the following packages, many of which are included in the standard library of vanilla Python installations:

  • requests - for making HTTP requests to the FAA's API
  • xml.etree.ElementTree - for parsing the XML response from the FAA's API
  • json - for parsing the JSON response from the FAA's API
  • re - for regular expression matching

Installation

Attribution & Licensing

Attribution

Although it is not required, please attribute use of this package to the author, Dariel Cruz Rodriguez, by including a link to dariel.us in your project. As a college student, your attribution can be really helpful in building my portfolio and building a reputation in the data science community. If you are unable to attribute, or it doesn't make sense for your project, please feel free to email me about your project so I can keep an internal note of it, I would love to hear about how you are using NASSTAT!

Additionally, the data provided by the FAA is licensed under the Open Government License, which allows for free use and redistribution of the data. Thank you Uncle Sam!

MIT License

Copyright (c) 2024 Dariel Cruz Rodriguez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Models

Airport()

Importing

MCO = Airport("MCO") # loads in an instance of MCO and all associated data with it

Attributes

  • airportid (str): The airport IATA/ICAO code (e.g., "MCO", "KATL")
  • lastupdate (datetime): The timestamp of when the airport data was last updated
  • airportclosures (dict): Information about current airport closures, if any
  • airportdelays (dict): Details about current delays including minimum, maximum, average delay times, and reasons
  • possibledelays (dict): Information about potential upcoming delays

Methods

Airport.getDelays()

If you want to filter for just departure or arrival delays, use either Airport.getDepartureDelays() or Airport.getArrivalDelays().

airportcode = "MCO"
airport = Airport(airportcode)
delays = airport.getDelays()
print(delays)

# > {'Departure': {'minDelay': 31, 'maxDelay': 45, 'avgDelay': 38, 'reason': 'TM INITIATIVES:MIT:STOP&VOL'}}
# In plain language, you can access items in the dictionary to form a string.
airportcode = "MCO"
airport = Airport(airportcode)
airport.getDelays()

if airport.airportdelays is None:
    print("There are no delays.")
else:
    for key, value in airport.airportdelays.items():
        print(f"There is a delay on {airportcode} {key}s averaging {value['avgDelay']} minutes (btwn. {value['minDelay']}-{value['maxDelay']} min) due to {value['reason']}.")

# > There is a delay on MCO Departures averaging 38 minutes (btwn. 31-45 min) due to TM INITIATIVES:MIT:STOP&VOL.

Airport.averageDelay()

airportcode = "MCO"
airport = Airport(airportcode)
print(airport.averageDelay())

# > 38.0

Airport.delayReasons()

airportcode = "PBI"
airport = Airport(airportcode)
print(airport.delayReasons())
# > "runway construction"
# This method also returns multiple reasons as a plain language string (adding 'and' at the end of the list for the last reason)

airportcode = "LGA"
airport = Airport(airportcode)
print(airport.delayReasons())
# > "runway construction, wind, and TM INITIATIVES:MIT:STOP&VOL"

Airport.isDelay()

airportcode = "MCO"
airport = Airport(airportcode)
print(airport.isDelay())

# > True
airportcode = "DEN"
airport = Airport(airportcode)
print(airport.isDelay())

# > "NAASTATUS Airport Delays is empty, attempting to refresh..."
# > False

Airport.getPossibleDelays()

airportcode = "DCA"
airport = Airport(airportcode)
print(airport.getPossibleDelays())

# > {'GROUND STOP/DELAY PROGRAM POSSIBLE': 'AFTER 1930'}

Airport.getClosures()

airportcode = "LAS"
airport = Airport(airportcode)
print(airport.getClosures())

# > [{'reason': '!LAS 03/121 LAS AD AP CLSD TO NON SKED TRANSIENT GA ACFT EXC 24HR PPR 702-261-7775 2503171851-2506252300', 'start': 'Mar 17 at 18:51 UTC.', 'reopen': 'Jun 25 at 23:00 UTC.'}]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nasstat-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file nasstat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nasstat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for nasstat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48397ef834830f4baaa4fc277bb27607f452d7074641e5d6a2a7846509d76937
MD5 8d2c3dab319b720e6c31d08579712536
BLAKE2b-256 0b797a4a406c1b3758ae6f3891761c71904e30bf5eea6f8bcef2ebdfc2ebed82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page