
curl "https://api.openweathermap.org/data/2.5/weather?q=Tokyo&units=metric&appid=YOUR_API_KEY"
if response.status_code == 200: data = response.json() temp = data['main']['temp'] desc = data['weather'][0]['description'] print(f"CITY: temp°C, desc") else: print(f"Error response.status_code: response.json().get('message', 'Unknown error')") openweathermap api
Error response example:
Returns data every 3 hours for the next 5 days. curl "https://api
curl "https://api.openweathermap.org/data/2.5/weather?q=Tokyo&units=metric&appid=YOUR_API_KEY"
if response.status_code == 200: data = response.json() temp = data['main']['temp'] desc = data['weather'][0]['description'] print(f"CITY: temp°C, desc") else: print(f"Error response.status_code: response.json().get('message', 'Unknown error')")
Error response example:
Returns data every 3 hours for the next 5 days.