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
Thevalue_template receives the API response as value_json:
Advanced Configuration
Headers
Headers
Add custom HTTP headers:
Method
Method
Change the HTTP method (default is GET):
Parameters
Parameters
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:- Request URL and parameters
- Response status code
- Response body
- Template rendering errors
Examples
Get Friend Names
Fetch and format data from a JSON API:Cryptocurrency Prices
Weather Data
Next Steps
Scrape Functions
Extract web page data
Composite Functions
Combine with other functions
Template Functions
Format REST data