- PHP 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github | ||
| examples | ||
| src | ||
| tests | ||
| .gitignore | ||
| autoload.php | ||
| CHANGELOG.md | ||
| composer.json | ||
| LICENSE | ||
| README.md | ||
| README.pt.md | ||
| repo.json | ||
PHP WHOIS for MozOut
A small PHP library for the free WHOIS of the MozOut API. Ask whether a domain is free or registered, when it expires, its nameservers, what it costs to register, and which similar names are free.
Install
composer require mozout/php-whois
PHP 7.4 or newer with the json extension. No other packages. It uses cURL when it is there, and PHP streams when it is not. Without Composer, require the autoload.php of this package.
Get started
use MozOut\Whois\Client;
$whois = new Client();
$result = $whois->lookup('example.com');
if ($result->isAvailable()) {
echo 'Free for ' . $result->registerPrice() . ' ' . $result->currency() . ' a year: ' . $result->registerUrl();
} elseif ($result->isRegistered()) {
echo 'Registered until ' . $result->expiresAt()->format('d/m/Y');
}
No key is needed: you get 60 lookups per hour per IP. With an API key of your account, Sandbox or Production, you get 1,000 per hour per account (resellers: 10,000). Create one in the API Center of My MozOut, then pass it or set the MOZOUT_API_KEY environment variable:
$whois = new Client(['api_key' => getenv('MOZOUT_API_KEY')]); // the same as new Client() when the variable is set
What the result gives you
| Method | What it returns |
|---|---|
status() |
available, registered, unknown or not_allowed |
isAvailable(), isRegistered() |
true or false |
expiresAt(), createdAt(), updatedAt() |
DateTimeImmutable or null |
daysUntilExpiry(), nameservers(), domainStatus() |
days, list of nameservers, list of statuses |
registration(), contacts() |
all registration data, and the contacts the registry publishes |
registerPrice($years), renewPrice($years), transferPrice() |
the price, or null |
currency(), isPremium(), quoteRequired() |
the currency, short premium names, names that need a quote |
alternatives() |
up to 4 free names, each with domain, price and register_url |
registerUrl(), transferUrl() |
the page to register a free name or transfer a registered one |
toArray(), get('field') |
everything the API sent |
More
Several domains in one request (up to 10, each counts 1 in the limit):
foreach ($whois->lookupMany(['example.com', 'mycompany.com']) as $domain => $r) {
echo $domain . ': ' . ($r->isError() ? $r->error()['message'] : $r->status()) . PHP_EOL;
}
Prices in another currency of the brand, and website links in Portuguese:
$whois = new Client(['currency' => 'USD', 'language' => 'pt']); // for every lookup
$whois->lookup('example.com', ['currency' => 'USD']); // or only for this one
Errors are exceptions you can catch:
use MozOut\Whois\Exception\RateLimitException;
use MozOut\Whois\Exception\ValidationException;
use MozOut\Whois\Exception\WhoisException;
try {
$r = $whois->lookup('example.invalid');
} catch (ValidationException $e) {
echo $e->getReason(); // extension_not_supported: an extension we do not sell
} catch (RateLimitException $e) {
echo $e->getRetryAfter(); // seconds to wait
} catch (WhoisException $e) {
echo $e->getMessage(); // anything else; getCorrelationId() helps support
}
Options of new Client([...]): api_key, currency, language (pt or en), timeout (15 seconds), retries (1, only on network errors and 5xx) and user_agent.
Tests
php tests/run.php # offline, no network
php tests/live.php example.com # real lookups, uses your hourly limit
The WHOIS API docs: https://docs.mozout.com/whois/
Domain extensions (502)
Most popular: .com, .net, .org, .info, .biz, .co, .io, .ai, .me, .tv, .app, .dev, .online, .store, .site, .shop, .tech, .xyz, .cloud, .pro
All others: .abogado, .ac, .ac.mz, .academy, .accountant, .accountants, .actor, .ad, .adult, .adv.mz, .africa.com, .agency, .airforce, .ao, .apartments, .archi, .army, .art, .asia, .associates, .attorney, .auction, .audio, .auto, .autos, .baby, .band, .bar, .barcelona, .bargains, .beauty, .beer, .berlin, .best, .bet, .bike, .bingo, .bio, .black, .blackfriday, .blog, .blue, .boats, .bond, .boo, .boston, .bot, .boutique, .br, .broker, .build, .builders, .business, .buzz, .ca, .cab, .cafe, .cam, .camera, .camp, .capetown, .capital, .car, .cards, .care, .career, .careers, .cars, .casa, .cash, .casino, .cat, .catering, .cc, .center, .ceo, .cfd, .channel, .charity, .chat, .cheap, .christmas, .church, .city, .claims, .cleaning, .click, .clinic, .clothing, .club, .co.ao, .co.mz, .co.uk, .co.za, .coach, .codes, .coffee, .college, .community, .company, .compare, .computer, .condos, .construction, .consulting, .contact, .contractors, .cooking, .cool, .country, .coupons, .courses, .credit, .creditcard, .cricket, .cruises, .cv, .cymru, .cyou, .dad, .dance, .date, .dating, .day, .de, .deal, .dealer, .deals, .degree, .delivery, .democrat, .dental, .dentist, .design, .diamonds, .diet, .digital, .direct, .directory, .discount, .diy, .doctor, .dog, .domains, .download, .durban, .eat, .eco, .edu.ao, .edu.mz, .education, .email, .energy, .engineer, .engineering, .enterprises, .equipment, .es, .esq, .estate, .eu, .events, .exchange, .expert, .exposed, .express, .fail, .faith, .family, .fan, .fans, .farm, .fashion, .fast, .feedback, .finance, .financial, .fish, .fishing, .fit, .fitness, .flights, .florist, .flowers, .fly, .fm, .foo, .food, .football, .forex, .forsale, .forum, .foundation, .free, .fun, .fund, .furniture, .futbol, .fyi, .gallery, .game, .games, .garden, .gay, .gg, .gifts, .gives, .giving, .glass, .global, .gmbh, .gold, .golf, .gov.mz, .graphics, .gratis, .green, .gripe, .group, .guide, .guitars, .guru, .hair, .haus, .health, .healthcare, .help, .here, .hiphop, .hiv, .hockey, .holdings, .holiday, .homes, .horse, .hospital, .host, .hosting, .hot, .house, .how, .icu, .id, .im, .immo, .immobilien, .in, .inc, .industries, .ing, .ink, .institute, .insure, .international, .investments, .irish, .it.ao, .je, .jetzt, .jewelry, .kaufen, .kids, .kim, .kitchen, .land, .lat, .latino, .law, .lawyer, .lease, .legal, .lgbt, .life, .lifestyle, .lighting, .limited, .limo, .link, .live, .living, .llc, .loan, .loans, .locker, .lol, .london, .lotto, .love, .ltd, .luxe, .luxury, .maison, .makeup, .management, .market, .marketing, .markets, .mba, .media, .meme, .memorial, .men, .miami, .mil.mz, .mobi, .mobile, .moda, .mom, .money, .monster, .mortgage, .motorcycles, .mov, .movie, .music, .my, .navy, .net.mz, .network, .new, .news, .nexus, .ninja, .nl, .now, .nyc, .observer, .one, .ong, .org.ao, .org.mz, .page, .partners, .parts, .party, .pet, .phd, .photo, .photography, .photos, .pics, .pictures, .pink, .pizza, .place, .plumbing, .plus, .poker, .porn, .press, .productions, .prof, .promo, .properties, .property, .protection, .pub, .pw, .quest, .racing, .realty, .recipes, .red, .rehab, .reise, .reisen, .rent, .rentals, .repair, .report, .republican, .rest, .restaurant, .review, .reviews, .rip, .rocks, .rodeo, .rsvp, .run, .sale, .salon, .sarl, .sbs, .school, .schule, .science, .security, .select, .services, .sex, .sexy, .sh, .shiksha, .shoes, .shopping, .show, .si, .singles, .ski, .skin, .soccer, .social, .software, .solar, .solutions, .soy, .space, .spot, .storage, .stream, .studio, .study, .style, .supplies, .supply, .support, .surf, .surgery, .systems, .talk, .tattoo, .tax, .taxi, .team, .technology, .tel, .tennis, .theater, .theatre, .tickets, .tienda, .tips, .tires, .to, .today, .tools, .top, .tours, .town, .toys, .trade, .trading, .training, .tube, .uk, .university, .uno, .us, .vacations, .vana, .ventures, .vet, .viajes, .video, .villas, .vin, .vip, .vision, .vodka, .vote, .voto, .voyage, .wales, .watch, .webcam, .website, .wedding, .wiki, .win, .wine, .work, .works, .world, .wtf, .xxx, .yachts, .yoga, .you, .za.com, .zip, .zone
License
MIT. See LICENSE.
Maintained by RLX Holdings.