Skip to content

Commit dc10228

Browse files
committed
Version 1.0.0
0 parents  commit dc10228

File tree

7 files changed

+7006
-0
lines changed

7 files changed

+7006
-0
lines changed

.eslintrc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"env": {
3+
"es2021": true,
4+
"node": true
5+
},
6+
"extends": [
7+
"standard",
8+
"plugin:security/recommended",
9+
"plugin:node/recommended",
10+
"plugin:promise/recommended",
11+
"plugin:import/errors",
12+
"plugin:import/warnings"
13+
],
14+
"parserOptions": {
15+
"ecmaVersion": 12,
16+
"sourceType": "module"
17+
},
18+
"rules": {
19+
"comma-dangle": ["error", "always-multiline"]
20+
}
21+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

LICENSE.md

Lines changed: 660 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# netatmo-nodejs-api
2+
3+
[![license: AGPLv3](https://img.shields.io/badge/license-AGPLv3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
4+
[![GitHub release](https://img.shields.io/github/release/nioc/netatmo-nodejs-api.svg)](https://github.com/nioc/netatmo-nodejs-api/releases/latest)
5+
6+
Node.js API wrapper for Netatmo API.
7+
8+
## Key features
9+
- Authentication with all Netatmo provided methods:
10+
- Authorization code grant type
11+
- Client credentials grant type
12+
- Refresh token
13+
- Security API (get homes, get events)
14+
- Weather API (get public data, get stations data, get measure)
15+
16+
## Installation
17+
18+
``` bash
19+
npm install netatmo-nodejs-api
20+
```
21+
22+
## Usage
23+
24+
### Basic example with refresh token and client credentials grant type
25+
```js
26+
const { NetatmoClient, SCOPE_BASIC_CAMERA } = require('netatmo-nodejs-api')
27+
28+
// you need to set your own information
29+
const clientId = '60...'
30+
const clientSecret = 'abc...'
31+
const username = 'user@domain'
32+
const password = 'pass'
33+
let refreshToken = ''
34+
let accessToken = ''
35+
let expiresInTimestamp = 0
36+
37+
try {
38+
// create client
39+
const client = new NetatmoClient(clientId, clientSecret, SCOPE_BASIC_CAMERA, { timeout: 1000 })
40+
41+
// authenticate
42+
if (!client.checkAndSetAccesToken(accessToken, expiresInTimestamp)) {
43+
if (refreshToken) {
44+
// use previous refresh token
45+
({ accessToken, refreshToken, expiresInTimestamp } = await client.authenticateByRefreshToken(refreshToken))
46+
} else {
47+
// use user credentials
48+
({ accessToken, refreshToken, expiresInTimestamp } = await client.authenticateByClientCredentials(username, password))
49+
}
50+
// you should store accessToken, refreshToken, expiresInTimestamp for further request
51+
}
52+
53+
// get data
54+
const homes = await client.getHomes()
55+
} catch (error) {
56+
console.log(error)
57+
}
58+
```
59+
60+
## Versioning
61+
62+
netatmo-nodejs-api is maintained under the [semantic versioning](https://semver.org/) guidelines.
63+
64+
See the [releases](https://github.com/nioc/netatmo-nodejs-api/releases) on this repository for changelog.
65+
66+
## License
67+
68+
This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](LICENSE.md) file for details

0 commit comments

Comments
 (0)