Skip to content

Loknar/py-iata-lookup

Repository files navigation

py-iata-lookup

Small API powered by a simple python flask example which exposes (as a json API) a search form on iata.org where you're able to search for airlines and airports based on name or code.

Setup and usage

You need to have python 2.7 and pip and install the following python modules:

pip install -r pip_requirements.txt

Open a terminal in this repository and start the py-iata-lookup API with

python app.py

You're now running a local instance of the py-iata-lookup API on your localhost:15000.

Examples

The pretty parameter is optional, it only prettifies the json response for readability.

http://localhost:15000/ [the root just returns url to this README section]

https://github.com/Loknar/py-iata-lookup#examples

http://localhost:15000/airline/code/ww?pretty=true

{
	"results": [
		{
			"accounting_code": "377", 
			"airline_name": "WOW Air ehf", 
			"airline_prefix_code": "377", 
			"iata_code": "WW"
		}
	]
}

http://localhost:15000/airline/name/Norwegian?pretty=true

{
	"results": [
		{
			"accounting_code": "329", 
			"airline_name": "Norwegian Air International LTD.", 
			"airline_prefix_code": "329", 
			"iata_code": "D8*"
		}, 
		{
			"accounting_code": null, 
			"airline_name": "Norwegian Air Norway AS", 
			"airline_prefix_code": null, 
			"iata_code": "DH*"
		}, 
		{
			"accounting_code": "328", 
			"airline_name": "Norwegian Air Shuttle A.S.", 
			"airline_prefix_code": "328", 
			"iata_code": "DY*"
		}, 
		{
			"accounting_code": "762", 
			"airline_name": "Norwegian Air UK ltd", 
			"airline_prefix_code": "762", 
			"iata_code": "DI"
		}
	]
}

http://localhost:15000/location/name/London?pretty=true

{
	"results": [
		{
			"airport_code": "ELS", 
			"airport_name": "East London", 
			"city_code": "ELS", 
			"city_name": "East London"
		}, 
		{
			"airport_code": "GON", 
			"airport_name": "Airport", 
			"city_code": "GON", 
			"city_name": "Groton/New London"
		}, 
		{
			"airport_code": "BQH", 
			"airport_name": "Biggin Hill", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "LCY", 
			"airport_name": "City Airport", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "LGW", 
			"airport_name": "Gatwick", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "LHR", 
			"airport_name": "Heathrow", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "LON", 
			"airport_name": "Metropolitan Area", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "LTN", 
			"airport_name": "Luton", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "SEN", 
			"airport_name": "Southend", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "STN", 
			"airport_name": "Stansted", 
			"city_code": "LON", 
			"city_name": "London"
		}, 
		{
			"airport_code": "YXU", 
			"airport_name": "International", 
			"city_code": "YXU", 
			"city_name": "London"
		}, 
		{
			"airport_code": "LOZ", 
			"airport_name": "Magee Field", 
			"city_code": "LOZ", 
			"city_name": "London/Corbin"
		}, 
		{
			"airport_code": "LYX", 
			"airport_name": "London Ashford", 
			"city_code": "LYX", 
			"city_name": "Lydd"
		}, 
		{
			"airport_code": "OXF", 
			"airport_name": "London Oxford", 
			"city_code": "OXF", 
			"city_name": "Oxford"
		}
	]
}

http://localhost:15000/location/code/YYZ?pretty=true

{
	"results": [
		{
			"airport_code": "YYZ", 
			"airport_name": "Lester B. Pearson Intl", 
			"city_code": "YTO", 
			"city_name": "Toronto"
		}
	]
}

Debugging

If the scraping breaks a good starting point would be to run the scraper, there are some manual test runs for the different functions in there (see here).

python iata_scraper.py

Licence

WTFPL

About

Python scripts to lookup things on iata.org

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages