Geolocate an IP Address to a Street Address in Node.JS

Cloudmersive
Level Up Coding
Published in
Oct 6, 2020

--

We previously posted an article on performing basic geolocation of an IP address using one of our APIs. Now, we have and API that will go even further. Ideal for UX and security applications, this new function will allow you to geolocate an IP Address down to its actual street address. By inputting an IP Address string (i.e. 55.55.55.55), you can return the country and country code, street address, city name, region name, and Zip code. This will allow you to better understand your client base and track any incoming threats to your sites.

We will start by installing our SDK:

npm install cloudmersive-validate-api-client --save

You may also add this snippet to your package.json:

"dependencies": {
"cloudmersive-validate-api-client": "^1.2.4"
}

Then, we can call our function:

var CloudmersiveValidateApiClient = require('cloudmersive-validate-api-client');
var defaultClient = CloudmersiveValidateApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveValidateApiClient.IPAddressApi();var value = "value_example"; // String | IP address to geolocate, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.iPAddressGeolocateStreetAddress(value, callback);

Now, you can both improve user experience and help mitigate any possible cyber threats to your organization. You can get your free API Key from Cloudmersive. This give you access to 800 monthly calls across our entire API Library.

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.