Node.js implementation (using promises) of the Nuki Web API
npm install nuki-web-api!Logo
let token = "YOUR TOKEN"
let nuki = new Nuki(token)
nuki.getAccount().then(function(res) {
console.log('getAccount(): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getAccount(): ' + e.message)});
nuki.getSmartlocks().then(function(res) {
console.log('getSmartlocks(): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlocks(): ' + e.message)});
nuki.getSmartlock(smartlockId).then(function(res) {
console.log('getSmartlock(smartlockId): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlock(smartlockId): ' + e.message)});
nuki.getSmartlockAuths().then(function(res) {
console.log('getSmartlockAuths(): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockAuths(): ' + e.message)});
nuki.getSmartlockUsers().then(function(res) {
console.log('getSmartlockUsers(): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockUsers(): ' + e.message)});
nuki.getSmartlockAuth(smartlockId).then(function(res) {
console.log('getSmartlockAuth(smartlockId): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockAuth(smartlockId): ' + e.message)});
nuki.getSmartlockAuth(smartlockId, userId).then(function(res) {
console.log('getSmartlockAuth(smartlockId, userId): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartLockAuth(smartlockId, userId): ' + e.message)});
nuki.getSmartlockLogs().then(function(res) {
console.log('getSmartlockLogs(): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockLogs(): ' + e.message)});
nuki.getSmartlockLogs({limit: 3}).then(function(res) {
console.log('getSmartlockLogs({limit: 3}): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockLogs({limit: 3}): ' + e.message)});
nuki.getSmartlockLogs(smartlockId).then(function(res) {
console.log('getSmartlockLogs(smartlockId): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockLogs(smartlockId): ' + e.message)});
nuki.getSmartlockLogs(smartlockId, {limit: 3}).then(function(res) {
console.log('getSmartlockLogs(smartlockId, {limit: 3}): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSmartlockLogs(smartlockId, {limit: 3}): ' + e.message)});
nuki.getSubscription().then(function(res) {
console.log('getSubscription(): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSubscription(): ' + e.message)});
nuki.getSubscription(subscriptionId).then(function(res) {
console.log('getSubscription(subscriptionId): ' + JSON.stringify(res))
}).catch(function(e) {console.error('getSubscription(subscriptionId): ' + e.message)});
`
Example
You may find a full implemented example at https://github.com/Zefau/ioBroker.nuki2.
API documentation (v1.2.0, 31.05.2019)
The source code documentation for this Node.js implementation of the Nuki Web API can be found at https://zefau.github.io/nuki-web-api/Nuki.html.
Subsequently a list of supported operations. See https://developer.nuki.io/page/nuki-web-api-120/3 for Nuki Web API documentation and https://api.nuki.io/ for the original list of operations.
You may use _req(paths[, parameters, method, body, options]) function for any of the following operations, e.g. _req('/account'). See API documentation for specific usage.
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| delete | /account | Delete an account | not implemented yet |
| get | /account | Get an account | __getAccount() since 2.0.0__ |
| post | /account | Update an account | not implemented yet |
| put | /account | Create an account | not implemented yet |
| delete | /account/otp | Disables one time password for an account | not implemented yet |
| post | /account/otp | Enables one time password for an account | not implemented yet |
| put | /account/otp | Create an one time password secret | not implemented yet |
| post | /account/password/reset | Reset account password | not implemented yet |
| get | /account/sub | Get an list of sub accounts | not implemented yet |
| put | /account/sub | Create an sub account | not implemented yet |
| delete | /account/sub/{accountId} | Delete an sub account | not implemented yet |
| get | /account/sub/{accountId} | Get an sub account | not implemented yet |
| post | /account/sub/{accountId} | Update an sub account | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| post | /account/subscription/pay | Starts a payment for an account and returns a payment url | not implemented yet |
| post | /account/subscription/{id}/activate | Activates a previously terminated subscription | not implemented yet |
| post | /account/subscription/{id}/terminate | Terminates a running subscription | not implemented yet |
| get | /app/account/subscription | Get a list of account subscriptions | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /account/user | Get an list of account users | not implemented yet |
| put | /account/user | Create an account user | not implemented yet |
| delete | /account/user/{accountUserId} | Deletes asynchronous an account user | not implemented yet |
| get | /account/user/{accountUserId} | Get an account user | not implemented yet |
| post | /account/user/{accountUserId} | Update an account user | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /address | Get a list of addresses | not implemented yet |
| post | /address/{addressId} | Update an address | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /address/{addressId}/reservation | Get a list of address reservations | not implemented yet |
| post | /address/{addressId}/reservation/{id}/issue | Issues authorizations for an address reservation | not implemented yet |
| post | /address/{addressId}/reservation/{id}/revoke | Revoke authorizations for an address reservation | not implemented yet |
AddressToken
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /address/token/{id} | Gives some info about address token | not implemented yet |
| get | /address/token/{id}/redeem | Gives an redeemed address token | not implemented yet |
| post | /address/token/{id}/redeem | Redeems an address token | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /api/key | Get a list of api keys | not implemented yet |
| put | /api/key | Create an api key | not implemented yet |
| delete | /api/key/{apiKeyId} | Delete an api key | not implemented yet |
| post | /api/key/{apiKeyId} | Update an api key | not implemented yet |
| get | /api/key/{apiKeyId}/token | Get a list of api key tokens | not implemented yet |
| put | /api/key/{apiKeyId}/token | Create an api key token | not implemented yet |
| delete | /api/key/{apiKeyId}/token/{id} | Delete an api key token | not implemented yet |
| post | /api/key/{apiKeyId}/token/{id} | Update an api key token | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /company | Get an list of companies | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /notification | Get all notifications attached to your account | __getNotification() since 2.1.0__ |
| put | /notification | Create a notification configuration | not implemented yet |
| delete | /notification/{notificationId} | Delete a notification configuration | not implemented yet |
| get | /notification/{notificationId} | Get a notification configuration | __getNotification(notificationId) since 2.1.0__ |
| post | /notification/{notificationId} | Update a notification configuration | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /opener/brand | Get all intercom brands | __getBrand() since 2.1.0__ |
| get | /opener/brand/{brandId} | Get an intercom brand | __getBrand(brandId) since 2.1.0__ |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /opener/intercom | Get a list of intercom models | __getModel() since 2.1.0__ |
| get | /opener/intercom/{intercomId} | Get an intercom model | __getModel(intercomId) since 2.1.0__ |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /service/{serviceId} | Get a service | not implemented yet |
| post | /service/{serviceId}/link | Links a service | not implemented yet |
| post | /service/{serviceId}/sync | Syncs a service | not implemented yet |
| post | /service/{serviceId}/unlink | Unlinks a service | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /smartlock | Get a list of smartlocks | __getSmartLocks(parameters) since 2.0.0__ |
| put | /smartlock | Create a smartlock | not implemented yet |
| delete | /smartlock/{smartlockId} | Delete a smartlock | not implemented yet |
| get | /smartlock/{smartlockId} | Get a smartlock | __getSmartLock(smartlockId) since 2.0.0__ |
| post | /smartlock/{smartlockId} | Update a smartlock | __updateSmartlock(smartlockId, update) since 2.0.0__ |
| post | /smartlock/{smartlockId}/action | Lock & unlock a smartlock | __setAction(smartlockId, action) since 2.0.0__ |
| post | /smartlock/{smartlockId}/admin/pin | Updates a smartlock admin pin | not implemented yet |
| post | /smartlock/{smartlockId}/advanced/config | Updates a smartlock advanced config | __setAdvancedConfig(smartlockId, configuration) since 2.2.0__ |
| post | /smartlock/{smartlockId}/advanced/openerconfig | Updates an opener advanced config | __setAdvancedConfig(smartlockId, configuration) since 2.2.0__ |
| post | /smartlock/{smartlockId}/config | Updates a smartlock config | __setConfig(smartlockId, configuration) since 2.2.0__ |
| post | /smartlock/{smartlockId}/sync | Syncs a smartlock | not implemented yet |
| post | /smartlock/{smartlockId}/web/config | Updates a smartlock web config | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /smartlock/auth | Get a list of smartlock authorizations for your smartlocks | __getSmartLockAuths(parameters) since 2.0.0__ |
| put | /smartlock/auth | Creates asynchronous smartlock authorizations | not implemented yet |
| get | /smartlock/{smartlockId}/auth | Get a list of smartlock authorizations | __getSmartLockAuth(smartlockId) since 2.0.0__ |
| put | /smartlock/{smartlockId}/auth | Creates asynchronous a smartlock authorization | not implemented yet |
| delete | /smartlock/{smartlockId}/auth/{id} | Deletes asynchronous a smartlock authorization | not implemented yet |
| get | /smartlock/{smartlockId}/auth/{id} | Get a smartlock authorization | __getSmartLockAuth(smartlockId, userId) since 2.0.0__ |
| post | /smartlock/{smartlockId}/auth/{id} | Updates asynchronous a smartlock authorization | not implemented yet |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /smartlock/log | Get a list of smartlock logs for all of your smartlocks | __getSmartlockLogs(parameters) since 2.0.0__ |
| get | /smartlock/{smartlockId}/log | Get a list of smartlock logs | __getSmartlockLogs(smartlockId, parameters) since 2.0.0__ |
$3
| Request Type | Path | Action | Implemented |
| ------------ | ---- | ------ | --------- |
| get | /subscription | Get a list of subscriptions | __getSubscription() since 2.0.0__ |
| get | /subscription/{subscriptionId} | Get a subscription | __getSubscription(subscriptionId) since 2.0.0__ |
Changelog
$3
- (Zefau) added Opener support
- (Zefau) added Notification support
$3
- (Zefau) Node.js v6 compatibility
$3
- (Zefau) refactored the API implementation using request-promise
API Documentation (using JSDoc)
You may update the API documentation using JSDoc (https://github.com/jsdoc3/jsdoc#installation-and-usage):
`
jsdoc lib -d docs --template ../minami
``