# netatmo-api

> Node client for the Netatmo API

Latest version **0.0.2** (published 2015-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install netatmo-api
pnpm add netatmo-api
yarn add netatmo-api
bun add netatmo-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2015-03-21 |
| First published | 2015-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Josh Levine |
| Maintainers | joshlevine |

## Links

- npm: https://www.npmjs.com/package/netatmo-api
- Repository: https://github.com/jlevine22/node-netatmo-api
- Issues: https://github.com/jlevine22/node-netatmo-api/issues
- npm.io page: https://npm.io/package/netatmo-api

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^3.5.0
- [request](https://npm.io/package/request.md) ^2.53.0
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.14

## Recent versions

- 0.0.2 (latest) — 2015-03-21

## README

# netatmo-api

A node.js Netatmo API client that supports promises and callbacks. Read more about the Netatmo API here: [https://dev.netatmo.com/doc](https://dev.netatmo.com/doc).

## Installation
```
$ npm install https://github.com/jlevine22/node-netatmo-api.git --save
```

## Example Usage

Using promises:

    var NetatmoClient = require('netatmo-api');
	
    var client = new NetatmoClient({
    	clientId: 'YOUR_CLIENT_ID',
    	clientSecret: 'YOUR_CLIENT_SECRET'
    });

    client.getToken({
    	grant_type: 'password',
    	username: 'yournetatmoaccount@email.com',
    	password: 'yourpassword'
    }).then(function (token) {
        return client.getUser({ access_token: token.access_token });
    }).then(function (response) {
        console.log(response);
        // Do something with the response
    })
    .catch(NetatmoClient.errors.InvalidClientError, function (error) {
        console.log('Client id/Client secret credentials are invalid');
    })
    .catch(NetatmoClient.errors.AccessTokenExpiredError, function (error) {
        console.log('Access token is expired');
    })
    .catch(function (error) {
        console.log('Got some other error');
        console.log(error);
    });

Or if you prefer callbacks:

    var NetatmoClient = require('netatmo-api');

    var client = new NetatmoClient({
    	clientId: 'YOUR_CLIENT_ID',
    	clientSecret: 'YOUR_CLIENT_SECRET'
    });

    client.getToken({
    	grant_type: 'password',
    	username: 'yournetatmoaccount@email.com',
    	password: 'yourpassword'
    }, function (err, result) {
        if (err) {
            // Do something
            return;
        }
        client.getUser({ access_token: result.access_token }, function (err, result) {
            if (err) {
                // do something with error;
                return;
            }
            // Do something with the result
        })
    });
    
## Notes
The client object has methods corresponding with the [methods of the api](https://dev.netatmo.com/doc). Each of these methods takes 2 arguments:
- `options` An object consisting of key/value pairs to be passed to the api.
- `callback` An optional error first callback

The [Netatmo API docs](https://dev.netatmo.com/doc) has details on what parameters are required for which calls.

## Errors
The Netatmo API client may throw the following errors:
- `ForbiddenError`
- `AccessTokenExpiredError`
- `AccessTokenInvalidError`
- `InvalidClientError` Thrown during a `client.getToken()` call if the clientId or clientSecret is invalid
- `InvalidGrantError` Thrown during a `client.getTOken()` call if the grant_type is 'password' and the username and/or password is incorrect.
- `NotFoundError`
- `Error`ß

---
_Source: https://npm.io/package/netatmo-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
