API
The API node provides access to all points of the Home Assistant WebSocket and HTTP API. This enables you to interact programmatically with Home Assistant, sending and receiving data through these protocols. It’s a powerful tool for integrating third-party systems, custom automations, or advanced control within Node-RED, offering full access to Home Assistant's core functionalities.
Config
Protocol required
- Type:
string
- Values:
websocket|http
- Default:
websocket
Protocol to use to access Home Assistant API.
Method
- Type:
string
- Values:
get|post
Type of method to use to access the HTTP endpoint.
Path
- Type:
string
- Accepts Mustache Templates
URL of the API endpoint.
Params
- Type:
Object
- Accepts Mustache Templates
A JSON object with key/value pairs that will be converted into URL parameters.
Data
- Type:
Object
- Accepts Mustache Templates when the data type is JSON
JSON Object to send for WebSocket requests and HTTP posts.
Results
Type:
string
Location to save the API results.
Input
All properties need to be under msg.payload
.
protocol
- Type:
string
- Values:
websocket|http
Overrides or sets the protocol property of the config.
method
- Type:
string
- Values:
get|post
Overrides or sets the method property of the config.
path
- Type:
string
Overrides or sets the path property of the config.
data
- Type:
Object|string
Overrides or sets the data/params property of the config.
location
- Type:
string
Overrides or sets the results property of the config.
locationType
- Type:
string
- Values:
msg|flow|global
Overrides or sets the results type property of the config.
Output
Value types:
results
: results of the API requestconfig
: config properties of the node