Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

IP Address Lookup

No security coverage Under active development

Part of the IP ecosystem · 13 projects

This module integrates with an IP address lookup API to retrieve detailed geolocation information for IP addresses. It allows you to fetch data such as city, country, region, and coordinates, and provides services for easy integration into your Drupal site.

This module helps in integration of IP Address Lookup (https://ipapi.co/#api).

ipapi.co provides a REST API to find the location of an IP address.

Specifically, you can get the following information for any IP address:
city, region (name & code), country (name & code), continent, postal code / zip code, latitude, longitude, timezone, utc offset, european union (EU) membership, country calling code, country capital, country tld (top-level domain), currency (name & code), area & population of the country, languages spoken, asn, organization and hostname*.

When you are using this api on client side, it work perfectly using the public IP.

GET https://ipapi.co/{format}/
Like GET https://ipapi.co/json/

When it comes to use at server side, it start giving response as per server IP

This module helps you in working with client side with some back-end configuration. It provide services which you can easily use in getting IP address details.


Step Involve

  1. Install module as you do.
  2. If you have API you can add in the configuration /admin/config/services/ip_address_lookup
  3. There is also a debug option which you can used to check the response for specifit IP address.


Function to Use

  1. getCountry() : This will return the Country Name
  2. getCity() : This will return the City Name
  3. getCountryCode() : This will return the Country Code
  4. getRegion() : Get region/state short code (FIPS or ISO)
  5. getLatitude() : Get latitude
  6. getLongitude() : Get longitude.
  7. getPostal() : Get zip/Postal code.
  8. getTimezone() : Get timezone


How to use service in code

  1. getCountry()
    $country = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getCountry();
  2. getCity()
    $city = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getCity();
  3. getCountryCode()
    $country_code = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getCountryCode();
  4. getRegion()
    $region = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getRegion();
  5. getLatitude()
    $lat = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getLatitude();
  6. getLongitude()
    $long = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getLongitude();
  7. getPostal()
    $postal = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getPostal();
  8. getTimezone()
    $timezone = \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail()->getTimezone();

If you want to get all data together then just call

 \Drupal::service('ip_address_lookup.getIpAddressGeolocation')->getIpLocationApiDetail();

Ask your assistant about IP Address Lookup

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Apr 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.x-dev Dev 8–10 Apr 24, 2023