PHPackages                             harrisonratcliffe/ip-api-laravel - 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. harrisonratcliffe/ip-api-laravel

ActiveLibrary[API Development](/categories/api)

harrisonratcliffe/ip-api-laravel
================================

A simple Laravel package to get IP address information from ip-api.com

v1.0.1(1y ago)17[2 PRs](https://github.com/harrisonratcliffe/ip-api-laravel/pulls)MITPHPPHP &gt;=7.2CI passing

Since Mar 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/harrisonratcliffe/ip-api-laravel)[ Packagist](https://packagist.org/packages/harrisonratcliffe/ip-api-laravel)[ RSS](/packages/harrisonratcliffe-ip-api-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

IP-Api Laravel - IP Address Information Lookup
==============================================

[](#ip-api-laravel---ip-address-information-lookup)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fcb6f1df47ac0db568b4ebe798e718d4220a4f809bc2068a7f11a938b1988290/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861727269736f6e726174636c696666652f69702d6170692d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harrisonratcliffe/ip-api-laravel)[![Total Downloads](https://camo.githubusercontent.com/cccac7d5e5c084c0f10088e57ff80c74d34f69a355e80394edc09dd57f523e7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861727269736f6e726174636c696666652f69702d6170692d6c61726176656c3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harrisonratcliffe/ip-api-laravel)[![Repo Size](https://camo.githubusercontent.com/9b1fb22ac23e5ede9d8adba8efaa7e97828629eb1c34f5d9b5e803fe608a93a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6861727269736f6e726174636c696666652f69702d6170692d6c61726176656c3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harrisonratcliffe/ip-api-laravel)[![Repo Size](https://camo.githubusercontent.com/6b357f4365a5b656a74ee778423cb28081b7d3ad299bb15266c1e92b3c79e78c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6861727269736f6e726174636c696666652f69702d6170692d6c61726176656c3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harrisonratcliffe/ip-api-laravel)

The `IpApiLaravel` package provides an easy-to-use interface for looking up information about IP addresses using the ip-api-laravel.com API. It allows you to fetch various details about an IP address, such as geographical location, time zone, currency, and more.

This package is a fork of [el-factory/ip-api](https://github.com/el-factory/ip-api) with additional features.

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

[](#requirements)

- PHP 7.2 or higher
- Laravel 7 or higher

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

[](#installation)

The `IpApiLaravel` package requires Laravel version 7 or higher.

To install the package, you can use Composer:

```
composer require harrisonratcliffe/ip-api-laravel
```

Configuration
-------------

[](#configuration)

After installing the package, you can optionally publish the configuration file to customize the default settings:

```
php artisan vendor:publish --tag=ip-api-laravel-config
```

This will create a `ip-api-laravel.php` file in the `config` directory of your Laravel application. You can modify the default configuration values in this file according to your specific requirements.

Usage
-----

[](#usage)

### IP Address Lookup

[](#ip-address-lookup)

To perform an IP address lookup, you can use the `lookup` method on the `IpApiLaravel` class:

```
use Harrisonratcliffe\IpApiLaravel\IpApiLaravel;

$ipDetails = IpApiLaravel::default('188.216.103.93')->lookup();
```

This will return an array with the details of the provided IP address.

### Additional Configuration

[](#additional-configuration)

You can also customize the IP address lookup by using the following methods:

#### `fields(array $fields): IpApiLaravel`

[](#fieldsarray-fields-ipapilaravel)

Set the fields to be included in the API response. The `$fields` parameter should be an array of fields you want to retrieve.

```
$ipDetails = IpApiLaravel::default('188.216.103.93')->fields(['city', 'country', 'timezone'])->lookup();
```

#### `usingKey(string $apiKey): IpApiLaravel`

[](#usingkeystring-apikey-ipapilaravel)

By default, the package uses the API key provided in the config file. If you wish to send a different API key for a specific request, you can use the `usingKey` method to set the API key for that request.

```
$ipDetails = IpApiLaravel::default('188.216.103.93')->usingKey('YOUR_API_KEY')->lookup();
```

#### `retry(int $times, int $sleep): IpApiLaravel`

[](#retryint-times-int-sleep-ipapilaravel)

Set the retry configuration for failed API requests. The `$times` parameter represents the number of retry attempts, and the `$sleep` parameter specifies the number of seconds to sleep between retries.

```
$ipDetails = IpApiLaravel::default('188.216.103.93')->retry(3, 2)->lookup();
```

#### `lang(string $language): IpApiLaravel`

[](#langstring-language-ipapilaravel)

Set the language for the API response. The `$language` parameter should be a two-letter language code.

```
$ipDetails = IpApiLaravel::default('188.216.103.93')->lang('en')->lookup();
```

#### `withHeaders(): IpApiLaravel`

[](#withheaders-ipapilaravel)

Include request limit and remaining requests headers in the API response.

```
$ipDetails = IpApiLaravel::default('188.216.103.93')->withHeaders()->lookup();
```

#### `timeout(int $seconds): IpApiLaravel`

[](#timeoutint-seconds-ipapilaravel)

Set a timeout for the API request. The `$seconds` parameter specifies the maximum number of seconds to wait for a response. If the request times out, an exception will be thrown.

```
$ipDetails = IpApiLaravel::default('188.216.103.93')->timeout(10)->lookup(); // Set timeout to 10 seconds
```

### Console Command - `ip-api-laravel:connection`

[](#console-command---ip-api-laravelconnection)

The `IpApiLaravel` package also includes a console command named `ip-api-laravel:connection` that allows you to test the connection to the ip-api-laravel.com API with a specific IP address or your public IP address (if not provided).

To use the command, run the following Artisan command:

```
php artisan ip-api-laravel:connection {ip?}
```

- `{ip}` (optional): The IP address to test with. If not provided, the command will use your public IP address.

The command will display the details retrieved from the ip-api-laravel.com API for the provided IP address.

### Example

[](#example)

Here's an example of using the `ip-api-laravel:connection` command:

```
php artisan ip-api-laravel:connection 188.216.103.93
```

This will test the connection to ip-api-laravel.com API with the specified IP address and display the details retrieved.

If no IP address is provided, the command will automatically use your public IP address:

```
php artisan ip-api-laravel:connection
```

Exceptions
----------

[](#exceptions)

The `IpApiLaravel` class may throw the following exceptions:

- `Exception`: If the provided IP address is invalid or reserved.
- `RequestException`: If an error occurs while making the API request.

License
-------

[](#license)

The `IpApiLaravel` package is open-source software licensed under the [MIT License](https://opensource.org/licenses/MIT). Feel free to use and modify it according to your needs.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance71

Regular maintenance activity

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.9% 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 ~0 days

Total

2

Last Release

423d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4b0218f62234c66a7c65601d79a21643bfe0d61529dc3d867a55441b9da2681?d=identicon)[harrisonratcliffe](/maintainers/harrisonratcliffe)

---

Top Contributors

[![harrisonratcliffe](https://avatars.githubusercontent.com/u/53269265?v=4)](https://github.com/harrisonratcliffe "harrisonratcliffe (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

IP APIip-api.comip api laravelip api php

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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