ManagerApi

You can access this manager through the Homey instance as this.homey.api

Methods

delete

delete(uri): Promise.<any>

Perform a DELETE request.

Parameters

Name Type Description
uri
string

The path to request, relative to /api.

Returns

Promise.<any>

get

get(uri): Promise.<any>

Perform a GET request.

Parameters

Name Type Description
uri
string

The path to request, relative to /api.

Returns

Promise.<any>

getApi

getApi(uri): Api

Create an Api instance, to receive realtime events.

Parameters

Name Type Description
uri
string

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

Returns

Api

getApiApp

getApiApp(appId): Api

Create an ApiApp instance, to receive realtime events.

Parameters

Name Type Description
appId
string

The ID of the App, e.g. com.athom.foo

Returns

Api

getLocalUrl

(async) getLocalUrl(): Promise.<string>

Returns the url for local access.

Requires the homey:manager:api permission. For more information about permissions read the Permissions tutorial.

Returns

Promise.<string>

getOwnerApiToken

(async) getOwnerApiToken(): Promise.<string>

Starts a new API session on behalf of the homey owner and returns 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

Promise.<string>

post

post(uri, body): Promise.<any>

Perform a POST request.

Parameters

Name Type Description
uri
string

The path to request, relative to /api.

body
any

The body of the request.

Returns

Promise.<any>

put

put(uri, body): Promise.<any>

Perform a PUT request.

Parameters

Name Type Description
uri
string

The path to request, relative to /api.

body
any

The body of the request.

Returns

Promise.<any>

realtime

realtime(event, data)

Emit a realtime event.

Parameters

Name Type Description
event
string

The name of the event

data
any

The data of the event

unregisterApi

unregisterApi(api)

Unregister an Api instance.

Parameters

Name Type Description
api
Api