PHPackages                             black-sheep-tech/laravel-ip-api - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. black-sheep-tech/laravel-ip-api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

black-sheep-tech/laravel-ip-api
===============================

A simple service provider/wrapper for the IP API Service (https://ip-api.com).

v1.0.0(1y ago)111MITPHPPHP ^8.1

Since Sep 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/BlackSheepTech/laravel-ip-api)[ Packagist](https://packagist.org/packages/black-sheep-tech/laravel-ip-api)[ Docs](https://github.com/BlackSheepTech/ip-api)[ RSS](/packages/black-sheep-tech-laravel-ip-api/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (1)Dependencies (14)Versions (3)Used By (0)

 [ ![BlackSheepTech UiAvatars](https://avatars.githubusercontent.com/u/85756821?s=400&u=14843f72938dc40cbd14400f5b3daad45f054f43&v=4) ](https://github.com/BlackSheepTech/laravel-ip-api)

 [![Current Version](https://camo.githubusercontent.com/e86f6d308088930c0904ce000cad8e40063c1755b246091d5e3e87b0628eef10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c61636b2d73686565702d746563682f6c61726176656c2d69702d617069)](https://packagist.org/packages/black-sheep-tech/laravel-ip-api) [![Total Downloads](https://camo.githubusercontent.com/937d8de34d1e60165ea8166e0ca1a135d9bc108bca3642757ddf8b11273e6964/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c61636b2d73686565702d746563682f6c61726176656c2d69702d617069)](https://packagist.org/packages/black-sheep-tech/laravel-ip-api) [![License](https://camo.githubusercontent.com/8e42aa11a84834475083bacdef370373b38b7e20dead5946fdbbbbddc9a9a78e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f426c61636b5368656570546563682f6c61726176656c2d69702d617069)](https://packagist.org/packages/black-sheep-tech/laravel-ip-api) [![Stars](https://camo.githubusercontent.com/4b9bfbd9f782fd8a35a17ffab85cb0367ac1fd65827e5cada0cfcf577b68ae4e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f426c61636b5368656570546563682f6c61726176656c2d69702d617069)](https://packagist.org/packages/black-sheep-tech/laravel-ip-api)

Laravel IpApi is a Laravel focused package that provides an easy way to get information about an IP address using the [IpApi](https://ip-api.com/) API.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require black-sheep-tech/laravel-ip-api
```

General Config
--------------

[](#general-config)

The package just works out of the box, but you can customize it to your liking.

### On the fly

[](#on-the-fly)

```
// Set API Key fluently
$info = IpApi::geolocation()->apiKey('yourapikeyhere')->query('google.com')->get();
// Set Base URL fluently
$info = IpApi::geolocation()->baseUrl('http://ip-api.com/')->query('google.com')->get();
```

### Using environment variables

[](#using-environment-variables)

You can set the following environment variables in your `.env` file:

```
IP_API_BASE_URL=http://ip-api.com/
IP_API_API_KEY=your_api_key
IP_API_DEFAULT_QUERY=google.com
IP_API_DEFAULT_LANG=en
IP_API_DEFAULT_FORMAT=json
IP_API_DEFAULT_FIELDS=country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,query
```

### Config File

[](#config-file)

For a more tailored configuration, you can publish the config file to your project by running the following command:

```
php artisan vendor:publish --provider="BlackSheepTech\IpApi\IpApiServiceProvider"
```

This will create a `ip-api.php` file in your `config` directory, where you can customize the package config to your liking.

#### Overusage Protection

[](#overusage-protection)

The package comes with a built-in overusage protection feature that will prevent you from making excessive requests to the API getting you temporarily banned. But, of course, you can disable this feature by setting the "IP\_API\_OVERUSAGE\_PROTECTION" environment variable to false.

```
IP_API_OVERUSAGE_PROTECTION=false
```

It can also be disabled on the fly:

```
$info = IpApi::geolocation()->disableOverusageProtection()->query('google.com')->get();
```

Usage
-----

[](#usage)

The package offers acess to both the geolocation and Batch APIs.

### Geolocation API

[](#geolocation-api)

- Basic Usage

```
use BlackSheepTech\IpApi\IpApi;

$info = IpApi::geolocation()->query('google.com')->get();
```

- Advanced Usage

```
//Return Format - can be json, xml, csv, line or php
$info = IpApi::geolocation()->query('google.com')->format('json')->get();

//Return Fields - Supported fields can be found at https://ip-api.com/docs/api:json
$info = IpApi::geolocation()->query('google.com')->fields('countryCode,lat,lon,timezone,query')->get();
// or
$info = IpApi::geolocation()->query('google.com')->fields(['countryCode', 'lat', 'lon', 'timezone', 'query'])->get();

//Return Language - Supported languages can be found at https://ip-api.com/docs/api:json
$info = IpApi::geolocation()->query('google.com')->language('es')->get();
```

- Return as Object

You can get the response as an object by doing the following:

```
$info = IpApi::geolocation()->query('google.com')->get(true);
//Or
$info = IpApi::geolocation()->query('google.com')->getAsObject();
//When using object return, the format provided is disregarded.
$info = IpApi::geolocation()->query('google.com')->format('php')->getAsObject(); //->format('php') will be ignored and have no impact on the response.
```

### Batch API

[](#batch-api)

- Basic Usage

```
use BlackSheepTech\IpApi\IpApi;

$entities = [
    {
        "query": "google.com"
    },{
        "query": "facebook.com"
    }
];

$info = IpApi::batch()->entities($entities)->get();
```

- Customized Return

```
use BlackSheepTech\IpApi\IpApi;

$entities = [
    {
        "query": "google.com",
        "fields": "country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,query",
        "lang": "en",
    },{
        "query": "facebook.com",
        "fields": "country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,query",
        "lang": "en",
    }
];

$info = IpApi::batch()->entities($entities)->get();
```

- Return as Object

You can get the response as an object by doing the following:

```
$entities = [
    {
        "query": "google.com"
    },{
        "query": "facebook.com"
    }
];

$info = IpApi::batch()->entities($entities)->get(true);
//Or
$info = IpApi::batch()->entities($entities)->getAsObject();
```

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel framework version 9.0 or higher

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request on GitHub.

Credits
-------

[](#credits)

- [Israel Pinheiro](https://github.com/IsraelPinheiro)
- [All Contributors](https://github.com/BlackSheepTech/laravel-ip-api/graphs/contributors)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

615d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f1bff44e900ea9254da31678986ec28a5894f29712b9af699cc52a4ddb77d32?d=identicon)[IsraelPinheiro](/maintainers/IsraelPinheiro)

---

Top Contributors

[![IsraelPinheiro](https://avatars.githubusercontent.com/u/2693283?v=4)](https://github.com/IsraelPinheiro "IsraelPinheiro (18 commits)")

---

Tags

laravelIP API

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/black-sheep-tech-laravel-ip-api/health.svg)

```
[![Health](https://phpackages.com/badges/black-sheep-tech-laravel-ip-api/health.svg)](https://phpackages.com/packages/black-sheep-tech-laravel-ip-api)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.5k9.4M48](/packages/laravel-reverb)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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