Septzzz's picture
Upload folder using huggingface_hub (part 24)
59f06a6 verified
Raw
History Blame Contribute Delete
11.1 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def aircraft_last_position_by_hex_id_icao(icao: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns one aircraft last known location using the mode-s hex (icao), if aircraft has flown in the last 48 hours."
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/hex/{icao}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_live_position_by_hex_id_icao(icao: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns one aircraft using the mode-s hex (icao)"
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/icao/{icao}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def single_aircraft_position_by_hex_id_icao(icao: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Single aircraft Position by ICAO Mode S 6-digit transponder hex code (if currently tracked)"
icao: ICAO code 000000-FFFFFF
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/icao/{icao}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def single_aircraft_position_by_registration(reg: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Single aircraft Position by Registration (if currently tracked)"
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/registration/{reg}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_250_nm_radius(lon: int, lat: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within 250 Nautical Mile radius of a point"
lon: Longitude (-180 to 180) Hint: US is negative longitude!
lat: Latitude (-90 to 90)
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/250/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_25_nm_radius(lat: int, lon: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within 25 Nautical Mile radius of a point"
lat: Latitude (-90 to 90)
lon: Longitude (-180 to 180) Hint: US is negative longitude!
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/25/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_10_nm_radius(lon: int, lat: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within 10 Nautical Mile radius of a point"
lon: Longitude (-180 to 180) Hint: US is negative longitude!
lat: Latitude (-90 to 90)
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/10/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_5_nm_radius(lat: int, lon: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within 5 Nautical Mile radius of a point"
lat: Latitude (-90 to 90)
lon: Longitude (-180 to 180) Hint: US is negative longitude!
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/5/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_1_nm_radius(lat: int, lon: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within 1 Nautical Mile radius of a point"
lat: Latitude (-90 to 90)
lon: Longitude (-180 to 180) Hint: US is negative longitude!
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/1/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_50_nm_radius(lon: int, lat: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all aircraft within 50 nautical mile radius of a point"
lon: Longitude (-180 to 180) Hint: US is negative longitude!
lat: Latitude (-90 to 90)
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/50/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_by_squawk(sqk: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns one or more aircraft currently broadcasting a specific squawk code"
sqk: 4-digit Transponder Squawk Code in Octal (ie.1200, 7700, 1234 etc.)
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/sqk/{sqk}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_user_specified_distance_up_to_250_nm(lon: int, dist: int, lat: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within specified distance up to 250 NM"
lon: Longitude (-180 to 180) Hint: US is negative longitude!
lat: Latitude (-90 to 90)
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/{dist}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def tagged_military_aircraft(toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns all active aircraft tagged as Military"
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/mil/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_by_call_sign(callsign: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns one or more aircraft currently broadcasting a call sign"
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/callsign/{callsign}/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def aircraft_within_100_nm_radius(lat: int, lon: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Show all Aircraft within 100 Nautical Mile radius of a point"
lat: Latitude (-90 to 90)
lon: Longitude (-180 to 180) Hint: US is negative longitude!
"""
url = f"https://adsbexchange-com1.p.rapidapi.com/v2/lat/{lat}/lon/{lon}/dist/100/"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "adsbexchange-com1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation