Api
homey.api
A web API endpoint on Homey. When registered, realtime events sent to the endpoint are fired on the instance.
Ancestors
- homey.util.event_emitter.EventEmitter
- typing.Generic
Subclasses
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.
unregister
def unregister(self) ‑> NoneUnregister this API instance.
on_realtime
def on_realtime(self, f: Callable[[str, Any], None]) ‑> SelfThe realtime event is fired when such an event is received on this API endpoint.
Args
| Name | Type | Description |
|---|---|---|
f |
Callable[[str, Any], None] | A callback that receives the name of the event and its data. |
ApiRequest
An API request, as received in the api.py implementation of the app.
- query: query parameters passed along with the request.
- params: a set of parameters defined in the path of the endpoint.
- body: the request body. JSON is automatically parsed.
- homey: the
Homeyinstance the app is running on. It can be used, for example, to access the App instance.
Ancestors
- builtins.dict