# upnpjs

> A Node.js package for using UPnP

Latest version **1.1.1** (published 2020-12-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install upnpjs
pnpm add upnpjs
yarn add upnpjs
bun add upnpjs
```

Provides the command `upnp`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-12-10 |
| First published | 2020-01-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 27.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Mark Auger |
| Maintainers | swimauger |
| Keywords | UPnP, Universal Plug and Play |

## Links

- npm: https://www.npmjs.com/package/upnpjs
- Repository: https://github.com/swimauger/upnpjs
- Homepage: https://github.com/swimauger/upnpjs#readme
- Issues: https://github.com/swimauger/upnpjs/issues
- npm.io page: https://npm.io/package/upnpjs

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^3.0.0
- [jsdom](https://npm.io/package/jsdom.md) ^16.4.0

## Recent versions

- 1.1.1 (latest) — 2020-12-10
- 1.1.0 — 2020-09-27
- 1.0.3 — 2020-02-08
- 1.0.2 — 2020-01-30
- 1.0.1 — 2020-01-29
- 1.0.0 — 2020-01-29

## README

# UPnP Node.js Package

![](https://img.shields.io/npm/dw/upnpjs?color=204051&style=for-the-badge)
![](https://img.shields.io/github/license/swimauger/upnpjs?color=3B6978&style=for-the-badge)
![](https://img.shields.io/npm/v/upnpjs?color=84A9AC&style=for-the-badge)
![](https://img.shields.io/github/repo-size/swimauger/upnpjs?color=E7DFD5&label=Size&style=for-the-badge)

 Node.js package built for managing a router using UPnP.

## Installation
**Install upnpjs Library**
```bash
    npm install upnpjs
```

**Install upnp CLI**
```bash
    # Use `upnp -h` to show help menu
    npm install upnpjs -g
```

#

## Getting Started
*Discover the Internet Gateway Device*
```JavaScript
    const upnp = require('upnpjs');

    const igd = await upnp.discover();
```
<br>
And that's all there is to it. Follow the documentation bellow to see what can be done with the newly discovered Internet Gateway Device.

#

## InternetGatewayDevice
*InternetGatewayDevice allows access to different services potentially allowed by the device*

<br>

### **addPortMapping**
*Service action for mapping ports on the router*
```JavaScript
await igd.addPortMapping({
    ip: 192.168.0.4,
    internalPort: 54321,
    externalPort: 54321,
    protocol: 'TCP', // Defaults to TCP
    description: 'Example port map from 54321 -> 54321', // Defaults to empty string
    enabled: false // Defaults to true
});
```

<br>

### **deletePortMapping**
*Service action for removing port mappings on the router*
```JavaScript
await igd.deletePortMapping({
    externalPort: 12345,
    protocol: 'UDP'
});
```

<br>

### **getExternalIPAddress**
*Service action for retrieving external ip address*
```JavaScript
const ip = await igd.getExternalIPAddress();
```

<br>

### **getPortMappingList**
*Service action for listing all currently mapped ports on the router*
```JavaScript
const list = await igd.getPortMappingList();
```

<br>

### **getPortMapping**
*Service action for remtrieving a single port map by index*
```JavaScript
const portmap = await igd.getPortMapping(2);
```

#

## References
**Documents**

[UPnP Architecture](http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf) |
[Service Template](http://upnp.org/specs/gw/UPnP-gw-WANIPConnection-v2-Service.pdf) |
[UPnP Background](http://www.upnp-hacks.org/upnp.html) |
[Internet Gateway Device](http://www.upnp-hacks.org/igd.html) 

**Code Samples**

[miniupnp](https://github.com/miniupnp/miniupnp) |
[TinyUPnP](https://github.com/ofekp/TinyUPnP) |
[weupnp](https://github.com/bitletorg/weupnp) |
[upnpclient](https://github.com/flyte/upnpclient) |
[Node.js and SSDP](https://coolaj86.com/articles/adventures-in-upnp-with-node-js/)

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