Fetching FAA airport status in python
I wrote some code to fetch airport status from the FAA’s airport status API.
Here’s the repo.
The API itself is pretty minimal.
You can get XML or JSON, but I’m just interested in JSON.
There are two “library” files, airportstatus.py and airports.py, that can be used in your code, and two examples of command line scripts that use the libraries, getall.py and getstatus.py.
airportstatus.py
This file is the main point of interest. It performs API calls with the get_status() method. It’s so short, I’ll paste the entire code here:
airports.py
This file creates a list of (airport code, airport name) tuples, and search() function that returns the subset of airports whose names or codes include the search term.
These are the two command line tool examples:
getall.py
Get status of all airports in the airports.py list and save them to all.json. Here’s the Usage:
getstatus.py
Get the the status of one airport and print to stdout. Here’s Usage: