Superface

IP geolocation lookup

address/ip-geolocation@1.0.1
6 providers

IP Geolocation

Retrieve address and geolocation coordinates from IP address

Input
IP address
Result
IP address
Country code
Country
Region
Locality
Postal code
Time zone
Latitude
Longitude

1.Choose a provider

2.Use IpGeolocation with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
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();

Structure details

Input (object)

ipAddress
If left empty, most providers will attempt to retrieve data for client IP address.

Example

{
  "ipAddress": "8.8.8.8"
}

Result (object)

ipAddress
IP address from the input or client IP address.
addressCountryCode
ISO 3166-1 alpha-2 country code.
addressCountry
The country. For example, USA.
addressRegion
The region in which the locality is, and which is in the country. For example, California or another appropriate first-level Administrative division.
addressLocality
The locality in which the street address is, and which is in the region. For example, Mountain View.
postalCode
The postal code. For example, 94043.
timeZone
The IANA time zone of the location. For example, America/Los_Angeles.
latitude
The latitude of a location. For example 37.42242 (WGS 84).
longitude
The longitude of a location. For example -122.08585 (WGS 84).

Example

{
  "ipAddress": "8.8.8.8",
  "addressCountryCode": "US",
  "addressCountry": "United States",
  "timeZone": "America/Chicago",
  "latitude": 37.751,
  "longitude": -97.822
}

Implementation details

Provider
mock
Use case
IpGeolocation
Author
@superface
Source
Verified