0

Search email

by
Published Apr 8, 2025

Foxentry will automatically offer you suggestions to complete the e-mail address you are writing down. This mainly serves as autocomplete. Pay attention to the client section in the request body. You can specify the user's location in order to receive more relevant suggestions.

Script foxentry Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Foxentry = {
3
  apiKey: string;
4
};
5
/**
6
 * Search email
7
 * Foxentry will automatically offer you suggestions to complete the e-mail address you are writing down. This mainly serves as autocomplete. Pay attention to the client section in the request body. You can specify the user's location in order to receive more relevant suggestions.
8
 */
9
export async function main(
10
  auth: Foxentry,
11
  api_version: string | undefined,
12
  foxentry_include_request_details: string | undefined,
13
  body: {
14
    request: {
15
      customId?: string;
16
      query: { value: string };
17
      options?: { resultsLimit?: number };
18
      client?: {
19
        ip?: string;
20
        country?: string;
21
        location?: { lat?: number; lon?: number };
22
      };
23
    };
24
  },
25
) {
26
  const url = new URL(`https://api.foxentry.com/email/search`);
27

28
  const headers: Record<string, string> = {
29
    "Content-Type": "application/json",
30
    Authorization: "Bearer " + auth.apiKey,
31
  };
32

33
  if (api_version) {
34
    headers["api-version"] = api_version;
35
  }
36
  if (foxentry_include_request_details) {
37
    headers["foxentry-include-request-details"] = foxentry_include_request_details;
38
  }
39

40
  const response = await fetch(url, {
41
    method: "POST",
42
    headers,
43
    body: JSON.stringify(body),
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51