Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

IP 2 Location API

2 sites No security coverage
View on drupal.org

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.

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 Release date
1.0.0-alpha1 Pre-release 10–11 Jul 10, 2025
1.0.x-dev Dev 10–11 Jul 10, 2025