:warning: Deprecation notice
The canihazip.com project stopped working. See the report at #2. As a fallback, this project is using ipify.org with patch 1.0.3 so it does not break old usages.
For new projects, I suggest using public-ip
. It is better maintained, built to be more robust (to avoid issues like #2) and has a better feature set.
Get public IP using canihazip.com ipify.org.
Install
To use it as a node module:
npm install --save canihazip
Or to use it as CLI:
npm install --global canihazip
Usage
As a node module:
var canihazip = require('canihazip');
var ip = canihazip();
As CLI:
canihazip
This will return IP of the current machine, for example: 1.2.3.4
.
License
MIT © Marko Grešak