IP Lookup is a simple tool for looking up the location of an IP address. It returns the country, city, and more.
npm install @apiverve/iplookupshell
npm install @apiverve/iplookup
`
Using yarn:
`shell
yarn add @apiverve/iplookup
`
---
Configuration
Before using the IP Lookup API client, you have to setup your account and obtain your API Key.
You can get it by signing up at https://apiverve.com
---
Quick Start
Get started with the Quick Start Guide
The IP Lookup API documentation is found here: https://docs.apiverve.com/ref/iplookup.
You can find parameters, example responses, and status codes documented here.
$3
`javascript
const iplookupAPI = require('@apiverve/iplookup');
const api = new iplookupAPI({
api_key: '[YOUR_API_KEY]'
});
`
---
Usage
---
$3
Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
`javascript
var query = {
ip: "173.172.81.20"
};
api.execute(query, function (error, data) {
if (error) {
return console.error(error);
} else {
console.log(data);
}
});
`
---
$3
You can also use promises to make requests. The API returns a promise that you can use to handle the response.
`javascript
var query = {
ip: "173.172.81.20"
};
api.execute(query)
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
`
---
$3
You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
`javascript
async function makeRequest() {
var query = {
ip: "173.172.81.20"
};
try {
const data = await api.execute(query);
console.log(data);
} catch (error) {
console.error(error);
}
}
`
---
Example Response
`json
{
"status": "ok",
"error": null,
"data": {
"range": [
2913751040,
2913755135
],
"country": "US",
"region": "MO",
"timezone": "America/Chicago",
"city": "Kansas City",
"coordinates": [
39.0831,
-94.5853
],
"ip": "173.172.81.20"
}
}
``