PHPackages                             nafisc/ipstackgeo-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. nafisc/ipstackgeo-php

ActiveLibrary[API Development](/categories/api)

nafisc/ipstackgeo-php
=====================

A PHP library for interfacing with IPStack Geo API

v1.7.0(4y ago)109734[1 issues](https://github.com/nathan-fiscaletti/ipstackgeo-php/issues)MITPHPPHP &gt;=7.0CI failing

Since Dec 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/nathan-fiscaletti/ipstackgeo-php)[ Packagist](https://packagist.org/packages/nafisc/ipstackgeo-php)[ RSS](/packages/nafisc-ipstackgeo-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

IPStack for PHP (Geo Location Library)
======================================

[](#ipstack-for-php-geo-location-library)

> **IPStack for PHP** is a simple library used to interface with an IPStack Geo API.

```
$ composer require nafisc/ipstackgeo-php

```

[![Sponsor Me!](https://camo.githubusercontent.com/c333a55be0058d206e8aebe9bedfa79004c7f85c2102970349acb40a81323a9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462539322542382d53706f6e736f722532304d65212d626c7565)](https://github.com/sponsors/nathan-fiscaletti)[![Maintainability](https://camo.githubusercontent.com/26b0ebb9582f93b35d24d4702f21e6321c03ab83af7b3047d976dd44bb919736/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32636262353633633165663034303539646632642f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/nathan-fiscaletti/ipstackgeo-php/maintainability)[![StyleCI](https://camo.githubusercontent.com/effa45d9323cf9da1e5037516c18285512e6e7c5695c62b759c1ea74ea69ad24/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131353536303333342f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/115560334)[![CircleCI](https://camo.githubusercontent.com/b4056db06047d6e4b53071b036e733d51e3aea2e383df9f3faa2a47731950b2b/68747470733a2f2f636972636c6563692e636f6d2f67682f6e617468616e2d66697363616c657474692f6970737461636b67656f2d7068702e7376673f7374796c653d737667)](https://circleci.com/gh/nathan-fiscaletti/ipstackgeo-php)[![Coverage Status](https://camo.githubusercontent.com/01ebda1612db1f270c66830ece399b78e296680c317e22a7c0dc16c95637260e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e617468616e2d66697363616c657474692f6970737461636b67656f2d7068702f62616467652e737667)](https://coveralls.io/github/nathan-fiscaletti/ipstackgeo-php)[![Latest Stable Version](https://camo.githubusercontent.com/a23b2c24ba0dd970b728ecd9c12b38b2c8a263c280c92e5e318b2dddb86e0cf0/68747470733a2f2f706f7365722e707567782e6f72672f6e61666973632f6970737461636b67656f2d7068702f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/nafisc/ipstackgeo-php)[![License](https://camo.githubusercontent.com/6c520422c02d1760deeef68871c6de7cac56486995d97ae7f639f4ac827af645/68747470733a2f2f706f7365722e707567782e6f72672f6e61666973632f6970737461636b67656f2d7068702f6c6963656e73653f666f726d61743d666c6174)](https://packagist.org/packages/nafisc/ipstackgeo-php)

Learn more about IPStack here: [ipstack.net](https://ipstack.com/product)

[Looking for the Python version?](https://github.com/nathan-fiscaletti/ipstackgeo-py)

[Looking for the Node.JS version?](https://github.com/nathan-fiscaletti/ipstackgeo-js)

### Features

[](#features)

- Retrieve the Geo Location data for any IP address.
- Retrieve the Geo Location data for the system executing this code.
- Retrieve the Geo Location data for a client.
- Retrieve the Geo Location data for a batch of IP addresses.
- Assess the security of an IP address.

### Legacy Features

[](#legacy-features)

- Link to a custom FreeGeoIP server

---

### Basic Usage

[](#basic-usage)

```
$geo = new GeoLookup('.....');
$location = $geo->getLocation('github.com');
print_r($location);
```

### Example Usage

[](#example-usage)

> Note: See [IPStack: Response Objects](https://ipstack.com/documentation#objects) for a list of available properties in a response object.

#### Create the GeoLookup object

[](#create-the-geolookup-object)

```
use IPStack\PHP\GeoLookup;

// Create the GeoLookup object using your API key.
$geoLookup = new GeoLookup('acecac3893c90871c3');
```

#### Lookup a location for an IP Address

[](#lookup-a-location-for-an-ip-address)

```
// Lookup a location for an IP Address
// and catch any exceptions that might
// be thrown by Guzzle or IPStack.
try {
    // Retrieve the location information for
    // github.com by using it's hostname.
    //
    // This function will work with hostnames
    // or IP addresses.
    $location = $geoLookup->getLocation('github.com');

    // If we are unable to retrieve the location information
    // for an IP address, null will be returned.
    if (\is_null($location)) {
        echo 'Failed to find location.'.PHP_EOL;
    } else {
        // Print the Location Object.
        print_r($location);
    }
} catch (\Exception $e) {
    echo $e->getMessage();
}
```

#### Look up a Clients location

[](#look-up-a-clients-location)

```
$location = $geoLookup->getClientLocation();
print_r($location);
```

#### Look up own location

[](#look-up-own-location)

```
$location = $geoLookup->getOwnLocation();
print_r($location);
```

#### Other Features

[](#other-features)

There are also a few other useful features built into this library and the IPStack API.

1. Bulk Location Lookup

    The ipstack API also offers the ability to request data for multiple IPv4 or IPv6 addresses at the same time. This requires the PROFESSIONAL teir API key or higher and is limitted to 50 IPs at a time.

    > See:

    ```
    $lookup = ['google.com', 'github.com', '1.1.1.1'];
    $locations = $geoLookup->getLocations(...$lookup);
    print_r($locations);
    ```
2. Requesting the hostname for an IP address.

    By default, the ipstack API does not return information about the hostname the given IP address resolves to. In order to include the hostname use the following.

    > See:

    ```
    $location = $geoLookup->setFindHostname(true)->getLocation('1.1.1.1');
    echo $location['hostname'];
    ```

    ```
    one.one.one.one

    ```
3. Assessing Security

    Customers subscribed to the Professional Plus Plan may access the ipstack API's Security Module, which can be used to assess risks and threats originating from certain IP addresses before any harm can be done to a website or web application.

    > See:

    ```
    $location = $geoLookup->assessSecurity(true)->getLocation('github.com');
    ```
4. Set the language for a response

    The ipstack API is capable of delivering its result set in different languages. To request data in a language other than English (default) use following with one of the supported language codes.

    > See:

    [Supported Langauges](https://ipstack.com/documentation#language)

    ```
    $location = $geoLookup->setLanguage('en')->getLocation('github.com');
    ```
5. Configuring your request

    ```
    /// Use HTTPS
    /// This requires IPStack Basic plan or higher.
    $location = $geoLookup->useHttps(true)->getLocation('github.com');

    /// Configure the timeout for requests
    $location = $geoLookup->setTimeout(15)->getLocation('github.com');
    ```

#### Using the the Legacy [FreeGeoIP Binary](https://github.com/fiorix/freegeoip/releases/)

[](#using-the-the-legacy-freegeoip-binary)

You can still use the legacy FreeGeoIP Binary hosted on a server

> Note: [FreeGeoIP has been deprecated](https://github.com/apilayer/freegeoip/#freegeoip---important-announcement).

```
use IPStack\PHP\Legacy\FreeGeoIp as GeoLookup;

// Address, Port, Protocol, Timeout
$geoLookup = new GeoLookup(
    'localhost', // Address hosting the legacy FreeGeoIP Binary
    8080,        // Port that the binary is running on (defaults to 8080)
    'http',      // Protocol to use (defaults to http)
    10           // Timeout (defaults to 10 seconds)
);
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 89.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~133 days

Recently: every ~229 days

Total

12

Last Release

1636d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1699763?v=4)[Nathan Fiscaletti](/maintainers/nathan-fiscaletti)[@nathan-fiscaletti](https://github.com/nathan-fiscaletti)

---

Top Contributors

[![nathan-fiscaletti](https://avatars.githubusercontent.com/u/1699763?v=4)](https://github.com/nathan-fiscaletti "nathan-fiscaletti (88 commits)")[![mihaikelemen](https://avatars.githubusercontent.com/u/17508016?v=4)](https://github.com/mihaikelemen "mihaikelemen (9 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

composerfreegeoipfreegeoip-apisipstackipstack-apiphpphp-7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nafisc-ipstackgeo-php/health.svg)

```
[![Health](https://phpackages.com/badges/nafisc-ipstackgeo-php/health.svg)](https://phpackages.com/packages/nafisc-ipstackgeo-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

232.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1772.4k4](/packages/aimeos-prisma)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
