Skip to main content
REST functions retrieve data from external HTTP APIs and return the results to the AI. They’re useful for integrating third-party services and real-time data sources.

Configuration

string
required
The URL endpoint to fetch data from
string
Jinja2 template to format the API response. The response is available as value_json.

Template Processing

The value_template receives the API response as value_json:

Advanced Configuration

Add custom HTTP headers:
Change the HTTP method (default is GET):
Add query parameters:

Use Cases

Third-party APIs

Integrate external services and data sources

Real-time Data

Fetch current information like weather, stocks, or news

Search Services

Query external search and lookup services

Status Checks

Monitor external service status and health

Best Practices

1

Handle API errors

APIs may return errors. Use safe filters and defaults:
2

Secure API keys

Never hardcode API keys in function definitions. Use Home Assistant secrets:
3

Format responses

Transform API responses into readable text for the AI:
4

Add timeouts

Set reasonable timeouts for external APIs:

Debugging

Enable logging to see API requests and responses:
Check the logs for:
  • Request URL and parameters
  • Response status code
  • Response body
  • Template rendering errors

Examples

Get Friend Names

Fetch and format data from a JSON API:
REST API Example

Cryptocurrency Prices

Weather Data

Next Steps

Scrape Functions

Extract web page data

Composite Functions

Combine with other functions

Template Functions

Format REST data