I am working on a smartwatch using the Pi Pico W, I am using an online server to grab the accurate time and date. I have done this before with a different API, for weather. For an unknown reason, this API, does not work properly, leaving the Pi Pico W in a hanging state.
Below is the code snippet that has to do with loading the API, the print function is only so that I can make sure the API loads properly, and outputs the required data.
I am using the JSON module along with requests to obtain this data.
Here is the code:
y,m,d,dw,h,mm,sec = rtc.datetime()[0:7]
api_key = 'APIKEYGOESHERE'
url = 'https://api.nasa.gov/neo/rest/v1/feed?start_date=' + str(y) + '-' + str(m) + '-' + str((d - 1)) + '&end_date=' + str(y) + '-' + str(m) + '-' + str(d) + '&api_key=' + api_key
neodata = requests.get(url, timeout=10)
size_a = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[0].get('estimated_diameter').get('kilometers').get('estimated_diameter_max')
hh_a = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[0].get('is_potentially_hazardous_asteroid')
dist_a = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[0].get('close_approach_data')[0].get('miss_distance').get('kilometers')
name_a = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[0].get('name')
size_b = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[1].get('estimated_diameter').get('kilometers').get('estimated_diameter_max')
hh_b = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[1].get('is_potentially_hazardous_asteroid')
dist_b = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[1].get('close_approach_data')[0].get('miss_distance').get('kilometers')
name_b = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[1].get('name')
size_c = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[2].get('estimated_diameter').get('kilometers').get('estimated_diameter_max')
hh_c = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[2].get('is_potentially_hazardous_asteroid')
dist_c = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[2].get('close_approach_data')[0].get('miss_distance').get('kilometers')
name_c = neodata.json().get('near_earth_objects').get(str(y) + '-' + str(m) + '-' + str(d))[2].get('name')
print(size_a, hh_a, dist_a, name_a, size_b, hh_b, dist_b, name_b, size_c, hh_c, dist_c, name_c)
I have checked the RTC data, and have retyped my API key around 3 times, to no avail. Any help would be greatly appriciated, thank you all in advance!