PHP SDK · Feature

ASN & DNS Lookups in PHP

Resolve the network and DNS layer behind an IP or domain: which autonomous system owns an address, who registered a domain, what a host's PTR record is, and which mail servers a domain uses — all from the same client.

Trusted by thousands of businesses
Fast JSON API responses
Real-time validation
Simple integration, SDKs & examples
What it does

Network ownership and DNS in one client

Behind every IP and domain is a network and DNS layer that tells you who owns the address space, when a domain was registered, and how its mail and hostnames resolve. ip-api.io exposes ASN, WHOIS, reverse/forward DNS, and MX lookups through the same client, so you can enrich logs, verify ownership, and feed fraud rules without juggling separate DNS libraries.

Prerequisites

1

Autonomous system with asn

Returns the ASN, owning organization, network range, and country for an IP — and whether it belongs to a datacenter.

<?php

use IpApiIo\Client;

$client = new Client(apiKey: getenv('IP_API_IO_KEY'));

$asn = $client->asn('8.8.8.8');

echo $asn['asn'];            // 15169
echo $asn['organization'];   // "Google LLC"
echo $asn['network'];        // "8.8.8.0/24"
var_dump($asn['is_datacenter']); // true
echo $asn['country_code'];   // "US"
2

Domain registration with whois

WHOIS record for a domain: registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text.

$whois = $client->whois('example.com');

echo $whois['registrar']['name'];
echo $whois['registered_on'];     // "1995-08-14"
echo $whois['expires_on'];
print_r($whois['name_servers']);  // ["a.iana-servers.net", ...]
echo $whois['status'][0]['humanized'];
3

DNS with reverseDns, forwardDns & mxRecords

Resolve a PTR record, resolve a hostname to addresses, or list a domain's mail servers.

$rdns = $client->reverseDns('8.8.8.8');
echo $rdns['hostname'];    // "dns.google"

$fdns = $client->forwardDns('dns.google');
foreach ($fdns['addresses'] as $record) {
    echo $record['type'], ' ', $record['address'], ' ', $record['ttl']; // "A" "8.8.8.8" 300
}

$mx = $client->mxRecords('example.com');
foreach ($mx['mx_records'] as $record) {
    echo $record['priority'], ' ', $record['hostname'], ' ', $record['ttl'];
}
Reference

Response reference

MethodReturnsKey fields
asn($ip)arrayip, asn, organization, network, is_datacenter, country, country_code
whois($domain)arraydomain, registrar, registered_on, expires_on, updated_on, name_servers, status, raw
reverseDns($ip)arrayip, hostname, ptr_record, ttl
forwardDns($hostname)arrayhostname, addresses (each type, address, ttl)
mxRecords($domain)arraydomain, mx_records (each priority, hostname, ttl)
FAQ

Frequently asked questions

How do I find the ASN and owner of an IP in PHP?

Call $client->asn($ip). It returns the ASN number, owning organization, network range, country, and whether the IP belongs to a datacenter.

How do I do a WHOIS lookup in PHP?

Use $client->whois($domain). It returns the registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text for a domain.

Can I do reverse and forward DNS lookups?

Yes. $client->reverseDns($ip) returns the PTR hostname for an IP, and $client->forwardDns($hostname) resolves a hostname to its A/AAAA addresses. $client->mxRecords($domain) returns a domain's mail servers.

What's the difference between mxRecords here and email validation?

mxRecords($domain) returns the raw MX records (priority, hostname, ttl) for DNS inspection. The email validation methods use MX presence as one input to a deliverability verdict for a specific address.

Start building with the ip-api.io PHP SDK

Run composer require ip-api-io/ipapi-php, drop in your free API key, and ship in minutes — one zero-dependency client for geolocation, fraud detection, and email validation.

Need support?

Explore how IP-API.io can enhance your security, provide robust bot protection, and improve IP geolocation accuracy for your applications.

Contact Support

Found a bug in the SDK?

The ip-api-io/ipapi-php package is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub