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) ‑> Any

Perform a GET request.

Args

NameTypeDescription
uri str The path to request, relative to /api.

Returns

The response from the endpoint.

post

async def post(self, uri: str, body: Any) ‑> Any

Perform a POST request.

Args

NameTypeDescription
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) ‑> Any

Perform a PUT request.

Args

NameTypeDescription
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) ‑> Any

Perform a DELETE request.

Args

NameTypeDescription
uri str The path to request, relative to /api.

Returns

The response from the endpoint.

unregister

def unregister(self) ‑> None

Unregister this API instance.

on_realtime

def on_realtime(self, f: Callable[[str, Any], None]) ‑> Self

The realtime event is fired when such an event is received on this API endpoint.

Args

NameTypeDescription
f Callable[[str, Any], None] A callback that receives the name of the event and its data.

ApiRequest

class 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 Homey instance the app is running on. It can be used, for example, to access the App instance.

Ancestors

  • builtins.dict