Let's follow the steps required in this recipe:
- Run the following lines of code in the REPL:
>>> import urequests >>> >>> API_URL = 'http://api.openweathermap.org/data/2.5/weather' >>>
- The API_URL variable has now been defined, which we will use to access the weather API. In the next block of code, we define APPID and city to get weather data for. Make sure to replace the APPID value with your actual APPID value. We will now build the URL by combining these variables, which we we can then access:
>>> APPID = 'put-your-API-key(APPID)-here' >>> city = 'Berlin' >>> url = API_URL + '?units=metric&APPID=' + APPID + '&q=' + city
- The following block of code will connect to the weather API and retrieve the weather data:
>>> ...