barstec/ip-api

Package for handling the ipapi.is API in Laravel

v1.1.1 2024-09-30 15:33 UTC

This package is auto-updated.

Last update: 2025-05-29 01:49:16 UTC


README

A package for handling the ipapi.is API in Laravel. You will need an API key from ipapi.is.

Support

If this package is helpful to you, you can support my work on Ko-fi.

ko-fi

Installation

  1. Install composer package using command:
  composer require barstec/ip-api
  1. Publish configuration files to your project
  php artisan vendor:publish --provider="Barstec\IpApi\IpApiServiceProvider"

Setup

First, add an environment variable with your API key to the .env file:

IP_API_KEY=your_api_key

Usage

Create an IpApi object and call the get method. You can pass an IP address as a parameter. If left empty, the IP from the current request will be used. The result will be an stdClass.

Example of geting city location:

$ipApi = new IpApi;
$result = $ipApi->get("8.8.8.8");
$result->location->city;

Author

Bartłomiej Stec

License

This package is distributed under the MIT license