0

Validate name data

by
Published Apr 8, 2025

Foxentry allows you to check the validity and real existence of names and their combinations.

Script foxentry Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Foxentry = {
3
  apiKey: string;
4
};
5
/**
6
 * Validate name data
7
 * Foxentry allows you to check the validity and real existence of names and their combinations.
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: { name?: string; surname?: string } | { nameSurname: string };
17
      options?: {
18
        dataScope?: "basic" | "full";
19
        dataSource?: string[];
20
        acceptDegrees?: false | true;
21
        acceptContext?: false | true;
22
        validationDepth?: "minimal" | "moderate" | "strict";
23
        smartMode?: false | true;
24
      };
25
      client?: {
26
        ip?: string;
27
        country?: string;
28
        location?: { lat?: number; lon?: number };
29
      };
30
    };
31
  },
32
) {
33
  const url = new URL(`https://api.foxentry.com/name/validate`);
34

35
  const headers: Record<string, string> = {
36
    "Content-Type": "application/json",
37
    Authorization: "Bearer " + auth.apiKey,
38
  };
39

40
  if (api_version) {
41
    headers["api-version"] = api_version;
42
  }
43
  if (foxentry_include_request_details) {
44
    headers["foxentry-include-request-details"] = foxentry_include_request_details;
45
  }
46

47
  const response = await fetch(url, {
48
    method: "POST",
49
    headers,
50
    body: JSON.stringify(body),
51
  });
52
  if (!response.ok) {
53
    const text = await response.text();
54
    throw new Error(`${response.status} ${text}`);
55
  }
56
  return await response.json();
57
}
58