apiKey
- The 32-character API key, unique to your OpenWeatherMap account.city
- The city which you want to retrieve the weather for. To reduce ambiguity problems with city names, it is better to use the city name and country. "San Francisco" could be 1 of 5 locations, so "San Francisco, US" will give much more specific results. To see the search results beforehand, you can check them here.isMetric
- Whether or not the temperature should be in metric (°C) or imperial (°F) units.city
variable.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 IP
Attribute. A couple of notes regarding this Attribute:Remote Port
- For the Remote Port
Attribute, this should be set to 80, which is the standard port for HTTP usage.Method
- Because we want to get data, the Method
Attribute 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 /data/2.5/weather
.Authentication
- This is used if the API requires a username and password, however OpenWeatherMap doesn't require this, so we set it to "None".Default Headers
- This allows us to add additional information in the form of key-value pairs, using HTTP headers. For our example, though, we don't need to add any.appid
and needs to be used whenever attempting to retrieve data.q=London
. By looking at the documentation, you will see that the parameter q
is the "City name, state code and country code divided by comma".units
parameter should be set to "metric" or "imperial".isMetric
, apiKey
, and city
to build a Dictionary, which will form our query
Variable.Query
input socket of the HTTP GET Node, overriding any information in its Request Query
Attribute.Body
output (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.Response
variable, we are getting another Dictionary called main
. From this, we are then able to get the temperature (temp
) as a Float. This structure (main
> temp
) corresponds to the OpenWeatherMap documentation, which shows an example of the hierarchy of the API response.Output
of the JSON Parse Node into the Value
input of a Dictionary-type variable (called Response
in this case), it is possible to trigger Logic in several places whenever the value of that Variable is set. This Variable is then fed into a number of custom Functions to get the relevant key-value pairs and process them so that the text and images of the weather app change to reflect the API response.