Lookup Method

Overview

This method is used to retrieve the information of a specific IP Address.

Options

Option
Type
Description
ip *
String
The IP Address you want to lookup.
params
Array
Specifies the modules you want to retrieve as visitor information. It's an Array of consist some Strings as it's items. Accepts: location, security, timezone, currency and/or device. Default: []
format
String
You can use this option to specify the API output format. Accepts: JSON, XML, CSV or Newline. Default: JSON
lang
String
Specifies the API output language. Accepts: EN, AR, DE, FR, ES, JA, JA, ZH or RU. Default: EN
mode
String
You can use this option for using the Development Environment of the API, read more. Accepts: live or test. Default: live
Parameters with the (*) are required.

Usage:

Basic example of using this method:
GeoIP.lookup({
'ip': '1.1.1.1'
})
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error);
});
Description:
This method accepts one parameter of type Object. The object contains the options you want to specify for this method. Let's dive into this:
Let's say that we want to retrieve the visitor information and also the timezone and device information. So the code will be like this:
GeoIP.lookup({
'ip': '1.1.1.1',
'params': ['timezone', 'device'] // <--- This key/value added to the options
})
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error);
});
Beside this, we can inform the module to return the response as XML:
GeoIP.lookup({
'ip': '1.1.1.1',
'params': ['timezone', 'device'],
'format': 'XML' // <--- This key/value added to the options
})
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error);
});
And so on...
The .then() will return the response if it's successfully fetched and the .catch() will return the error if something goes wrong.
If the request completed successfully, so the res variable of .then() returns the data in the format you specified. And we can read the data like this:
GeoIP.lookup({
'ip': '1.1.1.1',
'params': ['timezone', 'device']
})
.then(res => {
console.log(res?.data?.countryName); // <--- This will `log` the Country Name
})
.catch(error => {
console.log(error);
});
Copy link
On this page
Overview
Options
Usage: