You are currently viewing the Homey Apps SDK v2 documentation. New apps should use Homey Apps SDK v3 ››

Homey.Api

const { Api } = require('homey');

This class represents an API endpoint on Homey. When registered, realtime events are fired on the instance.

Table of Contents

Constructor

new Homey.Api(uri)

Parameters:
Name Type Description
uri string

The URI of the endpoint, e.g. homey:manager:webserver

Methods

delete(path, callbackopt)

Perform a DELETE request.

Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

callback genericCallbackFunction <optional>
Returns:

Promise

get(path, callbackopt)

Perform a GET request.

Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

callback genericCallbackFunction <optional>
Returns:

Promise

post(path, body, callbackopt)

Perform a POST request.

Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

body *

The body of the request.

callback genericCallbackFunction <optional>
Returns:

Promise

put(path, body, callbackopt)

Perform a PUT request.

Parameters:
Name Type Attributes Description
path string

The path of the request, relative to the endpoint.

body *

The body of the request.

callback genericCallbackFunction <optional>
Returns:

Promise

register() → {Api}

Register the API, to receive incoming realtime events. This is a shorthand method for ManagerApi#registerApi.

Returns:
Type:
Api

unregister()

Unregister the API. This is a shorthand method for ManagerApi#unregisterApi.