Web Relayexample

...or how to integrate with web APIs

In this example, we'll use a Web Relay to integrate with a web service and send temperature, pressure and humidity values to the web API of Windy.

Windy is a meteo service, which accepts public data from personal meteo stations, creating a world-wide meteo map

Prerequisites

This example builds upon the Meteo example and the Weblink example.

It assumes you already have a functional environment-sensitive device, which is connected to the internet and has an operational Weblink.

For details, check

Let's go!

Get Windy API key

Before we make our Web Relay for sending data to Windy, first we need to get a Windy API key.

The API key is a kind of a personal code, which is associated with you and your meteo station.
As Windy gets data from many stations, it recognizes the sender by this API key.

To get your API key from Windy, you need to create a Windy account.

You can manage your stations and see their API keys on the following page:
https://stations.windy.com/stations

Create an account, add a weather station, fill its details and get its API key.

Create a Web Relay

Now, having an API key, we're ready to set up a Web Relay and send data through to Windy

Go to your project's page and click on the New Web Relay button.

A new Web Relay will be created and you will be redirected to its settings page.

Here, you can set up the HTTP request, which the Web Relay will send towards the Windy server.
  • For Method, choose GET
  • For URL, set
    https://stations.windy.com/pws/update/[API-KEY]?temp={{AirSensor.temperature}}&mbar={{AirSensor.pressure}}
    ...but instead of the [API-KEY] part, put your own API key which you've obtained from Windy

And it's ready! The device will now be sending data to Windy.

The frequency of the data feed from your device is determined by the Feed Interval of the Weblink. For reference, check the Weblink example.

Check your station on the map

To see your station and its readings on the Windy map, go to
https://stations.windy.com/stations
and click the button of your station or simply go to the Map and locate it.

Done!

This concludes the practical part of the example.
Following below are some related additional details.

Supplemental

Windy API details

For more details about the Windy API, check out these posts:
https://community.windy.com/topic/8168/report-your-weather-station-data-to-windy
https://community.windy.com/topic/8285/how-to-access-the-windy-stations-data

How Web Relay works

The Web Relay sends data to Windy, in this case by encoding the data values in the URL and passing it to the Windy server.
In the actual URL that is sent to the server, the {{AirSensor.temperature}} and {{AirSensor.pressure}} parts will be replaced by their respective values from the current readings of the device, so the url may for example, look something like
https://stations.windy.com/pws/update/[API-KEY]?temp=23.8&mbar=982.5
...where the [API-KEY] is your API key obtained from Windy.

You should input your actual API key in the URL field instead of [API-KEY]

Web Relay is universal

Last thing to mention - Web Relay is universal.
This example just happens to be meteo-related and using Windy's services.
With Web Relay, your device can make calls to any web service and pass any of its properties in freely configurable web requests.

In fact, if you have multiple Web Relays in one project, the device will effectively pass data to multiple servers!