# Node-RED

[Node-RED](https://nodered.org/) is a visual flow-based programming tool commonly used for home automation and IoT. It runs on Node.js and lets you wire together APIs, hardware devices, and online services using a browser-based drag-and-drop editor.

Node-RED is useful as middleware between Brewfather and other systems. Common use cases include:

* **Forwarding device data** from one service to another (e.g., from a sensor to Brewfather's Custom Stream)
* **Automating actions** based on Brewfather data (e.g., sending notifications when gravity drops below a threshold)
* **Aggregating data** from multiple sources into a single dashboard

Brewfather does not have a dedicated Node-RED setup wizard in the app UI. Instead, use one of these patterns:

## Option A: API-based flows (pull/poll)

Use this approach when you want Node-RED to **read data from Brewfather** -- for example, fetching batch status, recipe details, or fermentation readings on a schedule.

1. Open **Settings > Integration > Generate API-Key**.
2. Select required scopes.
3. Copy both:
   * **API-Key**
   * **User Id**
4. Configure your Node-RED flow to call the Brewfather API.

API docs: <https://api.brewfather.app>

> In the current UI, **Generate Key** is only shown when no user API key exists. Delete/regenerate when rotating keys.

## Option B: Webhook-based flows (push)

Use this approach when you want Brewfather to **push device data to Node-RED** in real time. Each time a device logs a reading, Brewfather forwards it to your Node-RED endpoint.

1. Create an HTTPS endpoint in Node-RED.
2. In Brewfather, open **Settings > Power-ups** for a supported integration.
3. Click **(configure webhook)** and add your endpoint URL.
4. Choose **Processed** or **Raw** format.

Webhook guide: [Webhook (Device Forwarding)](/integrations/webhook.md)

## Option C: Post to Custom Stream

Use this approach when you want Node-RED to **send data to Brewfather** -- for example, collecting sensor data from custom hardware and forwarding it to Brewfather for logging in a batch.

Configure a Node-RED HTTP POST node to send JSON data to your Brewfather [Custom Stream](/integrations/custom-stream.md) endpoint.

## Node-RED package

Community package:

<https://flows.nodered.org/node/node-red-contrib-brewfather>

## Related docs

* [Custom Endpoint](/integrations/custom-api-endpoint.md)
* [Webhook (Device Forwarding)](/integrations/webhook.md)
* [API](/api.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.brewfather.app/integrations/node-red.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
