# arlo-api

> Thin API for interacting with Arlo

Latest version **1.0.11** (published 2023-03-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2023-03-04 |
| First published | 2023-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 72.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Will O'Donnell |
| Maintainers | wo-d |
| Keywords | arlo, homebridge, mfa |

## Links

- npm: https://www.npmjs.com/package/arlo-api
- Repository: https://github.com/wo-d/arlo-api
- Homepage: https://github.com/wo-d/arlo-api#readme
- Issues: https://github.com/wo-d/arlo-api/issues
- npm.io page: https://npm.io/package/arlo-api

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^1.3.3
- [mailparser](https://npm.io/package/mailparser.md) ^3.6.3
- [imap-simple](https://npm.io/package/imap-simple.md) ^5.1.0
- [tough-cookie](https://npm.io/package/tough-cookie.md) ^4.1.2
- [node-html-parser](https://npm.io/package/node-html-parser.md) ^6.1.5
- [axios-cookiejar-support](https://npm.io/package/axios-cookiejar-support.md) ^4.0.6

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.11 (latest) — 2023-03-04
- 1.0.10 — 2023-03-04
- 1.0.9 — 2023-03-03
- 1.0.8 — 2023-03-02
- 1.0.7 — 2023-03-02
- 1.0.6 — 2023-02-27
- 1.0.5 — 2023-02-23
- 1.0.4 — 2023-02-23
- 1.0.3 — 2023-02-23
- 1.0.2 — 2023-02-23
- 1.0.1 — 2023-02-23
- 1.0.0 — 2023-02-23

## README

# arlo-api

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/wo-d/arlo-api/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/wo-d/arlo-api/tree/main)

<a href="https://www.npmjs.com/package/arlo-api"><img title="npm version" src="https://badgen.net/npm/v/arlo-api" ></a>

Thin API for interacting with Arlo

<img src="./images/logo.png" alt="arlo-api-logo" width='162' />

## Usage

```ts
import { Basestation } from './basestation';

const arlo = new Client(config);

// `result` contains necessary information to make further requests
// allowing you to consume just the login result in your library.
const result = await arlo.login();

// Now that arlo has been logged in get the device matching type basestation.
const device = await arlo.getDevice({ deviceType: 'basestation' });

// Construct a new basestation object using our arlo client and the the basestation device.
const basestation = new Basestation(arlo, device);

// Setup event listeners.
basestation.on(ARLO_EVENTS.open, () => {});

basestation.on(ARLO_EVENTS.close, () => {});

// Start event stream.
await basestation.startStream();
```

### Authentication

Currently, email is the only supported MFA method. Caveat I've only tested with Gmail. The library will mark Arlo OTP emails has read. A future release will allow deletion based on a configuration value.

#### Configuration

```ts
{
  arloUser: 'something@somewhere.com',
  arloPassword: 'super secret password',
  emailUser: 'myemail@gmail.com',
  emailPassword: 'another secret password',
  emailServer: 'imap.gmail.com',
  emailImapPort: 993
}
```

The `emailUser` must match one of the configured MFA sources in Arlo.

#### Gmail

Gmail has certain limitations when trying to connect from a third party app using just username and password. As of May 2022 Google blocked "less secure apps" from accessing their email services. You have to [manually opt in](https://support.google.com/accounts/answer/6010255?hl=en) and then set up a separate password for a third party. Additionally, you must [enable IMAP](https://support.google.com/mail/answer/7126229?hl=en) in Gmail.

### Tests

Tests make use of `dotenv` package for providing environment variables to the running process.

Create a `.env` file at the root of the solution and supply it with whatever your secrets are.

```
ARLO_USER="user@gmail.com"
ARLO_PASSWORD="password"
EMAIL_USER="other_user@gmail.com"
EMAIL_PASSWORD="password2"
```

You can also skip the login flow if you've already received a login result object and instead use the following secrets.

```
SERIAL_NUMBER="serial"
SESSION_EXPIRES="session_expiration"
TOKEN="token"
USER_ID="userId"
```

And then use the provided `_shortCircuitLogin` method.

```ts
const arlo = new Client(config);

const loginResult: LoginResult = {
  serialNumber: process.env.SERIAL_NUMBER as string,
  sessionExpires: Number.parseInt(process.env.SESSION_EXPIRES as string),
  token: process.env.TOKEN as string,
  userId: process.env.USER_ID as string,
};

arlo._shortCircuitLogin(loginResult);
```

### References

Based on [JOHNEPPILLAR's](https://github.com/JOHNEPPILLAR/arlo) and [easton36's](https://github.com/easton36/arlo.js) great work.

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