Icanhazip
DevelopmentThe IP Address API is an invaluable tool for any developer, cybersecurity expert, or hobbyist interested in acquiring a user's IP address through straightforward means. Hosted on "icanhazip.com", the API returns a user's IP address in a plain text format. Whether your use-case demands IPv4, IPv6, or even both, the IP Address API can accommodate any and all requests. For detailed documentation, please visit the official documentation page .
This API is crafted to be incredibly straightforward, yet highly flexible in its application, making it an excellent fitting piece for a wide range of solutions from security to customization based on locations. Some factors that set the IP Address API apart include:
- It's completely free to use.
- Quick and easy setup.
- Returns IP in text format, simplifying parsing process.
- Supports both IPv4 and IPv6.
- Automatically detects the type of IP.
Here is an example of how to call this API using JavaScript:
var request = new XMLHttpRequest();
request.open('GET', 'https://icanhazip.com', true);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
// Success! IP address is in this.response
console.log(this.response);
} else {
// We reached the server, but it returned an error
}
};
request.onerror = function() {
// Connection error of some sort
};
request.send();
In this example, the output will be the IP address of the calling machine in plain text. This API is a surefire way to get IP related information quickly and efficiently.