{"_id":"nat-api","_rev":"4647369","name":"nat-api","description":"Port mapping with UPnP and NAT-PMP","dist-tags":{"latest":"0.3.1"},"maintainers":[{"name":"alxhotel","email":""}],"time":{"modified":"2026-04-10T20:22:14.000Z","created":"2019-10-01T19:05:02.808Z","0.3.1":"2021-08-16T11:49:56.270Z","0.3.0":"2020-05-09T19:50:51.163Z","0.1.3":"2020-02-05T15:17:09.677Z","0.1.2":"2020-01-12T20:03:41.316Z","0.1.1":"2020-01-10T21:22:43.310Z","0.1.0":"2019-10-14T01:00:10.790Z","0.0.1":"2019-10-01T19:05:02.808Z"},"users":{},"author":{"name":"Alex","email":"alxmorais8@msn.com"},"repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"versions":{"0.3.1":{"version":"0.3.1","name":"nat-api","description":"Port mapping with UPnP and NAT-PMP","main":"index.js","scripts":{"test":"standard"},"engines":{"node":">=10.0.0"},"dependencies":{"async":"^3.2.0","debug":"^4.2.0","default-gateway":"^6.0.2","request":"^2.88.2","unordered-array-remove":"^1.0.2","xml2js":"^0.1.0"},"devDependencies":{"standard":"^16.0.0"},"author":{"name":"Alex","email":"alxmorais8@msn.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"homepage":"https://github.com/alxhotel/nat-api#readme","keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"gitHead":"e404453ebca7e386fbd20f8dd7d86b8c9611058e","_id":"nat-api@0.3.1","_nodeVersion":"16.6.1","_npmVersion":"7.20.3","dist":{"shasum":"1e7808ed1c21c8c9b267d14be40cdb1e87d5271b","size":11327,"noattachment":false,"key":"/nat-api/-/nat-api-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.3.1.tgz"},"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"maintainers":[{"name":"alxhotel","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.3.1_1629114596156_0.5544089868132709"},"_hasShrinkwrap":false,"publish_time":1629114596270,"_cnpm_publish_time":1629114596270,"_cnpmcore_publish_time":"2021-12-18T06:56:47.068Z"},"0.3.0":{"version":"0.3.0","name":"nat-api","description":"Port mapping with UPnP and NAT-PMP","main":"index.js","scripts":{"test":"standard"},"engines":{"node":">=10.0.0"},"dependencies":{"async":"^3.1.0","debug":"^4.1.1","default-gateway":"^6.0.0","request":"^2.88.0","unordered-array-remove":"^1.0.2","xml2js":"^0.1.0"},"devDependencies":{"standard":"^14.3.1"},"author":{"name":"Alex","email":"alxmorais8@msn.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"homepage":"https://github.com/alxhotel/nat-api#readme","keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"gitHead":"8f78f25d7d5dc2d375efb918661936afeb73c1a4","_id":"nat-api@0.3.0","_nodeVersion":"13.8.0","_npmVersion":"6.14.5","dist":{"shasum":"ad0f9c676853df23d700fd100382f23bc853d631","size":11288,"noattachment":false,"key":"/nat-api/-/nat-api-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.3.0.tgz"},"maintainers":[{"name":"alxhotel","email":""}],"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.3.0_1589053851055_0.23936197595922803"},"_hasShrinkwrap":false,"publish_time":1589053851163,"_cnpm_publish_time":1589053851163,"_cnpmcore_publish_time":"2021-12-18T06:56:47.331Z"},"0.1.3":{"version":"0.1.3","name":"nat-api","scripts":{"test":"standard"},"main":"index.js","license":"MIT","author":{"name":"Alex","email":"alxmorais8@msn.com"},"repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"dependencies":{"async":"^3.1.0","default-gateway":"^5.0.5","request":"^2.88.0","unordered-array-remove":"^1.0.2","xml2js":"^0.1.0"},"description":"Port mapping with UPnP and NAT-PMP","devDependencies":{"standard":"^14.3.1"},"homepage":"https://github.com/alxhotel/nat-api#readme","keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"gitHead":"cbb4240656d7466ae1b3baa4c1c40e256c57b011","_id":"nat-api@0.1.3","_nodeVersion":"11.0.0","_npmVersion":"6.13.7","dist":{"shasum":"0cd3dc89a432879588ca4ac3d5a4a0188cda468e","size":11145,"noattachment":false,"key":"/nat-api/-/nat-api-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.1.3.tgz"},"maintainers":[{"name":"alxhotel","email":""}],"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.1.3_1580915829535_0.23566923719556643"},"_hasShrinkwrap":false,"publish_time":1580915829677,"_cnpm_publish_time":1580915829677,"_cnpmcore_publish_time":"2021-12-18T06:56:47.566Z"},"0.1.2":{"name":"nat-api","version":"0.1.2","description":"Port mapping with UPnP and NAT-PMP","main":"index.js","dependencies":{"async":"^3.1.0","default-gateway":"^5.0.5","nat-pmp":"github:yciabaud/node-nat-pmp#patch-1","request":"^2.88.0","unordered-array-remove":"^1.0.2","xml2js":"^0.1.0"},"devDependencies":{"standard":"^14.3.1"},"scripts":{"test":"standard"},"repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"author":{"name":"Alex","email":"alxmorais8@msn.com"},"license":"MIT","bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"homepage":"https://github.com/alxhotel/nat-api#readme","gitHead":"e16537dbb0bdc34041079f209da25593d45221eb","_id":"nat-api@0.1.2","_nodeVersion":"11.0.0","_npmVersion":"6.13.6","dist":{"shasum":"a70f4febd2018b2aeaf8d461d250ec24aeebd904","size":8749,"noattachment":false,"key":"/nat-api/-/nat-api-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.1.2.tgz"},"maintainers":[{"name":"alxhotel","email":""}],"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.1.2_1578859421178_0.5490327104883863"},"_hasShrinkwrap":false,"publish_time":1578859421316,"_cnpm_publish_time":1578859421316,"_cnpmcore_publish_time":"2021-12-18T06:56:47.804Z"},"0.1.1":{"name":"nat-api","version":"0.1.1","description":"Port mapping with UPnP and NAT-PMP","main":"index.js","dependencies":{"async":"^3.1.0","default-gateway":"^5.0.5","nat-pmp":"github:yciabaud/node-nat-pmp#patch-1","request":"^2.88.0","unordered-array-remove":"^1.0.2","xml2js":"^0.1.0"},"devDependencies":{"standard":"^14.3.1"},"scripts":{"test":"standard"},"repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"author":{"name":"Alex","email":"alxmorais8@msn.com"},"license":"MIT","bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"homepage":"https://github.com/alxhotel/nat-api#readme","gitHead":"bda1ce55b1fb4a1eaa5ec30f0d9dd1c835849beb","_id":"nat-api@0.1.1","_nodeVersion":"11.0.0","_npmVersion":"6.13.6","dist":{"shasum":"b9be48ae11245680a719cbf41f24ad3f7341393f","size":8745,"noattachment":false,"key":"/nat-api/-/nat-api-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.1.1.tgz"},"maintainers":[{"name":"alxhotel","email":""}],"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.1.1_1578691363169_0.5603258767988435"},"_hasShrinkwrap":false,"publish_time":1578691363310,"_cnpm_publish_time":1578691363310,"_cnpmcore_publish_time":"2021-12-18T06:56:48.017Z"},"0.1.0":{"name":"nat-api","version":"0.1.0","description":"Port mapping with UPnP and NAT-PMP","main":"index.js","dependencies":{"nat-pmp":"github:yciabaud/node-nat-pmp#patch-1","nat-upnp":"^1.1.1","default-gateway":"^5.0.3","unordered-array-remove":"^1.0.2"},"devDependencies":{"standard":"^14.3.1"},"scripts":{"test":"standard"},"repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"author":{"name":"Alex","email":"alxmorais8@msn.com"},"license":"MIT","bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"homepage":"https://github.com/alxhotel/nat-api#readme","gitHead":"31c19286eee27587f2a8f765cc9ff25e597a1c57","_id":"nat-api@0.1.0","_nodeVersion":"11.0.0","_npmVersion":"6.12.0","dist":{"shasum":"c1a84847ceb58d59209bc0b1ff47c11a0e17ae4c","size":4773,"noattachment":false,"key":"/nat-api/-/nat-api-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.1.0.tgz"},"maintainers":[{"name":"alxhotel","email":""}],"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.1.0_1571014810642_0.9505124103948461"},"_hasShrinkwrap":false,"publish_time":1571014810790,"_cnpm_publish_time":1571014810790,"_cnpmcore_publish_time":"2021-12-18T06:56:48.234Z"},"0.0.1":{"name":"nat-api","version":"0.0.1","description":"Port mapping with UPnP / NAT-PMP","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/alxhotel/nat-api.git"},"keywords":["nat","api","upnp","pmp","nat-pmp","holepunch","port","forwarding","map","mapping"],"author":{"name":"Alex","email":"alxmorais8@msn.com"},"license":"MIT","bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"homepage":"https://github.com/alxhotel/nat-api#readme","_id":"nat-api@0.0.1","_nodeVersion":"11.0.0","_npmVersion":"6.10.0","dist":{"shasum":"0c15bcc5713fe93246c6294e70441a9d8920a0c2","size":528,"noattachment":false,"key":"/nat-api/-/nat-api-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/nat-api/download/nat-api-0.0.1.tgz"},"maintainers":[{"name":"alxhotel","email":""}],"_npmUser":{"name":"alxhotel","email":"alxmorais8@msn.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nat-api_0.0.1_1569956702694_0.4362732698241807"},"_hasShrinkwrap":false,"publish_time":1569956702808,"_cnpm_publish_time":1569956702808,"_cnpmcore_publish_time":"2021-12-18T06:56:48.429Z"}},"readme":"# nat-api\n\n[![NPM Version][nat-api-ni]][nat-api-nu]\n[![Build Status][nat-api-ti]][nat-api-tu]\n[![Dependency Status][nat-api-di]][nat-api-du]\n[![Standard - Javascript Style Guide][standard-image]][standard-url]\n\nFast port mapping with **UPnP** and **NAT-PMP** in NodeJS.\n\n## Install\n\n**Required: NodeJS >= 10**\n\n```sh\nnpm install nat-api\n```\n\n## Usage\n\n```js\nconst NatAPI = require('nat-api')\n\nconst client = new NatAPI()\n\n// Map public port 1000 to private port 1000 with UDP and TCP\nclient.map(1000, function (err) {\n  if (err) return console.log('Error', err)\n  console.log('Port mapped!')\n})\n\n// Map public port 2000 to private port 3000 with UDP and TCP\nclient.map(2000, 3000, function (err) {\n  if (err) return console.log('Error', err)\n  console.log('Port mapped!')\n})\n\n// Map public port 4000 to private port 5000 with only UDP\nclient.map({ publicPort: 4000, privatePort: 5000, ttl: 1800, protocol: 'UDP' }, function (err) {\n  if (err) return console.log('Error', err)\n  console.log('Port mapped!')\n})\n\n// Unmap port public and private port 1000 with UDP and TCP\nclient.unmap(1000, function (err) {\n  if (err) return console.log('Error', err)\n  console.log('Port unmapped!') \n})\n\n// Get external IP\nclient.externalIp(function(err, ip) {\n  if (err) return console.log('Error', err)\n  console.log('External IP:', ip)\n})\n\n// Destroy object\nclient.destroy()\n```\n\n## API\n\n### `client = new NatAPI([opts])`\n\nCreate a new `nat-api` instance.\n\nIf `opts` is specified, then the default options (shown below) will be overridden.\n\n```js\n{\n  ttl: 1200, // Time to live of each port mapping in seconds (default: 1200)\n  autoUpdate: true, // Refresh all the port mapping to keep them from expiring (default: true)\n  gateway: '192.168.1.1', // Default gateway (default: null)\n  enablePMP: false // Enable PMP (default: false)\n}\n```\n\nIf `gateway` is not set, then `nat-api` will get the default gateway based on the current network interface.\n\n### `client.map(port, [callback])`\n* `port`: Public and private ports\n* `callback`\n\nThis method will use `port` por mapping the public port to the same private port.\n\nIt uses the default TTL and creates a map for UDP and TCP.\n\n### `client.map(publicPort, privatePort, [callback])`\n* `publicPort`: Public port\n* `privatePort`: Private port\n* `callback`\n\nThis is another quick way of mapping `publciPort` to `privatePort` with any protocol (UDP and TCP).\n\n### `client.map(opts, [callback])`\n* `opts`:\n - `publicPort`: Public port\n - `privatePort`: Private port\n - `protocol`: Port protocol (`UDP`, `TCP` or `null` for both)\n - `ttl`: Overwrite the default TTL in seconds.\n - `description`: Description of the port mapping\n* `callback`\n\n### `client.unmap(port, [callback])`\n\nUnmap any port that has the public port or private port equal to `port`.\n\n### `client.unmap(publicPort, privatePort, [callback])`\n\nUnmap any port that has the public port or private port equal to `publicPort` and `privatePort`, respectively.\n\n### `client.unmap(opts, [callback])`\n\nUnmap any port that contains the parameters provided in `opts`.\n\n### `client.externalIp([callback])`\n* `callback(err, ip)`\n\nGet the external IP address.\n\n### `client.destroy([callback])`\n\nDestroy the client. Unmaps all the ports open with `nat-api` and cleans up large data structure resources.\n\n## Additional Information\n\n- http://miniupnp.free.fr/nat-pmp.html\n- http://wikipedia.org/wiki/NAT_Port_Mapping_Protocol\n- http://tools.ietf.org/html/draft-cheshire-nat-pmp-03\n\n\n## License\n\nMIT. Copyright (c) [Alex](https://github.com/alxhotel)\n\n[nat-api-ti]: https://img.shields.io/travis/com/alxhotel/nat-api/master.svg\n[nat-api-tu]: https://travis-ci.com/alxhotel/nat-api\n[nat-api-ni]: https://img.shields.io/npm/v/nat-api.svg\n[nat-api-nu]: https://npmjs.org/package/nat-api\n[nat-api-di]: https://david-dm.org/alxhotel/nat-api/status.svg\n[nat-api-du]: https://david-dm.org/alxhotel/nat-api\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n","_attachments":{},"homepage":"https://github.com/alxhotel/nat-api#readme","bugs":{"url":"https://github.com/alxhotel/nat-api/issues"},"license":"MIT"}