This can be used in any application with minimum lines of code. A simple way to get weather data using the WeatherXu API service.
To get API Key:
- Go to WeatherXu's website
- Create a free account
- Navigate to your dashboard
- Copy your API key from the credentials section
import requests
api_address = 'https://api.weatherxu.com/v1/weather?api_key=YOUR_API_KEY'
lat = input('Latitude: ')
lon = input('Longitude: ')
url = f'{api_address}&lat={lat}&lon={lon}'
json_data = requests.get(url).json()
print(json_data)
formatted_data = json_data['data']['currently']
print(formatted_data)
Top comments (0)