geolax/freeipapi

FreeIPAPI driver addon for geolax/geolocate

Maintainers

Package info

github.com/geolax/freeipapi

pkg:composer/geolax/freeipapi

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v1.1.0 2026-04-02 19:48 UTC

README

Latest Version on Packagist Total Downloads

FreeIPAPI driver addon for geolax/geolocate.

Installation

composer require geolax/freeipapi

That's it. The package is auto-discovered by Laravel and registers itself as the freeipapi driver.

Configuration

Add or update the driver config in config/geolocate.php:

'drivers' => [
    'freeipapi' => [
        'driver'   => 'freeipapi',
        'base_url' => env('GEOLOCATE_FREEIPAPI_URL', 'https://freeipapi.com'),
        'api_key'  => env('GEOLOCATE_FREEIPAPI_KEY'),
        'server'   => env('GEOLOCATE_FREEIPAPI_SERVER', 'free'),
        'timeout'  => 5,
    ],
],

Environment Variables

Variable Default Description
GEOLOCATE_DRIVER freeipapi Set this in the base package to use FreeIPAPI as default
GEOLOCATE_FREEIPAPI_URL https://freeipapi.com Base URL override
GEOLOCATE_FREEIPAPI_KEY null API key for paid plans (Bearer token)
GEOLOCATE_FREEIPAPI_SERVER free Server region: free, us, de, sgp, au

Servers

Key Host Plan
free freeipapi.com Free (rate limited)
us us.freeipapi.com Paid
de de.freeipapi.com Paid
sgp sgp.freeipapi.com Paid
au au.freeipapi.com Paid

Usage

use Geolax\Geolocate\Facades\Geolocate;

$result = Geolocate::lookup('1.1.1.1');

$result->ipAddress;    // "1.1.1.1"
$result->countryName;  // "Australia"
$result->countryCode;  // "AU"
$result->cityName;     // "Sydney"
$result->latitude;     // -33.8688
$result->longitude;    // 151.209
$result->timezone;     // "Australia/Sydney"
$result->currency;     // "AUD"

FreeIPAPI-Specific Data

FreeIPAPI returns additional fields beyond the standard DTO. Access them via raw:

$result = Geolocate::lookup('1.1.1.1');

$result->raw['capital'];         // "Canberra"
$result->raw['phoneCodes'];      // [61]
$result->raw['timeZones'];       // ["Australia/Sydney", "Australia/Melbourne", ...]
$result->raw['currencies'];      // ["AUD"]
$result->raw['languages'];       // ["en"]
$result->raw['asn'];             // "13335"
$result->raw['asnOrganization']; // "Cloudflare, Inc."
$result->raw['isProxy'];         // false

Authentication (Paid Plans)

For paid/unlimited plans, set your API key:

GEOLOCATE_FREEIPAPI_KEY=your-api-key-here
GEOLOCATE_FREEIPAPI_SERVER=us

The driver automatically sends the API key as a Bearer token in the Authorization header.

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.