Find your public (external) IP address in your favorite language with a secure API
Shell
curl 'https://ipapi.co/ip/'
Ruby
require 'net/http'
puts Net::HTTP.get(URI('https://ipapi.co/ip/'))
Python
from requests import get
print get('https://ipapi.co/ip/').text
PHP
echo file_get_contents('https://ipapi.co/ip/')
Node.js
var https = require('https');
https.get('https://ipapi.co/ip/', function(resp){
var body = ''
resp.on('data', function(data){
body += data;
});
resp.on('end', function(){
console.log(body);
});
});
jQuery
$.get('https://ipapi.co/ip/', function(data){
console.log(data)
})