Skip to content
Permalink
3ea1c562d6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (25 sloc) 707 Bytes
import datetime
import requests
import pprint
current_time = datetime.datetime.now(datetime.UTC)
print(current_time)
recent_time = current_time - datetime.timedelta(seconds=60)
print(recent_time)
# to unix timestamp
unix_time = recent_time.timestamp()
print(unix_time)
base_url = "https://opensky-network.org/api"
api_url = "/states/all"
url = base_url + api_url
print(url)
"""
example_query = requests.get(f"https://opensky-network.org/api/states/all?lamin=45.8389&lomin=5.9962&lamax=47.8229&lomax=10.5226")
pprint.pprint(example_query.json())
"""
icao_code = "4BAA84"
params = {
"time": int(unix_time),
"icao24": icao_code,
}
req = requests.get(url, params=params)
pprint.pprint(req.json())