-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_single.js
More file actions
49 lines (41 loc) · 1.32 KB
/
verify_single.js
File metadata and controls
49 lines (41 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Verify a single email address using the OrbiSearch API.
*/
const API_KEY = "your_api_key_here";
const BASE_URL = "https://api.orbisearch.com";
/**
* Verify a single email address.
* @param {string} email - Email address to verify
* @param {number} timeout - Timeout in seconds (3-90, default 70)
* @returns {Promise<object>} Verification result
*/
async function verifyEmail(email, timeout = 70) {
const params = new URLSearchParams({ email, timeout });
const response = await fetch(`${BASE_URL}/v1/verify?${params}`, {
method: "GET",
headers: {
"X-API-Key": API_KEY,
},
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return response.json();
}
// Example usage
async function main() {
try {
const result = await verifyEmail("test@example.com");
console.log(`Email: ${result.email}`);
console.log(`Status: ${result.status}`);
console.log(`Substatus: ${result.substatus}`);
console.log(`Explanation: ${result.explanation}`);
console.log(`Provider: ${result.email_provider}`);
console.log(`Is Disposable: ${result.is_disposable}`);
console.log(`Is Role Account: ${result.is_role_account}`);
console.log(`Is Free: ${result.is_free}`);
} catch (error) {
console.error("Error:", error.message);
}
}
main();