https://github.com/zurfyx/what-is-my-ip-address
Your external IP address in a JavaScript library.
https://github.com/zurfyx/what-is-my-ip-address
Last synced: about 2 months ago
JSON representation
Your external IP address in a JavaScript library.
- Host: GitHub
- URL: https://github.com/zurfyx/what-is-my-ip-address
- Owner: zurfyx
- License: mit
- Created: 2017-07-08T18:38:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-09T10:14:26.000Z (almost 8 years ago)
- Last Synced: 2025-03-06T08:18:10.376Z (2 months ago)
- Language: TypeScript
- Size: 51.8 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What Is My IP Address
> Your external IP address in a JavaScript library.
[](https://www.npmjs.com/package/what-is-my-ip-address)
[](https://travis-ci.org/zurfyx/what-is-my-ip-address)
[](https://david-dm.org/zurfyx/what-is-my-ip-address)
[](https://david-dm.org/zurfyx/what-is-my-ip-address#info=devDependencies)
[](https://coveralls.io/github/zurfyx/what-is-my-ip-address?branch=master)
[](https://codeclimate.com/github/zurfyx/what-is-my-ip-address)## Why?
I am aware that there are other libraries out there to get your public / external IP right with JavaScript ([public-ip](https://www.npmjs.com/package/public-ip), [external-ip](https://www.npmjs.com/package/external-ip)). But they faced a *serious* compatibility issue: they did not support ES5.
Although [some think that ES5 is a thing of a past](https://github.com/sindresorhus/ama/issues/446#issuecomment-281014491) (with all due respect), some builders are still requiring it, for example [Uglify](https://github.com/angular/angular-cli/issues/6370) (which comes built-in with angular-cli). Thus, it is currently [recommended to transpile to ES5](https://github.com/facebookincubator/create-react-app/issues/1125#issuecomment-264158377).
`What-Is-My-Ip-Address` aims to support developers looking forward to gather their IP address on the client side. The latest versions of Node should be fine regardless since they understand ES6.
## Getting started
`npm install --save what-is-my-ip-address`
IP v4:
```
var ip = require('what-is-my-ip-address');
ip.v4()
.then((ip) => {
...
})
.catch((error) => {
// Do you have IP v4?
});
```IP v6:
```
var ip = require('what-is-my-ip-address');
ip.v6()
.then((ip) => {
...
})
.catch((error) => {
// Do you have IP v6?
});
```## Contributions
Contributions are very welcome.
## Special thanks
To [@major/icanhaz](https://github.com/major/icanhaz) for his awesome IP address service.
## License
MIT © [Gerard Rovira Sánchez](//zurfyx.com)