IPGeolocation API Javascript SDK
Installation
npm i ip-geolocation-api-javascript-sdk
Usage
var IPGeolocationAPI = require('ip-geolocation-api-javascript-sdk');
var GeolocationParams = require('ip-geolocation-api-javascript-sdk/GeolocationParams.js');
var TimezoneParams = require('ip-geolocation-api-javascript-sdk/TimezoneParams.js');
Setup API
var api = new IPGeolocationAPI("YOUR_API_KEY");
Geolocation Lookup
var geolocationParams = new GeolocationParams();
geolocationParams.setIp("1.1.1.1");
geolocationParams.setFields("geo,time_zone,currency");
console.log(api.getGeolocation(geolocationParams));
GeolocationParams geoParams = new GeolocationParams();
geoParams.SetIp("1.1.1.1");
console.log(api.getGeolocation(geolocationParams));
console.log(api.getGeolocation());
Bulk Geolocations Lookup
var geolocationParams = new GeolocationParams();
geolocationParams.setIps(['1.1.1.1','2.2.22.2','34.1.1.3']);
console.log(api.getGeolocation(geolocationParams));
Time Zone API
var tzParams = new TimezoneParams();
tzParams.setIp("1.1.1.1");
console.log(obj.getTimezone());