Download the PHP package gam6itko/ipquery-client without Composer
On this page you can find all versions of the php package gam6itko/ipquery-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ipquery-client
php-ipquery-client
Framework-agnostic PHP client for a self-hosted IPQuery geo service: resolve country, ISP and risk data by IP address. Built on PSR-18 (HTTP client) and PSR-17 (HTTP factories), so it works with any PSR-7 implementation.
[!IMPORTANT] This client targets the self-hosted
akyriako/ipqueryserver (endpointGET /lookup/{ip}). It is NOT compatible with the public SaaS ipquery.io — that service has a different API (endpoints and response shape). Foripquery.iouse one of these instead:
Installation
Usage
Endpoints
| Method | Server endpoint | Returns |
|---|---|---|
lookup(string $ip) |
GET /lookup/{ip} |
TIPQueryResult for the given IP |
own() |
GET /own/all |
TIPQueryResult for the caller's own IP |
ownIp() |
GET /own |
non-empty-string — the caller's own IP |
own()/ownIp()live onIPQueryClientonly;LookupInterface(the cacheable, mockable contract used viaCachedIPQuery/IPQueryStub) exposes justlookup().
Error handling
Every failure throws an exception implementing Gam6itko\IPQuery\ExceptionInterface:
lookup() accepts both IPv4 and IPv6 — a string that is not a valid IP address is rejected up
front with InvalidIpException (a LookupException, so existing catch blocks keep working). For an
unexpected HTTP status the code is available via getStatusCode() (null for transport/parsing/
validation failures):
Caching
CachedIPQuery decorates any IPQueryInterface with a PSR-16 cache (the IP-to-country
mapping changes rarely; failures are never cached):
Retrying transient failures
RetryingIPQuery decorates any LookupInterface and retries transient failures with
exponential backoff — a transport error, a 5xx status, or 429. Deterministic failures
(InvalidIpException, other 4xx) fail fast and are never retried:
Override which failures are retried via the $retryable callback
(\Closure(LookupException $e, int $attempt): bool).
Testing
Use IPQueryStub as a test double — it returns a canned result or throws a given exception:
Response contract
lookup() returns the decoded /lookup/{ip} payload (psalm type TIPQueryResult):
| Key | Shape |
|---|---|
ip |
string |
isp |
{asn, org, isp} |
location |
{country, country_code, city, state, zipcode, latitude, longitude, timezone, localtime} |
risk |
{abuse_confidence_score, usage_type, is_tor, total_reports, number_of_users_reported, last_reported_at} |
Development
License
MIT — see LICENSE.
All versions of ipquery-client with dependencies
ext-json Version *
psr/http-client Version ^1.0.3
psr/http-factory Version ^1.1
psr/http-message Version ^1.1 || ^2.0
psr/simple-cache Version ^1.0 || ^2.0 || ^3.0