0

List accounts

by
Published Oct 17, 2025
Script salesflare Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Salesflare = {
3
  apiKey: string;
4
};
5
/**
6
 * List accounts
7
 *
8
 */
9
export async function main(
10
  auth: Salesflare,
11
  id: string | undefined,
12
  details: string | undefined,
13
  search: string | undefined,
14
  name: string | undefined,
15
  creation_after: string | undefined,
16
  creation_before: string | undefined,
17
  min_size: string | undefined,
18
  max_size: string | undefined,
19
  domain: string | undefined,
20
  tag: string | undefined,
21
  tag_name: string | undefined,
22
  address_country: string | undefined,
23
  address_city: string | undefined,
24
  address_state_region: string | undefined,
25
  hotness: string | undefined,
26
  offset: string | undefined,
27
  custom: string | undefined,
28
  order_by: string | undefined,
29
  q: string | undefined,
30
  limit: string | undefined,
31
  _export: string | undefined,
32
) {
33
  const url = new URL(`https://api.salesflare.com/accounts`);
34
  for (const [k, v] of [
35
    ["id", id],
36
    ["details", details],
37
    ["search", search],
38
    ["name", name],
39
    ["creation_after", creation_after],
40
    ["creation_before", creation_before],
41
    ["min_size", min_size],
42
    ["max_size", max_size],
43
    ["domain", domain],
44
    ["tag", tag],
45
    ["tag.name", tag_name],
46
    ["address.country", address_country],
47
    ["address.city", address_city],
48
    ["address.state_region", address_state_region],
49
    ["hotness", hotness],
50
    ["offset", offset],
51
    ["custom", custom],
52
    ["order_by", order_by],
53
    ["q", q],
54
    ["limit", limit],
55
    ["export", _export],
56
  ]) {
57
    if (v !== undefined && v !== "" && k !== undefined) {
58
      url.searchParams.append(k, v);
59
    }
60
  }
61
  const response = await fetch(url, {
62
    method: "GET",
63
    headers: {
64
      Authorization: "Bearer " + auth.apiKey,
65
    },
66
    body: undefined,
67
  });
68
  if (!response.ok) {
69
    const text = await response.text();
70
    throw new Error(`${response.status} ${text}`);
71
  }
72
  return await response.text();
73
}
74