Skip to content

Commit

Permalink
Merge pull request #172 from DJDevon3/DJDevon3-openskynetwork_public
Browse files Browse the repository at this point in the history
Update OpenSky-Network Public Single Flight API Example
  • Loading branch information
FoamyGuy authored Apr 15, 2024
2 parents 0c193c6 + 019f126 commit 12e6b47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2024 DJDevon3
# SPDX-License-Identifier: MIT
# Coded for Circuit Python 8.2.x
# Coded for Circuit Python 9.x
"""OpenSky-Network.org Single Flight Private API Example"""

import binascii
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# SPDX-FileCopyrightText: 2024 DJDevon3
# SPDX-License-Identifier: MIT
# Coded for Circuit Python 8.2.x
"""OpenSky-Network.org Public API Example"""
# pylint: disable=import-error
# Coded for Circuit Python 9.x
"""OpenSky-Network.org Single Flight Public API Example"""

import os
import time
Expand All @@ -17,13 +16,11 @@
# All active flights JSON: https://opensky-network.org/api/states/all PICK ONE!
# JSON order: transponder, callsign, country
# ACTIVE transpondes only, for multiple "c822af&icao24=cb3993&icao24=c63923"
TRANSPONDER = "3c5ef8"
TRANSPONDER = "88044d"

# Get WiFi details, ensure these are setup in settings.toml
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
osnusername = os.getenv("OSN_USERNAME") # Website Credentials
osnpassword = os.getenv("OSN_PASSWORD") # Website Credentials

# API Polling Rate
# 900 = 15 mins, 1800 = 30 mins, 3600 = 1 hour
Expand Down Expand Up @@ -80,15 +77,16 @@ def _format_datetime(datetime):
print("✅ Wifi!")

try:
print(" | Attempting to GET OpenSky-Network Single Flight JSON!")
print(" | Attempting to GET OpenSky-Network Single Public Flight JSON!")
print(" | Website Credentials NOT Required! Less daily calls than Private.")
try:
opensky_response = requests.get(url=OPENSKY_SOURCE)
opensky_json = opensky_response.json()
except ConnectionError as e:
print("Connection Error:", e)
print("Retrying in 10 seconds")

print(" | ✅ OpenSky-Network JSON!")
print(" | ✅ OpenSky-Network Public JSON!")

if DEBUG:
print("Full API GET URL: ", OPENSKY_SOURCE)
Expand Down

0 comments on commit 12e6b47

Please sign in to comment.