Nhập tên miền và nhấn "Tra cứu"
Giới thiệu
API tra cứu WHOIS cho phép bạn kiểm tra thông tin tên miền nhanh chóng và chính xác. Dữ liệu được tự động cache 1 giờ để giảm tải server.
Lưu ý: API hỗ trợ CORS, cho phép gọi từ mọi domain. Hỗ trợ JSON và XML.
Endpoint
GET https://portal.vnhost.vn/api/domain/whois?domain={domain}&refreshCache={boolean}&format={json|xml}
Tham số
Bắt buộc
- domain - Tên miền cần tra cứu
Tùy chọn
- refreshCache - true/false
- format - json hoặc xml
Ví dụ gọi API
1. Gọi API cơ bản:
curl "https://portal.vnhost.vn/api/domain/whois?domain=google.com"
2. Gọi API với refresh cache:
curl "https://portal.vnhost.vn/api/domain/whois?domain=google.com&refreshCache=true"
3. Gọi API trả về XML:
curl "https://portal.vnhost.vn/api/domain/whois?domain=google.com&format=xml"
Gọi API bằng PHP
<?php
$domain = 'google.com';
$url = "https://portal.vnhost.vn/api/domain/whois?domain=" . urlencode($domain);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$data = json_decode($response, true);
if ($data['data']['available']) {
echo "Domain {$domain} có sẵn để đăng ký!\n";
} else {
echo "Domain {$domain} đã được đăng ký.\n";
echo "Registrar: " . $data['data']['registrar'] . "\n";
echo "Hết hạn: " . $data['data']['expirationDate'] . "\n";
}
} else {
echo "Error: " . $data['message'] . "\n";
}
?>
Gọi API bằng JavaScript
fetch('https://portal.vnhost.vn/api/domain/whois?domain=google.com')
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
console.log('Domain:', data.data.domainName);
console.log('Available:', data.data.available);
console.log('Registrar:', data.data.registrar);
console.log('Name Servers:', data.data.nameServer);
console.log('Creation Date:', data.data.creationDate);
console.log('Expiration Date:', data.data.expirationDate);
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Error:', error));
Response mẫu (JSON)
{
"status": "success",
"code": 200,
"message": "WHOIS information retrieved successfully",
"data": {
"domainName": "google.com",
"available": false,
"registrar": "MarkMonitor Inc.",
"nameServer": ["ns1.google.com", "ns2.google.com"],
"creationDate": "1997-09-15",
"expirationDate": "2028-09-14",
"registrantName": "Google LLC",
"DNSSEC": "Unsigned",
"status": ["clientDeleteProhibited", "clientTransferProhibited"],
"raw": null
}
}
Response mẫu (XML)
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>success</status>
<code>200</code>
<message>WHOIS information retrieved successfully</message>
<data>
<domainName>google.com</domainName>
<available>false</available>
<registrar>MarkMonitor Inc.</registrar>
<nameServer>ns1.google.com</nameServer>
<nameServer>ns2.google.com</nameServer>
<creationDate>1997-09-15</creationDate>
<expirationDate>2028-09-14</expirationDate>
<registrantName>Google LLC</registrantName>
<DNSSEC>Unsigned</DNSSEC>
<status>clientDeleteProhibited</status>
<status>clientTransferProhibited</status>
</data>
</response>