Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

IP 2 Location API

No security coverage Under active development 3 sites

This module provides a Drupal service to interact with the IP2Location API, allowing you to geolocate IP addresses to retrieve country codes and names. It wraps the official IP2Location PHP library and requires an API key to function.

A light weight wrapper that provides a Drupal Service interface to the IP2Location API

Features

This module provides a service that wraps the IP2Location api via the PHP library ip2location/ip2location-io-php - currently only Geolocation is implemented. There are two helper functions to return the country code and country name.

Post-Installation

  1. Set up an API key at https://www.ip2location.com
  2. Save the key at admin/config/system/keys/add as Key Type "IP2 Location API Key"
  3. Select the key at admin/config/system/ip2location-settings

After these steps you have access to a Drupal Service in code. The service provides the ability to Geolocate the current request, or specify an IP address to Geolocate.

Additional Requirements

You will need to sign up to IP2Location and get an api key.
Keys are managed using Drupal module Key.

You will need to write custom code to take advantage of this module.

Similar projects

There is an existing project ip2location however this doesn't currently use the API instead it requires on the user downloading the required databases and keeping these up to date.

Community Documentation

Example code:
Assuming you inject this service and saved it as $ip2LocationAPI then
$countryName = $this->ip2LocationAPI->getCountryName();
would get you the country name of the user making the request as processed by the ip2LocationAPI.

Note there is currently no caching of responses beyond a very simple storage on the service itself. Ideally we'd cache response data so we wouldn't make repeated attempts to look up the same IP address.

Ask your assistant about IP 2 Location API

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
2
Tracked since
Jul 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.0-alpha1 Pre-release 10–11 Jul 10, 2025
1.0.x-dev Dev 10–11 Jul 10, 2025