apiKey- The 32-character API key, unique to your OpenWeatherMap account.
locationsList- A list of four locations for which you want to retrieve the weather. To avoid ambiguity issues with location names, it is preferred to use both the city name and country. "San Francisco" could be 1 of 5 locations, but "San Francisco, US" yields only one result. To see the search results beforehand, you can check them here.
isMetric- Whether the temperature should be in metric (°C) or imperial (°F) units.
Remote IP- The first section of this request is
http://api.openweathermap.org, which is our endpoint. This is the value we put inside the
Remote IPAttribute. A couple of notes regarding this Attribute:
Remote Port- For the
Remote PortAttribute, this should be set to 80, which is the standard port for HTTP usage.
Method- Because we want to get data, the
MethodAttribute should be set to "GET".
Path- This is the specific path defined by the API provider. Usually, this is the text after the main root URL but before the
?character. In the case above, the path is
Authentication- This is used if the API requires a username and password, however OpenWeatherMap doesn't require this, so we set it to "None".
appidand needs to be used whenever attempting to retrieve data.
q=London. By looking at the documentation, you will see that the parameter
qis the "City name, state code and country code divided by comma".
unitsparameter should be set to "metric" or "imperial".
cityto build a Dictionary, which will form a query for each location in the
locationsListArray and put it into the
queryListArray is then used as a
Queryinput parameter for the
QueryInput Socket, overriding any information in the Node's
Request QueryAttribute. The
SetResponseFunction outputs a
Responseparameter that is used to set different
Bodyoutput (the response) into a Dictionary, we can use the new JSON Parse Node to convert the String. Because JSON can also be parsed as an Array, we need to tell Incari that we are expecting a Dictionary, not an Array. We do this by using the Conversion Node to cast the Any-type output of the JSON Parse Node to a Dictionary.
Responsevariable, we are getting another Dictionary called
main. From this, we are then able to get the temperature (
temp) as a Float. This structure (
temp) corresponds to the OpenWeatherMap documentation, which shows an example of the hierarchy of the API response.
ResponseDictionary-type Variable with the
SetResponseFunction, this output is passed to the
SetWeatherScreenValuesFunction and fed into a number of custom Functions to get the relevant key-value pairs and process them.