ManagerApi
homey.manager.api
Manages web API access and realtime events to this app, as well as communication with other apps.
You can access this manager through the Homey instance as self.homey.api.
Ancestors
- Manager
- SimpleClass
- homey.util.event_emitter.EventEmitter
- typing.Generic
- abc.ABC
Methods
get
async def get(self, uri: str) ‑> AnyPerform a GET request.
Args
| Name | Type | Description |
|---|---|---|
uri |
str | The path to request, relative to /api. |
Returns
The response from the endpoint.
post
async def post(self, uri: str, body: Any) ‑> AnyPerform a POST request.
Args
| Name | Type | Description |
|---|---|---|
uri |
str | The path to request, relative to /api. |
body |
Any | A body to send with the request. |
Returns
The response from the endpoint.
put
async def put(self, uri: str, body: Any) ‑> AnyPerform a PUT request.
Args
| Name | Type | Description |
|---|---|---|
uri |
str | The path to request, relative to /api. |
body |
Any | A body to send with the request. |
Returns
The response from the endpoint.
delete
async def delete(self, uri: str) ‑> AnyPerform a DELETE request.
Args
| Name | Type | Description |
|---|---|---|
uri |
str | The path to request, relative to /api. |
Returns
The response from the endpoint.
realtime
async def realtime(self, event: str, data: Any) ‑> NoneEmit a realtime event.
Args
| Name | Type | Description |
|---|---|---|
event |
str | The name of the event. |
data |
Any | The data to send. |
get_api
def get_api(self, uri: str) ‑> ApiCreate an API instance, to receive realtime events.
Args
| Name | Type | Description |
|---|---|---|
uri |
str | The URI of the endpoint, e.g. homey:manager:webserver. |
Returns
An Api instance registered to the given uri.
get_api_app
def get_api_app(self, app_id: str) ‑> ApiAppCreate an app API instance, to receive realtime events.
Args
app_id:
Returns
An ApiApp instance registered to the given app.
unregister_api
def unregister_api(self, api: Api) ‑> NoneUnregister an API instance.
Args
| Name | Type | Description |
|---|---|---|
api |
Api | Api instance. |
get_local_url
async def get_local_url(self) ‑> strGet a url for local access.
get_owner_api_token
async def get_owner_api_token(self) ‑> strStart a new API session on behalf of the homey owner and return the API token. The API Token expires after not being used for two weeks.
Requires the homey:manager:api permission.
For more information about permissions read the Permissions tutorial.
Returns
An API token.