Retrieve address and geolocation coordinates from IP address
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('address/ip-geolocation@1.0.1');
// Use the profile
const result = await profile
.getUseCase('IpGeolocation')
.perform({
ipAddress: '8.8.8.8'
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"ipAddress": "8.8.8.8"
}
{
"ipAddress": "8.8.8.8",
"addressCountryCode": "US",
"addressCountry": "United States",
"timeZone": "America/Chicago",
"latitude": 37.751,
"longitude": -97.822
}