CallForCode weather API in Node-RED

I notice there are some changes in the usage of the weather API. For that reason I created a very simple sample with Node-RED to access the weather forecast. The Node-RED flow implements the access to the weather API you can use during your CallForCode challenge.

Here is what you need to do, to get access to the weather API:

  1. Register on Welcome to The Weather Company API Platform Site Powering the best Weather Apps & Sites
  2. You will get a mail with the apikey
  3. Then you can use the documentation to access the APIweather-api-doc-2019

Please ensure you have following simple settings for your REST API request in place:

  1. The HTTP header must contain Accept-Encoding: gzip
    The reason for that is, that all responses of the weather API requests are compressed. The Supported encoding format is: gzip
  2. Use the parameter apiKey

The following picture shows a simple postman this request:

postman-weather

Inside the flow you have to replace the text YOUR_WEATHER_APIKEY  with the apiKey you got in your mail. Beware you have to install node-red-contrib-gzip in your Node-RED to use the sample. You can get the Node-RED flow from GitHub.

In the following gif you can see the usage of the flow:

node-red-weather

For a more detailed understanding, how the weather service can be used in real world UseCases, please visit that awesome blog post from Va Barbosa All for code the weather company and you .

I hope this was useful for you and let’s see what’s next?

Greetings,

Thomas

PS: By the way, you can use the IBM Cloud for free, if you simply create an IBM Lite account. Here you only need an e-mail address.

#IBMDeveloper, #CallForCode, #Node-RED, #WeatherAPI

 

 

Cors and Node-RED using a simple forwarding server

When you use Node-RED on IBM Cloud during hackathons you will notice REST calls in flows cannot be directly invoked from a web application. The reason for this is mostly that cors (cross-origin resource sharing) is not enabled for the Node-RED server. This blog post is a simple workaround for this problem.

By the way, you can use the IBM Cloud for free, if you simply create an IBM Lite account. Here you only need an e-mail address.

I developed this workaround to have full control and be very flexible during a hackathon, when using Node-RED for prototyping and building integrations to services and web-applications, without changing Node-RED settings or using cors browser enabler.

Continue reading