Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
netatmo-nodejs-api
Advanced tools
Readme
Node.js API wrapper for Netatmo API.
npm install netatmo-nodejs-api
const { NetatmoClient, SCOPE_BASIC_CAMERA } = require('netatmo-nodejs-api')
// you need to set your own information
const clientId = '60...'
const clientSecret = 'abc...'
const username = 'user@domain'
const password = 'pass'
let refreshToken = ''
let accessToken = ''
let expiresInTimestamp = 0
try {
// create client
const client = new NetatmoClient(clientId, clientSecret, SCOPE_BASIC_CAMERA, { timeout: 1000 })
// authenticate
if (!client.checkAndSetAccesToken(accessToken, expiresInTimestamp)) {
if (refreshToken) {
// use previous refresh token
({ accessToken, refreshToken, expiresInTimestamp } = await client.authenticateByRefreshToken(refreshToken))
} else {
// use user credentials
({ accessToken, refreshToken, expiresInTimestamp } = await client.authenticateByClientCredentials(username, password))
}
// you should store accessToken, refreshToken, expiresInTimestamp for further request
}
// get data
const homes = await client.getHomes()
} catch (error) {
console.log(error)
}
You can use the authenticate
method which wrap 3 authentication methods.
const { NetatmoClient, SCOPE_BASIC_CAMERA } = require('netatmo-nodejs-api')
// you need to set your own information
const clientId = '60...'
const clientSecret = 'abc...'
const username = 'user@domain'
const password = 'pass'
let refreshToken = ''
let accessToken = ''
let expiresInTimestamp = 0
try {
// create client
const client = new NetatmoClient(clientId, clientSecret, SCOPE_BASIC_CAMERA, { timeout: 1000 })
// authenticate
({ accessToken, refreshToken, expiresInTimestamp } = await client.authenticate(accessToken, refreshToken, expiresInTimestamp, username, password))
// you should store accessToken, refreshToken, expiresInTimestamp for further request
// get data
const homes = await client.getHomes()
} catch (error) {
console.log(error)
}
netatmo-nodejs-api is maintained under the semantic versioning guidelines.
See the releases on this repository for changelog.
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details
FAQs
Node.js API wrapper for Netatmo API.
The npm package netatmo-nodejs-api receives a total of 10 weekly downloads. As such, netatmo-nodejs-api popularity was classified as not popular.
We found that netatmo-nodejs-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.