Skip to content

naylonkessler/ipapi-sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip-api.com PHP SDK

A simple API for ip-api.com using PHP

Installation

Just require the package using composer.

composer require naylonkessler/ipapi-sdk-php

Using the package

Just import, instantiate and call:

<?php

use IpApi\IpApi;

$api = new IpApi();
$location = $api->locate('ip or address');

The \IpApi\Location object

The location object has an schema returned composed by the following fields by default:

  • status: Status of operation;
  • country: Country of address;
  • countryCode: Country code of address;
  • region: Region abbr (state) of address;
  • regionName": Region name (state) of address;
  • city: City of address;
  • zip: Zipcode of address;
  • lat: Latitude of address;
  • lon: Longitude of address;
  • timezone: Timezone related to address;
  • isp: The ISP organization;
  • org: The organization name related to address;
  • as: The AS number and name;
  • query: The address or IP used on query.

The location object has some others methods and features:

// Convert the object to an array
$data = $location->toArray();

// JSON encode
$json = json_encode($location);

About

A simple API for ip-api.com using PHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages