Skip to content

Instantly share code, notes, and snippets.

@Jxck-S
Last active October 26, 2020 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jxck-S/66d6500833dfd9d24a2b67d61868d3c2 to your computer and use it in GitHub Desktop.
Save Jxck-S/66d6500833dfd9d24a2b67d61868d3c2 to your computer and use it in GitHub Desktop.
Lookup Nearest API Wrapper/Function by cords using OutAirport API
#GET KEY AND HOST FROM https://rapidapi.com/sujayvsarma/api/ourairport-data-search?endpoint=apiendpoint_157e1886-2798-46cf-83e6-b71c2cb76273
def getAirport(latitude, longitude):
print(latitude, longitude)
import requests
import json
url = "https://ourairport-data-search.p.rapidapi.com/nearest/" + str(latitude) + "," + str(longitude)
querystring = {"maxResults":"1"}
headers = {
'x-rapidapi-host': "-",
'x-rapidapi-key': "-"
}
response = requests.request("GET", url, headers=headers, params=querystring)
response = json.loads(response.text)
#print(json.dumps(response, indent=4))
#Open Results, Then first result set as nearest
nearest = response["results"][0]
print(nearest["icao"])
print(nearest["name"])
return nearest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment