diff --git a/source/developers/api.markdown b/source/developers/api.markdown index b5828d9e729..543bb06aa33 100644 --- a/source/developers/api.markdown +++ b/source/developers/api.markdown @@ -18,12 +18,28 @@ In the package [`homeassistant.remote`](https://github.com/balloob/home-assistan The API accepts and returns only JSON encoded objects. All API calls have to be accompanied by the header `X-HA-Access: YOUR_PASSWORD` (YOUR_PASSWORD as specified in your `configuration.yaml`). +There are several ways to consume the Home Assistant API. One is with `curl`: + ```bash curl -X GET \ -H "x-ha-access: YOUR_PASSWORD" \ http://localhost:8123/api ``` +Another option is to use Python and the [Requests](http://docs.python-requests.org/en/latest/) module. + +```python +from requests import get + +url = 'http://localhost:8123/api/' +headers = {'x-ha-access': 'YOUR_PASSWORD', + 'content-type': 'application/json'} + +response = get(url, headers=headers) + +print(response.text) +``` +

You can append ?api_password=YOUR_PASSWORD to any url to log in automatically.

@@ -251,3 +267,4 @@ It will return a message if event forwarding was cancelled successful.

If your client does not support DELETE HTTP requests you can add an optional attribute _METHOD and set its value to DELETE.

+