If you have any questions, comments, or issues with this project please post them here!
So the default code for day 92 is broken, specifically in requests.get()
. Here’s what they give you:
import requests, json
timezone = "GMT"
latitude = 51.5002
longitude = -0.1262
result = requests.get(f"https://api.open-meteo.com/v1/forecast?latituude={latitude}&longitude={longitude}&daily=weathercode, temperature_2m_max, temperature_2m_min&timezone={timezone.upper()}")
user = result.json()
print(json.dumps(user, indent=2))
First off, latitude is misspelled as “latituude.” Second, there are spaces in the link.
Fixed version:
import requests, json
timezone = "GMT"
latitude = 51.5002
longitude = -0.1262
result = requests.get(f"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone={timezone.upper()}")
user = result.json()
print(json.dumps(user, indent=2))
Would definitely appreciate a fix for this in the repl.
Great spot @QwertyQwerty88 thank you for letting us know.
I’ve got in touch with @DavidAtReplit so that we can investigate and correct if needed!
Sorry! It looks like a transcription error between the video and the text being written, all sorted now!
Sorry it was private - should be sorted now!
everytime i use my local timezone i get an error message. is this something i make wrong or is something wrong with the api
Hi @im120699, welcome to the community!
Can you send a link to your Repl or show your code? It worked fine for me.
import requests, json
timezone = "GMT+2"
latitude = 50.47
longitude = 6.05
result = requests.get(f"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone={timezone.upper()}")
user = result.json()
print(json.dumps(user, indent=2))
I dont know how to translate the weathercode. Is there somewhere an instruction that i can follow. Because i have no idea what the numbers i get back mean.
Here, from my solution:
def getCode(code):
if code == 0:
return "Clear sky"
elif code == 1 or code == 2 or code == 3:
return "Mainly clear, partly cloudy, and overcast"
elif code == 45 or code == 48:
return "Fog and depositing rime fog"
elif code == 51 or code == 55:
return "Drizzle: Light, moderate, and dense intensity"
elif code == 56 or code == 57:
return "Freezing Drizzle: Light and dense intensity"
elif code == 61 or code == 63 or code == 65:
return "Rain: Slight, moderate, and heavy intensity"
elif code == 66 or code == 67:
return "Freezing Rain: Light and heavy intensity"
elif code == 71 or code == 73 or code == 75:
return "Snow fall: Slight, moderate, and heavy intensity"
elif code == 77:
return "Snow grains"
elif code == 80 or code == 81 or code == 82:
return "Rain showers: Slight, moderate, and violent"
elif code == 85 or code == 86:
return "Snow showers slight and heavy"
elif code == 95:
return "Thunderstorm: Slight or moderate"
elif code == 96 or code == 98:
return "Thunderstorm with slight and heavy hail"