Last active
October 26, 2020 02:37
-
-
Save Jxck-S/66d6500833dfd9d24a2b67d61868d3c2 to your computer and use it in GitHub Desktop.
Lookup Nearest API Wrapper/Function by cords using OutAirport API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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