@leadsetsai/sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +373 -2
- package/dist/index.cjs +472 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +588 -0
- package/dist/index.d.ts +588 -0
- package/dist/index.js +450 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request and response types for the Leadsets API v1.
|
|
3
|
+
*
|
|
4
|
+
* Response objects are plain JSON from the API. Every response also carries a
|
|
5
|
+
* non-enumerable `lastResponse` with the HTTP status, headers and rate-limit info.
|
|
6
|
+
*/
|
|
7
|
+
type Seniority = 'c_level' | 'vp' | 'head' | 'director' | 'manager' | 'ic';
|
|
8
|
+
type PersonFunction = 'revenue' | 'marketing' | 'engineering' | 'product' | 'ops' | 'finance' | 'hr';
|
|
9
|
+
type Plan = 'free' | 'solo' | 'pro' | 'team' | 'max';
|
|
10
|
+
/** Status of an email attached to a person. Invalid emails are never returned. */
|
|
11
|
+
type EmailStatus = 'verified' | 'catch_all' | 'unknown';
|
|
12
|
+
/** Status from `emails.verify`. */
|
|
13
|
+
type VerificationStatus = 'verified' | 'catch_all' | 'unknown' | 'invalid';
|
|
14
|
+
/** A value or a list of values. */
|
|
15
|
+
type OneOrMany<T> = T | T[];
|
|
16
|
+
/** When a field was last seen and how confident we are in it. */
|
|
17
|
+
interface FieldSource {
|
|
18
|
+
seen_at: string | null;
|
|
19
|
+
confidence: number | null;
|
|
20
|
+
}
|
|
21
|
+
interface Location {
|
|
22
|
+
country: string | null;
|
|
23
|
+
region: string | null;
|
|
24
|
+
city: string | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* What this call counted and what is left. Which keys appear depends on the endpoint and
|
|
28
|
+
* the plan: paid plans get the five-hour and weekly meters, Free gets the one-time balances,
|
|
29
|
+
* scrape endpoints get scrape units.
|
|
30
|
+
*/
|
|
31
|
+
interface Usage {
|
|
32
|
+
search_records_counted?: number;
|
|
33
|
+
search_records_left_5h?: number;
|
|
34
|
+
search_requests_left_5h?: number;
|
|
35
|
+
search_records_left_week?: number;
|
|
36
|
+
free_search_records_left?: number;
|
|
37
|
+
enrich_records_counted?: number;
|
|
38
|
+
enrich_records_left_5h?: number;
|
|
39
|
+
enrich_requests_left_5h?: number;
|
|
40
|
+
enrich_records_left_week?: number;
|
|
41
|
+
free_enrich_records_left?: number;
|
|
42
|
+
free_calls_left?: number;
|
|
43
|
+
scrape_units_counted?: number;
|
|
44
|
+
scrape_units_left?: number;
|
|
45
|
+
/** True when limits could not be checked for this call. */
|
|
46
|
+
degraded?: boolean;
|
|
47
|
+
[key: string]: number | boolean | undefined;
|
|
48
|
+
}
|
|
49
|
+
/** Rate-limit headers of a response, parsed. `null` when the header was absent. */
|
|
50
|
+
interface RateLimitInfo {
|
|
51
|
+
/** `X-Leadsets-Records-Remaining`: records left in this kind's five-hour window. */
|
|
52
|
+
recordsRemaining: number | null;
|
|
53
|
+
/** `X-Leadsets-Requests-Remaining`: requests left in this kind's five-hour window. */
|
|
54
|
+
requestsRemaining: number | null;
|
|
55
|
+
/** `X-Leadsets-Weekly-Remaining`: records left in this kind's weekly window. */
|
|
56
|
+
weeklyRemaining: number | null;
|
|
57
|
+
/** `X-Leadsets-Free-Remaining`: Free plan only, free records left. */
|
|
58
|
+
freeRemaining: number | null;
|
|
59
|
+
/** `Retry-After` in seconds. */
|
|
60
|
+
retryAfter: number | null;
|
|
61
|
+
}
|
|
62
|
+
/** HTTP details of a response. Available as the non-enumerable `lastResponse` on every result. */
|
|
63
|
+
interface ResponseMeta {
|
|
64
|
+
status: number;
|
|
65
|
+
headers: Headers;
|
|
66
|
+
requestId: string | null;
|
|
67
|
+
/** The Idempotency-Key that was sent, if any. */
|
|
68
|
+
idempotencyKey: string | null;
|
|
69
|
+
/** True when the API replayed a stored result for this Idempotency-Key (nothing was counted again). */
|
|
70
|
+
idempotentReplayed: boolean;
|
|
71
|
+
rateLimit: RateLimitInfo;
|
|
72
|
+
/** How many HTTP attempts the call took (1 = no retries). */
|
|
73
|
+
attempts: number;
|
|
74
|
+
}
|
|
75
|
+
interface APIResponse {
|
|
76
|
+
/** Quote it to support: we can see exactly what happened. */
|
|
77
|
+
request_id: string;
|
|
78
|
+
usage: Usage;
|
|
79
|
+
/** HTTP status, headers and rate-limit info. Not serialized by JSON.stringify. */
|
|
80
|
+
readonly lastResponse: ResponseMeta;
|
|
81
|
+
}
|
|
82
|
+
interface Email {
|
|
83
|
+
address: string;
|
|
84
|
+
status: EmailStatus;
|
|
85
|
+
type: 'business' | 'personal' | string;
|
|
86
|
+
confidence: number;
|
|
87
|
+
checked_at: string | null;
|
|
88
|
+
mx_provider: string | null;
|
|
89
|
+
}
|
|
90
|
+
interface PersonCompany {
|
|
91
|
+
company_id: string | null;
|
|
92
|
+
name: string | null;
|
|
93
|
+
domain: string | null;
|
|
94
|
+
industry: string | null;
|
|
95
|
+
employees: number | null;
|
|
96
|
+
employee_range: string | null;
|
|
97
|
+
}
|
|
98
|
+
interface Person {
|
|
99
|
+
person_id: string;
|
|
100
|
+
full_name: string | null;
|
|
101
|
+
first_name: string | null;
|
|
102
|
+
last_name: string | null;
|
|
103
|
+
title: string | null;
|
|
104
|
+
seniority: Seniority | null;
|
|
105
|
+
/** Finer-grained seniority, e.g. "founder" or "senior". */
|
|
106
|
+
seniority_detail: string | null;
|
|
107
|
+
function: PersonFunction | null;
|
|
108
|
+
/** Finer-grained function, e.g. "sales" or "revops". */
|
|
109
|
+
function_detail: string | null;
|
|
110
|
+
linkedin_url: string | null;
|
|
111
|
+
location: Location;
|
|
112
|
+
company: PersonCompany | null;
|
|
113
|
+
email: Email | null;
|
|
114
|
+
/** Present on `people.enrich` with `include_personal_email`. */
|
|
115
|
+
personal_email?: Email | null;
|
|
116
|
+
/** Which filters this record matched (search results only). */
|
|
117
|
+
match_reasons?: string[];
|
|
118
|
+
refreshed_at: string | null;
|
|
119
|
+
confirmed_at: string | null;
|
|
120
|
+
stale_after_at: string | null;
|
|
121
|
+
stale: boolean;
|
|
122
|
+
/** Source, last-seen date and confidence for every field that has a value. */
|
|
123
|
+
sources: Record<string, FieldSource>;
|
|
124
|
+
}
|
|
125
|
+
interface PeopleSearchParams {
|
|
126
|
+
/** Job titles. Fuzzy-matched: "VP Sales" also finds "Vice President, Sales". */
|
|
127
|
+
title?: OneOrMany<string>;
|
|
128
|
+
seniority?: OneOrMany<Seniority>;
|
|
129
|
+
function?: OneOrMany<PersonFunction>;
|
|
130
|
+
/** Only people at these companies (domains). */
|
|
131
|
+
company_domain?: OneOrMany<string>;
|
|
132
|
+
/** Company headcount range, e.g. "50-200", "1000+" or "<50". */
|
|
133
|
+
employees?: string;
|
|
134
|
+
/** Leadsets industry slugs, e.g. "saas". */
|
|
135
|
+
industry?: OneOrMany<string>;
|
|
136
|
+
/** ISO 3166-1 alpha-2 country codes, e.g. "US". */
|
|
137
|
+
country?: OneOrMany<string>;
|
|
138
|
+
/** Only people with a verified work email. */
|
|
139
|
+
has_verified_email?: boolean;
|
|
140
|
+
/** Only records refreshed within this many days. */
|
|
141
|
+
max_age_days?: number;
|
|
142
|
+
/** Leave out records flagged stale. */
|
|
143
|
+
exclude_stale?: boolean;
|
|
144
|
+
/** 1–100. Default 25. Free plan: at most 10. */
|
|
145
|
+
limit?: number;
|
|
146
|
+
/** `next_cursor` from the previous page. */
|
|
147
|
+
cursor?: string;
|
|
148
|
+
/** Optional: the request in plain language, kept with your request log. */
|
|
149
|
+
prompt?: string;
|
|
150
|
+
}
|
|
151
|
+
interface PeopleSearchResponse extends APIResponse {
|
|
152
|
+
items: Person[];
|
|
153
|
+
next_cursor: string | null;
|
|
154
|
+
}
|
|
155
|
+
interface PersonEnrichParams {
|
|
156
|
+
/** LinkedIn profile URL (strongest identifier). */
|
|
157
|
+
linkedin_url?: string;
|
|
158
|
+
/** A known work email. */
|
|
159
|
+
email?: string;
|
|
160
|
+
/** Full name; use with `company_domain`. */
|
|
161
|
+
full_name?: string;
|
|
162
|
+
first_name?: string;
|
|
163
|
+
last_name?: string;
|
|
164
|
+
/** Company domain; use with a name. */
|
|
165
|
+
company_domain?: string;
|
|
166
|
+
/** Also return a personal email when there is one (paid plans). */
|
|
167
|
+
include_personal_email?: boolean;
|
|
168
|
+
prompt?: string;
|
|
169
|
+
}
|
|
170
|
+
interface PersonEnrichResponse extends APIResponse {
|
|
171
|
+
person: Person;
|
|
172
|
+
matched_by: 'linkedin_url' | 'email' | 'name_and_domain';
|
|
173
|
+
/** Why a requested personal email was left out. */
|
|
174
|
+
personal_email_note?: string;
|
|
175
|
+
}
|
|
176
|
+
interface Company {
|
|
177
|
+
company_id: string;
|
|
178
|
+
name: string | null;
|
|
179
|
+
domain: string | null;
|
|
180
|
+
linkedin_url: string | null;
|
|
181
|
+
industry: string | null;
|
|
182
|
+
naics: string | null;
|
|
183
|
+
employees: number | null;
|
|
184
|
+
employee_range: string | null;
|
|
185
|
+
revenue_range: string | null;
|
|
186
|
+
location: Location;
|
|
187
|
+
founded_year: number | null;
|
|
188
|
+
description: string | null;
|
|
189
|
+
technologies: string[];
|
|
190
|
+
match_reasons?: string[];
|
|
191
|
+
refreshed_at: string | null;
|
|
192
|
+
confirmed_at: string | null;
|
|
193
|
+
stale_after_at: string | null;
|
|
194
|
+
stale: boolean;
|
|
195
|
+
sources: Record<string, FieldSource>;
|
|
196
|
+
}
|
|
197
|
+
interface CompaniesSearchParams {
|
|
198
|
+
industry?: OneOrMany<string>;
|
|
199
|
+
/** Headcount range, e.g. "50-200" or "1000+". */
|
|
200
|
+
employees?: string;
|
|
201
|
+
country?: OneOrMany<string>;
|
|
202
|
+
/** Technologies the company uses, e.g. "hubspot". Matches any. */
|
|
203
|
+
technology?: OneOrMany<string>;
|
|
204
|
+
/** Only these domains. */
|
|
205
|
+
domain?: OneOrMany<string>;
|
|
206
|
+
max_age_days?: number;
|
|
207
|
+
exclude_stale?: boolean;
|
|
208
|
+
/** 1–100. Default 25. Free plan: at most 10. */
|
|
209
|
+
limit?: number;
|
|
210
|
+
cursor?: string;
|
|
211
|
+
prompt?: string;
|
|
212
|
+
}
|
|
213
|
+
interface CompaniesSearchResponse extends APIResponse {
|
|
214
|
+
items: Company[];
|
|
215
|
+
next_cursor: string | null;
|
|
216
|
+
}
|
|
217
|
+
interface CompanyEnrichParams {
|
|
218
|
+
/** Company domain or website URL, e.g. "example.com". */
|
|
219
|
+
domain?: string;
|
|
220
|
+
/** LinkedIn company page URL. */
|
|
221
|
+
linkedin_url?: string;
|
|
222
|
+
prompt?: string;
|
|
223
|
+
}
|
|
224
|
+
interface CompanyEnrichResponse extends APIResponse {
|
|
225
|
+
company: Company;
|
|
226
|
+
}
|
|
227
|
+
interface EmailVerifyParams {
|
|
228
|
+
/** One email to verify. */
|
|
229
|
+
email?: string;
|
|
230
|
+
/** Up to 100 emails to verify. */
|
|
231
|
+
emails?: string[];
|
|
232
|
+
}
|
|
233
|
+
interface EmailVerification {
|
|
234
|
+
email: string;
|
|
235
|
+
/** `null` when the email was not checked (see `reason`); nothing was counted for it. */
|
|
236
|
+
status: VerificationStatus | null;
|
|
237
|
+
confidence: number | null;
|
|
238
|
+
checked_at: string | null;
|
|
239
|
+
mx_provider: string | null;
|
|
240
|
+
/** Why the email was not checked, e.g. "not_checked: limit reached". */
|
|
241
|
+
reason?: string;
|
|
242
|
+
}
|
|
243
|
+
interface EmailVerifySummary {
|
|
244
|
+
verified: number;
|
|
245
|
+
catch_all: number;
|
|
246
|
+
unknown: number;
|
|
247
|
+
invalid: number;
|
|
248
|
+
not_checked: number;
|
|
249
|
+
}
|
|
250
|
+
interface EmailVerifyResponse extends APIResponse {
|
|
251
|
+
results: EmailVerification[];
|
|
252
|
+
summary: EmailVerifySummary;
|
|
253
|
+
}
|
|
254
|
+
interface ScrapeParams {
|
|
255
|
+
/** Company domain, e.g. "example.com". */
|
|
256
|
+
domain?: string;
|
|
257
|
+
/** A specific page to start from (overrides domain). */
|
|
258
|
+
url?: string;
|
|
259
|
+
/** Pages to read, 1–10. 1 scrape unit per page read. */
|
|
260
|
+
max_pages?: number;
|
|
261
|
+
}
|
|
262
|
+
interface ScrapedPage {
|
|
263
|
+
url: string;
|
|
264
|
+
title: string | null;
|
|
265
|
+
description: string | null;
|
|
266
|
+
/** Page text as Markdown, truncated. */
|
|
267
|
+
text: string;
|
|
268
|
+
}
|
|
269
|
+
interface ScrapeCompanyResponse extends APIResponse {
|
|
270
|
+
domain: string;
|
|
271
|
+
url: string;
|
|
272
|
+
name: string | null;
|
|
273
|
+
description: string | null;
|
|
274
|
+
headings: string[];
|
|
275
|
+
/** e.g. pricing, about, customers, careers, contact, blog, docs, product, login, signup. */
|
|
276
|
+
key_links: Record<string, string>;
|
|
277
|
+
/** e.g. linkedin, x, github, youtube, facebook, instagram. */
|
|
278
|
+
social: Record<string, string>;
|
|
279
|
+
pages: ScrapedPage[];
|
|
280
|
+
units_used: number;
|
|
281
|
+
scraped_at: string;
|
|
282
|
+
}
|
|
283
|
+
interface Job {
|
|
284
|
+
title: string;
|
|
285
|
+
url: string;
|
|
286
|
+
location: string | null;
|
|
287
|
+
team: string | null;
|
|
288
|
+
posted: string | null;
|
|
289
|
+
/** Where the role is listed, e.g. "greenhouse", "lever" or "site". */
|
|
290
|
+
source: string;
|
|
291
|
+
found_on: string;
|
|
292
|
+
}
|
|
293
|
+
interface ScrapeJobsResponse extends APIResponse {
|
|
294
|
+
domain: string;
|
|
295
|
+
careers_url: string;
|
|
296
|
+
jobs: Job[];
|
|
297
|
+
count: number;
|
|
298
|
+
units_used: number;
|
|
299
|
+
scraped_at: string;
|
|
300
|
+
}
|
|
301
|
+
interface AsyncJob extends APIResponse {
|
|
302
|
+
id: string;
|
|
303
|
+
status: string;
|
|
304
|
+
[key: string]: unknown;
|
|
305
|
+
}
|
|
306
|
+
/** `[used, limit]`. */
|
|
307
|
+
type Meter = [number, number];
|
|
308
|
+
interface WindowMeters {
|
|
309
|
+
records_5h: Meter;
|
|
310
|
+
requests_5h: Meter;
|
|
311
|
+
records_week: Meter;
|
|
312
|
+
resets_at: string | null;
|
|
313
|
+
week_resets_at: string | null;
|
|
314
|
+
}
|
|
315
|
+
interface Unavailable {
|
|
316
|
+
unavailable: true;
|
|
317
|
+
}
|
|
318
|
+
interface FreeMeters {
|
|
319
|
+
search_records: Meter;
|
|
320
|
+
enrich_records: Meter;
|
|
321
|
+
data_calls: Meter;
|
|
322
|
+
search_per_call: number;
|
|
323
|
+
note: string;
|
|
324
|
+
}
|
|
325
|
+
interface UsageResponse extends APIResponse {
|
|
326
|
+
plan: Plan;
|
|
327
|
+
/** Free plan: one-time balances. */
|
|
328
|
+
free?: FreeMeters;
|
|
329
|
+
/** Paid plans: enrichment windows. */
|
|
330
|
+
enrich?: WindowMeters | Unavailable;
|
|
331
|
+
/** Paid plans: search windows. */
|
|
332
|
+
search?: WindowMeters | Unavailable;
|
|
333
|
+
/** Plans with a weekly personal email cap. */
|
|
334
|
+
personal_emails_week?: Meter | Unavailable;
|
|
335
|
+
/** `[running, limit]`. `running` is null when it could not be read. */
|
|
336
|
+
concurrent_searches: [number | null, number];
|
|
337
|
+
scrape_units: number;
|
|
338
|
+
scraping: boolean;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
declare const DEFAULT_BASE_URL = "https://api.leadsets.ai";
|
|
342
|
+
type Fetch = (input: string, init: RequestInit) => Promise<Response>;
|
|
343
|
+
interface ClientOptions {
|
|
344
|
+
/** Your API key (`ls_live_…`). Defaults to the LEADSETS_API_KEY or LEADSETS_KEY environment variable. */
|
|
345
|
+
apiKey?: string | undefined;
|
|
346
|
+
/** Defaults to https://api.leadsets.ai (or the LEADSETS_BASE_URL environment variable). */
|
|
347
|
+
baseURL?: string | undefined;
|
|
348
|
+
/** Retries on 429, 5xx, timeouts and network errors. Default 2. */
|
|
349
|
+
maxRetries?: number | undefined;
|
|
350
|
+
/** Per-attempt timeout in milliseconds. Default 120000. */
|
|
351
|
+
timeout?: number | undefined;
|
|
352
|
+
/**
|
|
353
|
+
* The longest `Retry-After` the SDK will wait for before retrying, in milliseconds.
|
|
354
|
+
* A 429 asking for a longer wait (a weekly limit, say) is thrown at once. Default 60000.
|
|
355
|
+
*/
|
|
356
|
+
maxRetryDelay?: number | undefined;
|
|
357
|
+
/** A custom fetch implementation. Defaults to the global fetch. */
|
|
358
|
+
fetch?: Fetch | undefined;
|
|
359
|
+
/** Headers sent with every request. */
|
|
360
|
+
defaultHeaders?: Record<string, string> | undefined;
|
|
361
|
+
}
|
|
362
|
+
interface RequestOptions {
|
|
363
|
+
/**
|
|
364
|
+
* Idempotency-Key for this call. The SDK generates one for every paid call when you don't,
|
|
365
|
+
* and reuses it on retries, so a retry never counts records twice. Keys last 24 hours.
|
|
366
|
+
*/
|
|
367
|
+
idempotencyKey?: string | undefined;
|
|
368
|
+
maxRetries?: number | undefined;
|
|
369
|
+
timeout?: number | undefined;
|
|
370
|
+
signal?: AbortSignal | undefined;
|
|
371
|
+
headers?: Record<string, string> | undefined;
|
|
372
|
+
}
|
|
373
|
+
interface ApiRequest {
|
|
374
|
+
method: 'GET' | 'POST';
|
|
375
|
+
path: string;
|
|
376
|
+
body?: unknown;
|
|
377
|
+
/** Paid POSTs: send an Idempotency-Key. */
|
|
378
|
+
idempotent?: boolean;
|
|
379
|
+
}
|
|
380
|
+
declare class HttpClient {
|
|
381
|
+
readonly apiKey: string;
|
|
382
|
+
readonly baseURL: string;
|
|
383
|
+
readonly maxRetries: number;
|
|
384
|
+
readonly timeout: number;
|
|
385
|
+
readonly maxRetryDelay: number;
|
|
386
|
+
private readonly fetchImpl;
|
|
387
|
+
private readonly defaultHeaders;
|
|
388
|
+
constructor(opts?: ClientOptions);
|
|
389
|
+
request<T extends object>(req: ApiRequest, opts?: RequestOptions): Promise<T>;
|
|
390
|
+
/** Milliseconds to wait before retrying, or null to not retry. */
|
|
391
|
+
private retryDelay;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
interface PaginationOptions extends RequestOptions {
|
|
395
|
+
/** Stop after this many items (the last page asks only for what's left, so you pay for no more). */
|
|
396
|
+
maxItems?: number | undefined;
|
|
397
|
+
/** Stop after this many pages. */
|
|
398
|
+
maxPages?: number | undefined;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
declare class Companies {
|
|
402
|
+
private readonly http;
|
|
403
|
+
constructor(http: HttpClient);
|
|
404
|
+
/** POST /v1/companies/search. 1 search record per record returned; empty results use none. */
|
|
405
|
+
search(params?: CompaniesSearchParams, options?: RequestOptions): Promise<CompaniesSearchResponse>;
|
|
406
|
+
/** Every matching company, page after page. Use `maxItems` to cap what you pay for. */
|
|
407
|
+
searchAll(params?: CompaniesSearchParams, options?: PaginationOptions): AsyncGenerator<Company, void, undefined>;
|
|
408
|
+
/** Every page of results. */
|
|
409
|
+
searchPages(params?: CompaniesSearchParams, options?: PaginationOptions): AsyncGenerator<CompaniesSearchResponse, void, undefined>;
|
|
410
|
+
/** POST /v1/companies/enrich. 1 enrichment record when found; 404 uses none. */
|
|
411
|
+
enrich(params: CompanyEnrichParams, options?: RequestOptions): Promise<CompanyEnrichResponse>;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
declare class Emails {
|
|
415
|
+
private readonly http;
|
|
416
|
+
constructor(http: HttpClient);
|
|
417
|
+
/**
|
|
418
|
+
* POST /v1/emails/verify. One email (`email`) or up to 100 (`emails`), or pass a string or
|
|
419
|
+
* an array directly. 1 enrichment record per email checked.
|
|
420
|
+
*/
|
|
421
|
+
verify(params: EmailVerifyParams | string | string[], options?: RequestOptions): Promise<EmailVerifyResponse>;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
declare class Jobs {
|
|
425
|
+
private readonly http;
|
|
426
|
+
constructor(http: HttpClient);
|
|
427
|
+
/** GET /v1/jobs/{id}: status of an async job. */
|
|
428
|
+
get(id: string, options?: RequestOptions): Promise<AsyncJob>;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
declare class People {
|
|
432
|
+
private readonly http;
|
|
433
|
+
constructor(http: HttpClient);
|
|
434
|
+
/** POST /v1/people/search. 1 search record per record returned; empty results use none. */
|
|
435
|
+
search(params?: PeopleSearchParams, options?: RequestOptions): Promise<PeopleSearchResponse>;
|
|
436
|
+
/** Every matching person, page after page. Use `maxItems` to cap what you pay for. */
|
|
437
|
+
searchAll(params?: PeopleSearchParams, options?: PaginationOptions): AsyncGenerator<Person, void, undefined>;
|
|
438
|
+
/** Every page of results (with `usage` and `lastResponse` per page). */
|
|
439
|
+
searchPages(params?: PeopleSearchParams, options?: PaginationOptions): AsyncGenerator<PeopleSearchResponse, void, undefined>;
|
|
440
|
+
/** POST /v1/people/enrich. 1 enrichment record when found (+1 for a personal email); 404 uses none. */
|
|
441
|
+
enrich(params: PersonEnrichParams, options?: RequestOptions): Promise<PersonEnrichResponse>;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
declare class Scrape {
|
|
445
|
+
private readonly http;
|
|
446
|
+
constructor(http: HttpClient);
|
|
447
|
+
/** POST /v1/scrape/company. 1 scrape unit per page read (default 1 page). Paid plans with scrape units. */
|
|
448
|
+
company(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeCompanyResponse>;
|
|
449
|
+
/** POST /v1/scrape/jobs. 1 scrape unit per page read (default up to 3). Paid plans with scrape units. */
|
|
450
|
+
jobs(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeJobsResponse>;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
declare class UsageResource {
|
|
454
|
+
private readonly http;
|
|
455
|
+
constructor(http: HttpClient);
|
|
456
|
+
/** GET /v1/usage: what's left in every meter and when each window resets. Free to call. */
|
|
457
|
+
get(options?: RequestOptions): Promise<UsageResponse>;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* The Leadsets API client.
|
|
462
|
+
*
|
|
463
|
+
* ```ts
|
|
464
|
+
* const ls = new Leadsets(process.env.LEADSETS_KEY)
|
|
465
|
+
* const res = await ls.people.search({ function: ['revenue'], country: 'US', limit: 10 })
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
declare class Leadsets {
|
|
469
|
+
readonly people: People;
|
|
470
|
+
readonly companies: Companies;
|
|
471
|
+
readonly emails: Emails;
|
|
472
|
+
readonly scrape: Scrape;
|
|
473
|
+
readonly jobs: Jobs;
|
|
474
|
+
readonly usage: UsageResource;
|
|
475
|
+
/** The base URL requests go to. */
|
|
476
|
+
readonly baseURL: string;
|
|
477
|
+
constructor(apiKey?: string | ClientOptions, options?: ClientOptions);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Error hierarchy.
|
|
482
|
+
*
|
|
483
|
+
* LeadsetsError
|
|
484
|
+
* ├── APIError the API answered with an error status
|
|
485
|
+
* │ ├── InvalidRequestError 400 invalid_request
|
|
486
|
+
* │ ├── AuthenticationError 401 unauthorized
|
|
487
|
+
* │ ├── PaymentRequiredError 402
|
|
488
|
+
* │ │ ├── FreeRecordsExhaustedError free_records_exhausted
|
|
489
|
+
* │ │ └── ScrapeUnitsExhaustedError scrape_units_exhausted
|
|
490
|
+
* │ ├── PermissionDeniedError 403 forbidden (upgradeUrl)
|
|
491
|
+
* │ ├── NotFoundError 404 not_found
|
|
492
|
+
* │ ├── IdempotencyConflictError 409 idempotency_conflict
|
|
493
|
+
* │ ├── RateLimitError 429 window_full, weekly_limit, too_many_concurrent
|
|
494
|
+
* │ └── InternalServerError 5xx internal_error
|
|
495
|
+
* │ └── ServiceUnavailableError 503 unavailable
|
|
496
|
+
* └── APIConnectionError the request never got an answer
|
|
497
|
+
* └── APITimeoutError ...because it timed out
|
|
498
|
+
*/
|
|
499
|
+
interface ErrorBody {
|
|
500
|
+
type?: string;
|
|
501
|
+
message?: string;
|
|
502
|
+
param?: string;
|
|
503
|
+
meter?: string;
|
|
504
|
+
resets_at?: string;
|
|
505
|
+
upgrade_url?: string;
|
|
506
|
+
charged?: number;
|
|
507
|
+
[key: string]: unknown;
|
|
508
|
+
}
|
|
509
|
+
declare class LeadsetsError extends Error {
|
|
510
|
+
/** The request_id of the failed call, when the API returned one. */
|
|
511
|
+
readonly requestId: string | null;
|
|
512
|
+
constructor(message: string, requestId?: string | null, options?: {
|
|
513
|
+
cause?: unknown;
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
interface APIErrorInit {
|
|
517
|
+
status: number;
|
|
518
|
+
error: ErrorBody | undefined;
|
|
519
|
+
requestId: string | null;
|
|
520
|
+
headers: Headers;
|
|
521
|
+
body: unknown;
|
|
522
|
+
}
|
|
523
|
+
declare class APIError extends LeadsetsError {
|
|
524
|
+
/** HTTP status. */
|
|
525
|
+
readonly status: number;
|
|
526
|
+
/** Machine-readable `error.type`, e.g. "window_full". */
|
|
527
|
+
readonly type: string | null;
|
|
528
|
+
/** The field a 400 refers to. */
|
|
529
|
+
readonly param: string | null;
|
|
530
|
+
/** The meter that ran out, e.g. "search_records_5h". */
|
|
531
|
+
readonly meter: string | null;
|
|
532
|
+
/** When the meter's window frees up (ISO 8601). */
|
|
533
|
+
readonly resetsAt: string | null;
|
|
534
|
+
/** Seconds to wait, from the `Retry-After` header. */
|
|
535
|
+
readonly retryAfter: number | null;
|
|
536
|
+
/** Always 0: errors never count records. */
|
|
537
|
+
readonly charged: number | null;
|
|
538
|
+
/** The `error` object of the response. */
|
|
539
|
+
readonly error: ErrorBody | undefined;
|
|
540
|
+
readonly headers: Headers;
|
|
541
|
+
/** The full parsed response body. */
|
|
542
|
+
readonly body: unknown;
|
|
543
|
+
constructor(init: APIErrorInit);
|
|
544
|
+
/** Builds the most specific error class for a response. */
|
|
545
|
+
static from(init: APIErrorInit): APIError;
|
|
546
|
+
}
|
|
547
|
+
declare class InvalidRequestError extends APIError {
|
|
548
|
+
}
|
|
549
|
+
declare class AuthenticationError extends APIError {
|
|
550
|
+
}
|
|
551
|
+
declare class PaymentRequiredError extends APIError {
|
|
552
|
+
}
|
|
553
|
+
declare class FreeRecordsExhaustedError extends PaymentRequiredError {
|
|
554
|
+
}
|
|
555
|
+
declare class ScrapeUnitsExhaustedError extends PaymentRequiredError {
|
|
556
|
+
}
|
|
557
|
+
declare class PermissionDeniedError extends APIError {
|
|
558
|
+
/** Where to upgrade, when a plan change would allow the call. */
|
|
559
|
+
readonly upgradeUrl: string | null;
|
|
560
|
+
constructor(init: APIErrorInit);
|
|
561
|
+
}
|
|
562
|
+
declare class NotFoundError extends APIError {
|
|
563
|
+
}
|
|
564
|
+
declare class IdempotencyConflictError extends APIError {
|
|
565
|
+
}
|
|
566
|
+
declare class RateLimitError extends APIError {
|
|
567
|
+
}
|
|
568
|
+
declare class InternalServerError extends APIError {
|
|
569
|
+
}
|
|
570
|
+
declare class ServiceUnavailableError extends InternalServerError {
|
|
571
|
+
}
|
|
572
|
+
declare class APIConnectionError extends LeadsetsError {
|
|
573
|
+
constructor(message?: string, options?: {
|
|
574
|
+
cause?: unknown;
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
declare class APITimeoutError extends APIConnectionError {
|
|
578
|
+
constructor(message?: string, options?: {
|
|
579
|
+
cause?: unknown;
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** `Retry-After` as seconds: a number of seconds or an HTTP date. */
|
|
584
|
+
declare function parseRetryAfter(v: string | null, now?: number): number | null;
|
|
585
|
+
|
|
586
|
+
declare const VERSION = "0.1.0";
|
|
587
|
+
|
|
588
|
+
export { APIConnectionError, APIError, type APIErrorInit, type APIResponse, APITimeoutError, type AsyncJob, AuthenticationError, type ClientOptions, type CompaniesSearchParams, type CompaniesSearchResponse, type Company, type CompanyEnrichParams, type CompanyEnrichResponse, APIConnectionError as ConnectionError, DEFAULT_BASE_URL, type Email, type EmailStatus, type EmailVerification, type EmailVerifyParams, type EmailVerifyResponse, type EmailVerifySummary, type ErrorBody, type FieldSource, type FreeMeters, FreeRecordsExhaustedError, IdempotencyConflictError, InternalServerError, InvalidRequestError, type Job, Leadsets, LeadsetsError, type Location, type Meter, NotFoundError, type OneOrMany, type PaginationOptions, PaymentRequiredError, type PeopleSearchParams, type PeopleSearchResponse, PermissionDeniedError, type Person, type PersonCompany, type PersonEnrichParams, type PersonEnrichResponse, type PersonFunction, type Plan, RateLimitError, type RateLimitInfo, type RequestOptions, type ResponseMeta, type ScrapeCompanyResponse, type ScrapeJobsResponse, type ScrapeParams, ScrapeUnitsExhaustedError, type ScrapedPage, type Seniority, ServiceUnavailableError, APITimeoutError as TimeoutError, type Unavailable, type Usage, type UsageResponse, VERSION, type VerificationStatus, type WindowMeters, parseRetryAfter };
|