This article shows how to read a web API (a cloud meter, a weather service, a third-party platform) with the HTTP driver in client mode, from the gateway creation to the use of the response in a route. The example reads the current outdoor temperature from the public Open-Meteo API, which needs no account, then adds authentication for APIs that require it.
The HTTP driver page is the reference for every parameter. This article is the step-by-step method.
The one thing to remember: in client mode, the response is not written to the address you created but to a read-only twin whose path starts with
#.%http-get:/v1/forecastsends the request,%http-get:#/v1/forecastholds the answer.
client. The form then shows the client parameters only.https://api.open-meteo.com. The path of each address is appended to it, with a single / between the two.Accept / application/json or an API key header such as X-Api-Key / <your key>. A header sent with a specific request (section 4) takes precedence over a gateway header of the same name.none for now and confirm. Start the gateway: it turns green (CONNECTED).The HTTP driver needs a licence. Without it the gateway does not start and its log shows
missing license: contact support@weble.ch.
%http-get:; type the path after it:/v1/forecast?latitude=46.20&longitude=6.15¤t=temperature_2m60000 (one request per minute) and confirm.| Address | Content |
|---|---|
%http-get:/v1/forecast?latitude=46.20&longitude=6.15¤t=temperature_2m |
The request. Its status shows the result of the last call: online, or ! followed by the HTTP status code or the network error (for example ! 404). |
%http-get:#/v1/forecast |
The last response, parsed as JSON when possible. This is the address to use in routes, logs and logic. |
%http-get:#lastQuery |
The last response received by any GET address of this gateway, with its URL. |
Because the address contains a query string, the twin holds an object that recalls the query next to the response:
{
"query": { "latitude": "46.20", "longitude": "6.15", "current": "temperature_2m" },
"body": {
"latitude": 46.203693, "longitude": 6.145807, "timezone": "GMT", "elevation": 405,
"current_units": { "time": "iso8601", "interval": "seconds", "temperature_2m": "°C" },
"current": { "time": "2026-11-25T09:45", "interval": 900, "temperature_2m": 5.5 }
},
"url": "/v1/forecast?latitude=46.20&longitude=6.15¤t=temperature_2m"
}
Without a query string in the address (for example %http-get:/api/v1/status), the twin holds the response itself.
The query string is not part of the twin's name: two addresses that differ only by their query string share the same
#twin. Give each request its own path when you need separate values.
A request is sent at each Polling period and each time a value is written to the request address. Leave Polling empty or at 0 to send the request only on demand, for instance from a route or a logic.
A request is successful only when the server answers with status 200. Any other status code is shown on the request address as ! <code>, and the request is sent again at the next polling period.
Choose the method in Auth. Method:
| Auth. Method | What the gateway sends | Fields to fill |
|---|---|---|
none |
Nothing. Use Headers for an API key. | — |
Bearer basic |
HTTP Basic authentication (Authorization: Basic …) on every request. |
Username, Password |
oAuth2 |
A token requested from the token endpoint, then Authorization: <token_type> <access_token> on every request. |
oAuth2 url, Client_id, Client_secret, Scope, Grant type, Request type |
For OAuth2:
https://auth.example.com/oauth/token. https:// is assumed when no scheme is given.client_credentials: Client_id, Client_secret and Scope are sent (empty fields are left out);password: Username and Password are sent as well.POST/x-www-form-urlencoded (form body, the most common) or POST/body (JSON body).expires_in of the token response).If the token endpoint does not answer with status 200, the gateway stops with invalid oAuth response <code> in its log and restarts: check the URL, the identifiers and the request type with the provider's documentation.
A header named Authorization defined in Headers replaces the OAuth2 token.
What you write to a request address becomes the request. It can be a plain value, sent as the body, or an object with up to three keys:
{
"headers": { "X-Request-Id": "wbox-42" },
"query": { "from": "2026-11-24", "to": "2026-11-25" },
"body": { "setpoint": 21.5 }
}
?from=…&to=…), merged with the query string already present in the address;Content-type: application/json.Each method has its own tab and prefix: %http-get:, %http-post:, %http-put:, %http-patch:, %http-delete:. A typical command to a REST API is a POST address written by a route:
%http-post:/api/v1/devices/12/command{"body": {"mode": "eco"}}%http-post:#/api/v1/devices/12/commandAn address can also hold a complete URL (%http-get:https://other.example.com/status), which is then used as is, ignoring the gateway URL.
In client mode, the values written to the request addresses are not kept across restarts. A polled request must therefore not depend on a value written once: put its parameters in the address name (query string, as in section 2) or in Headers, and keep the
{headers, query, body}object for requests sent by a route or a logic.
60000) or a cron expression in standard syntax (*/15 * * * * = every 15 minutes, 0 6 * * 1 = Mondays at 06:00).The # twin is an ordinary read-only address: it can be logged, shown in a dashboard and used as the source of a route.
Extract a value with a route. To copy the temperature into a BACnet object read by the building management system:
%http-get:#/v1/forecast and destination %bac:local/analogValue:1/presentValue.function (value, source, dest, info) {
// value = content of the # twin: { query, body, url } here
var body = value && value.body;
if (body && body.current && typeof body.current.temperature_2m === 'number') {
return body.current.temperature_2m;
}
}
Without a query string in the request address, the twin holds the response directly: read value.current.temperature_2m instead of value.body.current.temperature_2m.
The same extraction can be built with Blockly blocks (see Route functions), and a logic can read the twin like any other address.
Supervise the API. Add a route of type status on the request address (without #) to raise an alarm when its status starts with !. See Email gateway status alerts for a complete alerting example.
| Symptom | Cause and fix |
|---|---|
| The request address stays empty | Normal: the response is on the # twin of the address. |
No request is sent, the gateway log shows no polling configured |
No address of the gateway has a Polling value. Set one, or write a value to the address to send it once. |
Status ! 401 or ! 403 |
Wrong credentials, API key or scope. Check Auth. Method, Headers and the rights of the API account. |
Status ! 404 |
Wrong path: the address path is appended to URL. Check that the two do not repeat a segment. |
Status ! 429 |
Too many calls: increase Polling or Idle timeout. |
Status other than online although the API answers |
Only status 200 is treated as success. Check the status code returned by the API with its documentation. |
The gateway restarts in a loop, log shows invalid oAuth response or invalid oAuth2 host |
OAuth2 token request refused, or oAuth2 url empty. See section 3. |
| A polled request fails after a restart, although it worked before | It relied on a value written once, which is not kept. See the warning in section 4. |
The gateway does not start, log shows missing license |
The gateway has no HTTP licence. |