PHP SDK
The IPWho PHP SDK wraps the IP geolocation API in idiomatic PHP — typed response objects, built-in error handling, and a single composer require. One call returns the full payload: geolocation, timezone, currency, connection (ASN/ISP), security flags, and more.
- Source: lavrox/SDK-IPWho-IP-Geolocation-PHP
- Packagist:
ipwho/ipwho-ip-geolocation-apiv2.0.0 - API key: ipwho.org/free-plan
Installation
Section titled “Installation”composer require ipwho/ipwho-ip-geolocation-apiPHP >= 7.4, ext-json, Guzzle ^7. Namespace: IpWho\SDK\Client.
Quick start
Section titled “Quick start”<?phprequire 'vendor/autoload.php';
use IpWho\SDK\Client;
$client = new Client(getenv('IPWHO_API_KEY'));
$res = $client->lookup('8.8.8.8'); // GET /ip/{ip}$me = $client->me(); // GET /me$bulk = $client->bulk(['8.8.8.8', '1.1.1.1']); // GET /bulk/{a,b,c}
echo $res->data->geoLocation->country; // United StatesError handling
Section titled “Error handling”use IpWho\SDK\Exceptions\InvalidIPError;use IpWho\SDK\Exceptions\RateLimitError;use IpWho\SDK\Exceptions\APIResponseError;
try { $res = $client->lookup('8.8.8.8');} catch (InvalidIPError $e) { // malformed IP address (404)} catch (RateLimitError $e) { // plan limit reached (429)} catch (APIResponseError $e) { // unexpected response}Migrating from v1
Section titled “Migrating from v1”| v1 | v2 |
|---|---|
getIp / getLocation($ip) | lookup($ip) then $res->data->geoLocation |
getMe / getLocation() | me() |
| (missing) | bulk($ips) |
Methods
Section titled “Methods”lookup($ip)—GET /ip/{ip}me()—GET /mebulk($ips)—GET /bulk/{a,b,c}; rows ondata->responseArray