@fiberai/sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +969 -0
- package/dist/index.cjs +1606 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +50778 -0
- package/dist/index.d.ts +50778 -0
- package/dist/index.js +1496 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
# @fiberai/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript SDK for the [Fiber AI](https://fiber.ai) API - Enterprise B2B data intelligence platform.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fiberai/sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Quick Start](#quick-start)
|
|
12
|
+
- [Authentication](#authentication)
|
|
13
|
+
- [Core Features](#core-features)
|
|
14
|
+
- [Company & People Search](#company--people-search)
|
|
15
|
+
- [Contact Enrichment](#contact-enrichment)
|
|
16
|
+
- [LinkedIn Live Enrichment](#linkedin-live-enrichment)
|
|
17
|
+
- [Saved Searches (Audiences)](#saved-searches-audiences)
|
|
18
|
+
- [Exclusion Lists](#exclusion-lists)
|
|
19
|
+
- [Google Maps Search](#google-maps-search)
|
|
20
|
+
- [AI-Powered Research](#ai-powered-research)
|
|
21
|
+
- [Advanced Usage](#advanced-usage)
|
|
22
|
+
- [Error Handling](#error-handling)
|
|
23
|
+
- [TypeScript Support](#typescript-support)
|
|
24
|
+
- [Rate Limits & Credits](#rate-limits--credits)
|
|
25
|
+
- [Support](#support)
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @fiberai/sdk
|
|
31
|
+
# or
|
|
32
|
+
yarn add @fiberai/sdk
|
|
33
|
+
# or
|
|
34
|
+
pnpm add @fiberai/sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Requirements:** Node.js 18.0.0 or higher
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { peopleSearch, companySearch, getOrgCredits } from '@fiberai/sdk';
|
|
43
|
+
|
|
44
|
+
// Check your organization's credit balance
|
|
45
|
+
const credits = await getOrgCredits({
|
|
46
|
+
query: { apiKey: 'your-api-key' }
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
console.log(`Available credits: ${credits.data.output.available}`);
|
|
50
|
+
|
|
51
|
+
// Search for companies
|
|
52
|
+
const companies = await companySearch({
|
|
53
|
+
body: {
|
|
54
|
+
apiKey: 'your-api-key',
|
|
55
|
+
searchParams: {
|
|
56
|
+
industriesV2: {
|
|
57
|
+
anyOf: ['Software', 'Information Technology']
|
|
58
|
+
},
|
|
59
|
+
employeeCountV2: {
|
|
60
|
+
lowerBoundExclusive: 100,
|
|
61
|
+
upperBoundInclusive: 1000
|
|
62
|
+
},
|
|
63
|
+
headquartersCountryCode: {
|
|
64
|
+
anyOf: ['USA']
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
pageSize: 25
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Search for people
|
|
72
|
+
const people = await peopleSearch({
|
|
73
|
+
body: {
|
|
74
|
+
apiKey: 'your-api-key',
|
|
75
|
+
searchParams: {
|
|
76
|
+
title: ['CEO', 'CTO', 'VP Engineering'],
|
|
77
|
+
location: {
|
|
78
|
+
cities: ['San Francisco, CA']
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
pageSize: 25
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Authentication
|
|
87
|
+
|
|
88
|
+
All API requests require an API key. Get yours at [fiber.ai/app/api](https://fiber.ai/app/api).
|
|
89
|
+
|
|
90
|
+
**Include your API key in every request:**
|
|
91
|
+
|
|
92
|
+
- **POST requests**: Pass `apiKey` in the request body
|
|
93
|
+
- **GET requests**: Pass `apiKey` as a query parameter
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// POST request example
|
|
97
|
+
await companySearch({
|
|
98
|
+
body: {
|
|
99
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
100
|
+
searchParams: { /* ... */ }
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// GET request example
|
|
105
|
+
await getOrgCredits({
|
|
106
|
+
query: { apiKey: process.env.FIBERAI_API_KEY }
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Best Practice:** Store your API key in environment variables:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# .env
|
|
114
|
+
FIBERAI_API_KEY=your_api_key_here
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Core Features
|
|
118
|
+
|
|
119
|
+
### Company & People Search
|
|
120
|
+
|
|
121
|
+
#### Company Search
|
|
122
|
+
|
|
123
|
+
Search for companies using 40+ filters including industry, location, revenue, funding, and more.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { companySearch, companyCount } from '@fiberai/sdk';
|
|
127
|
+
|
|
128
|
+
// Advanced company search
|
|
129
|
+
const result = await companySearch({
|
|
130
|
+
body: {
|
|
131
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
132
|
+
searchParams: {
|
|
133
|
+
// Industry filters
|
|
134
|
+
industriesV2: {
|
|
135
|
+
anyOf: ['Software', 'Cloud']
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
// Size filters
|
|
139
|
+
employeeCountV2: {
|
|
140
|
+
lowerBoundExclusive: 50,
|
|
141
|
+
upperBoundInclusive: 500
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
// Location filters
|
|
145
|
+
headquartersCountryCode: {
|
|
146
|
+
anyOf: ['USA']
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
// Funding filters
|
|
150
|
+
totalFundingUSD: {
|
|
151
|
+
lowerBound: 1000000
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
// Keywords filter
|
|
155
|
+
keywords: {
|
|
156
|
+
containsAny: ['venture-backed-startup']
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
pageSize: 50,
|
|
160
|
+
cursor: null // For pagination
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
console.log(`Found ${result.data.output.data.items.length} companies`);
|
|
165
|
+
|
|
166
|
+
// Get total count before searching
|
|
167
|
+
const count = await companyCount({
|
|
168
|
+
body: {
|
|
169
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
170
|
+
searchParams: { /* same filters */ }
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
console.log(`Total companies matching: ${count.data.output.count}`);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### People Search
|
|
178
|
+
|
|
179
|
+
Find decision-makers and key contacts with precise targeting.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { peopleSearch, peopleSearchCount } from '@fiberai/sdk';
|
|
183
|
+
|
|
184
|
+
const people = await peopleSearch({
|
|
185
|
+
body: {
|
|
186
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
187
|
+
searchParams: {
|
|
188
|
+
// Job title filters
|
|
189
|
+
title: ['CEO', 'Chief Executive Officer', 'Founder'],
|
|
190
|
+
|
|
191
|
+
// Seniority and function
|
|
192
|
+
seniority: ['Executive'],
|
|
193
|
+
jobFunction: ['Entrepreneurship'],
|
|
194
|
+
|
|
195
|
+
// Location filters
|
|
196
|
+
location: {
|
|
197
|
+
cities: ['San Francisco, CA', 'New York, NY'],
|
|
198
|
+
countries: ['USA']
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
// Company filters (search within specific companies)
|
|
202
|
+
currentCompany: {
|
|
203
|
+
domains: ['example.com'],
|
|
204
|
+
linkedinUrls: ['https://linkedin.com/company/example']
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// Tags and special filters
|
|
208
|
+
tags: ['decision-maker', 'c-suite'],
|
|
209
|
+
|
|
210
|
+
// Education filters
|
|
211
|
+
schools: ['Stanford University', 'Harvard University']
|
|
212
|
+
},
|
|
213
|
+
pageSize: 100,
|
|
214
|
+
getDetailedWorkExperience: true,
|
|
215
|
+
getDetailedEducation: true
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Access profile data
|
|
220
|
+
people.data.output.data.items.forEach(profile => {
|
|
221
|
+
console.log(`${profile.name} - ${profile.headline}`);
|
|
222
|
+
console.log(`LinkedIn: ${profile.url}`);
|
|
223
|
+
if (profile.currentJob) {
|
|
224
|
+
console.log(`Current: ${profile.currentJob.title} at ${profile.currentJob.company_name}`);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### Combined Search (Companies + People)
|
|
230
|
+
|
|
231
|
+
Search for companies and their employees in one workflow.
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
import { combinedSearch, pollCombinedSearch } from '@fiberai/sdk';
|
|
235
|
+
|
|
236
|
+
// Start async search
|
|
237
|
+
const searchTask = await combinedSearch({
|
|
238
|
+
body: {
|
|
239
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
240
|
+
companySearchParams: {
|
|
241
|
+
industriesV2: {
|
|
242
|
+
anyOf: ['Software']
|
|
243
|
+
},
|
|
244
|
+
employeeCountV2: {
|
|
245
|
+
lowerBoundExclusive: 100
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
personSearchParams: {
|
|
249
|
+
title: ['VP of Sales', 'Sales Director'],
|
|
250
|
+
seniority: ['Director', 'Executive']
|
|
251
|
+
},
|
|
252
|
+
maxCompanies: 100,
|
|
253
|
+
maxProspects: 500
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const searchId = searchTask.data.output.searchId;
|
|
258
|
+
|
|
259
|
+
// Poll for companies
|
|
260
|
+
let companyCursor = null;
|
|
261
|
+
do {
|
|
262
|
+
const companies = await pollCombinedSearch({
|
|
263
|
+
body: {
|
|
264
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
265
|
+
searchId,
|
|
266
|
+
entityType: 'company',
|
|
267
|
+
cursor: companyCursor,
|
|
268
|
+
pageSize: 25
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Process companies
|
|
273
|
+
companies.data.output.data.items.forEach(company => {
|
|
274
|
+
console.log(company.preferred_name);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
companyCursor = companies.data.output.nextCursor;
|
|
278
|
+
} while (companyCursor);
|
|
279
|
+
|
|
280
|
+
// Poll for prospects
|
|
281
|
+
let prospectCursor = null;
|
|
282
|
+
do {
|
|
283
|
+
const prospects = await pollCombinedSearch({
|
|
284
|
+
body: {
|
|
285
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
286
|
+
searchId,
|
|
287
|
+
entityType: 'profile',
|
|
288
|
+
cursor: prospectCursor,
|
|
289
|
+
pageSize: 100
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Process profiles
|
|
294
|
+
prospects.data.output.data.items.forEach(profile => {
|
|
295
|
+
console.log(`${profile.name} - ${profile.headline}`);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
prospectCursor = prospects.data.output.nextCursor;
|
|
299
|
+
} while (prospectCursor);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Contact Enrichment
|
|
303
|
+
|
|
304
|
+
Get emails and phone numbers for LinkedIn profiles.
|
|
305
|
+
|
|
306
|
+
#### Single Contact Enrichment (Async)
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import { triggerContactEnrichment, pollContactEnrichmentResult } from '@fiberai/sdk';
|
|
310
|
+
|
|
311
|
+
// Start enrichment
|
|
312
|
+
const task = await triggerContactEnrichment({
|
|
313
|
+
body: {
|
|
314
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
315
|
+
linkedinUrl: 'https://www.linkedin.com/in/example',
|
|
316
|
+
dataToFetch: {
|
|
317
|
+
workEmail: true,
|
|
318
|
+
personalEmail: true,
|
|
319
|
+
phoneNumber: true
|
|
320
|
+
},
|
|
321
|
+
liveFetch: false // Set to true for real-time LinkedIn scraping (+1 credit)
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// Poll for results
|
|
326
|
+
let done = false;
|
|
327
|
+
while (!done) {
|
|
328
|
+
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
|
|
329
|
+
|
|
330
|
+
const result = await pollContactEnrichmentResult({
|
|
331
|
+
body: {
|
|
332
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
333
|
+
taskId: task.data.output.taskId
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
done = result.data.output.done;
|
|
338
|
+
|
|
339
|
+
if (done) {
|
|
340
|
+
const profile = result.data.output.profile;
|
|
341
|
+
console.log('Emails:', profile.emails);
|
|
342
|
+
console.log('Phone numbers:', profile.phoneNumbers);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
#### Single Contact Enrichment (Sync)
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
import { syncContactEnrichment } from '@fiberai/sdk';
|
|
351
|
+
|
|
352
|
+
// Synchronous enrichment (waits for completion)
|
|
353
|
+
const result = await syncContactEnrichment({
|
|
354
|
+
body: {
|
|
355
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
356
|
+
linkedinUrl: 'https://www.linkedin.com/in/example',
|
|
357
|
+
dataToFetch: {
|
|
358
|
+
workEmail: true,
|
|
359
|
+
personalEmail: false,
|
|
360
|
+
phoneNumber: false
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
console.log('Work emails:', result.data.output.profile.emails);
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
#### Batch Contact Enrichment
|
|
369
|
+
|
|
370
|
+
Enrich up to 10,000 contacts in one request.
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
import { startBatchContactEnrichment, pollBatchContactEnrichment } from '@fiberai/sdk';
|
|
374
|
+
|
|
375
|
+
// Start batch enrichment
|
|
376
|
+
const batch = await startBatchContactEnrichment({
|
|
377
|
+
body: {
|
|
378
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
379
|
+
people: [
|
|
380
|
+
{ linkedinUrl: { value: 'https://linkedin.com/in/person1' } },
|
|
381
|
+
{ linkedinUrl: { value: 'https://linkedin.com/in/person2' } },
|
|
382
|
+
// ... up to 10,000 people
|
|
383
|
+
],
|
|
384
|
+
dataToFetch: {
|
|
385
|
+
workEmail: true,
|
|
386
|
+
personalEmail: true,
|
|
387
|
+
phoneNumber: true
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// Poll for results with pagination
|
|
393
|
+
let cursor = null;
|
|
394
|
+
let allDone = false;
|
|
395
|
+
|
|
396
|
+
while (!allDone) {
|
|
397
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
398
|
+
|
|
399
|
+
const results = await pollBatchContactEnrichment({
|
|
400
|
+
body: {
|
|
401
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
402
|
+
taskId: batch.data.output.taskId,
|
|
403
|
+
cursor,
|
|
404
|
+
take: 100
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
allDone = results.data.output.done;
|
|
409
|
+
cursor = results.data.output.nextCursor;
|
|
410
|
+
|
|
411
|
+
// Process page results
|
|
412
|
+
results.data.output.pageResults.forEach(person => {
|
|
413
|
+
if (person.outputs) {
|
|
414
|
+
console.log('LinkedIn:', person.inputs.linkedinUrl.value);
|
|
415
|
+
console.log('Emails:', person.outputs.emails);
|
|
416
|
+
console.log('Phones:', person.outputs.phoneNumbers);
|
|
417
|
+
console.log('---');
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### LinkedIn Live Enrichment
|
|
424
|
+
|
|
425
|
+
Get real-time data from LinkedIn with live scraping.
|
|
426
|
+
|
|
427
|
+
#### Live Profile Enrichment
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
import { profileLiveEnrich } from '@fiberai/sdk';
|
|
431
|
+
|
|
432
|
+
const profile = await profileLiveEnrich({
|
|
433
|
+
body: {
|
|
434
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
435
|
+
linkedinUrl: 'https://www.linkedin.com/in/example'
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
console.log(profile.data.output.name);
|
|
440
|
+
console.log(profile.data.output.summary);
|
|
441
|
+
console.log(profile.data.output.experiences);
|
|
442
|
+
console.log(profile.data.output.education);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
#### Live Company Enrichment
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
import { companyLiveEnrich } from '@fiberai/sdk';
|
|
449
|
+
|
|
450
|
+
const company = await companyLiveEnrich({
|
|
451
|
+
body: {
|
|
452
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
453
|
+
linkedinUrl: 'https://www.linkedin.com/company/example'
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
console.log(company.data.output.preferred_name);
|
|
458
|
+
console.log(company.data.output.li_description);
|
|
459
|
+
console.log(company.data.output.li_follower_count);
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
#### Fetch LinkedIn Posts
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
import { profilePostsLiveFetch, companyPostsLiveFetch } from '@fiberai/sdk';
|
|
466
|
+
|
|
467
|
+
// Get profile posts
|
|
468
|
+
const profilePosts = await profilePostsLiveFetch({
|
|
469
|
+
body: {
|
|
470
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
471
|
+
linkedinUrl: 'https://www.linkedin.com/in/example',
|
|
472
|
+
cursor: null // For pagination
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// Get company posts
|
|
477
|
+
const companyPosts = await companyPostsLiveFetch({
|
|
478
|
+
body: {
|
|
479
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
480
|
+
linkedinUrl: 'https://www.linkedin.com/company/example',
|
|
481
|
+
cursor: null
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Saved Searches (Audiences)
|
|
487
|
+
|
|
488
|
+
Create, manage, and run saved searches with automatic updates.
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
import {
|
|
492
|
+
createSavedSearch,
|
|
493
|
+
listSavedSearch,
|
|
494
|
+
manuallySpawnSavedSearchRun,
|
|
495
|
+
getSavedSearchRunStatus,
|
|
496
|
+
getSavedSearchRunCompanies,
|
|
497
|
+
getSavedSearchRunProfiles
|
|
498
|
+
} from '@fiberai/sdk';
|
|
499
|
+
|
|
500
|
+
// Create a saved search
|
|
501
|
+
const savedSearch = await createSavedSearch({
|
|
502
|
+
body: {
|
|
503
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
504
|
+
name: 'Tech Executives in SF',
|
|
505
|
+
searchParams: {
|
|
506
|
+
companySearchParams: {
|
|
507
|
+
industriesV2: {
|
|
508
|
+
anyOf: ['Software']
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
personSearchParams: {
|
|
512
|
+
title: ['CEO', 'CTO'],
|
|
513
|
+
seniority: ['Executive']
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// List all saved searches
|
|
520
|
+
const searches = await listSavedSearch({
|
|
521
|
+
body: {
|
|
522
|
+
apiKey: process.env.FIBERAI_API_KEY
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
// Manually run a saved search
|
|
527
|
+
const run = await manuallySpawnSavedSearchRun({
|
|
528
|
+
body: {
|
|
529
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
530
|
+
savedSearchId: savedSearch.data.output.savedSearchId
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// Check run status
|
|
535
|
+
const status = await getSavedSearchRunStatus({
|
|
536
|
+
body: {
|
|
537
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
538
|
+
runId: run.data.output.runId
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// Get companies from run
|
|
543
|
+
const companies = await getSavedSearchRunCompanies({
|
|
544
|
+
body: {
|
|
545
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
546
|
+
runId: run.data.output.runId,
|
|
547
|
+
pageSize: 100
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// Get profiles from run
|
|
552
|
+
const profiles = await getSavedSearchRunProfiles({
|
|
553
|
+
body: {
|
|
554
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
555
|
+
runId: run.data.output.runId,
|
|
556
|
+
pageSize: 100
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Exclusion Lists
|
|
562
|
+
|
|
563
|
+
Manage exclusion lists to filter out companies or prospects from searches.
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
import {
|
|
567
|
+
createCompanyExclusionList,
|
|
568
|
+
addCompaniesToExclusionList,
|
|
569
|
+
getExcludedCompaniesForExclusionList,
|
|
570
|
+
createCompanyExclusionListFromAudience
|
|
571
|
+
} from '@fiberai/sdk';
|
|
572
|
+
|
|
573
|
+
// Create an exclusion list
|
|
574
|
+
const list = await createCompanyExclusionList({
|
|
575
|
+
body: {
|
|
576
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
577
|
+
name: 'Competitors',
|
|
578
|
+
isOrganizationWide: true
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// Add companies to the list
|
|
583
|
+
await addCompaniesToExclusionList({
|
|
584
|
+
body: {
|
|
585
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
586
|
+
listId: list.data.output.listId,
|
|
587
|
+
companies: [
|
|
588
|
+
{ domain: 'competitor1.com', linkedinUrl: null },
|
|
589
|
+
{ domain: 'competitor2.com', linkedinUrl: null }
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// Create exclusion list from an existing audience
|
|
595
|
+
const audienceList = await createCompanyExclusionListFromAudience({
|
|
596
|
+
body: {
|
|
597
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
598
|
+
audienceId: 'audience-123',
|
|
599
|
+
name: 'Existing Customers',
|
|
600
|
+
isOrganizationWide: true
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
// View excluded companies
|
|
605
|
+
const excluded = await getExcludedCompaniesForExclusionList({
|
|
606
|
+
body: {
|
|
607
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
608
|
+
exclusionListId: list.data.output.listId,
|
|
609
|
+
pageSize: 100
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### Google Maps Search
|
|
615
|
+
|
|
616
|
+
Search for local businesses on Google Maps.
|
|
617
|
+
|
|
618
|
+
```typescript
|
|
619
|
+
import {
|
|
620
|
+
googleMapsSearch,
|
|
621
|
+
checkGoogleMapsResults,
|
|
622
|
+
pollGoogleMapsResults
|
|
623
|
+
} from '@fiberai/sdk';
|
|
624
|
+
|
|
625
|
+
// Start Google Maps search
|
|
626
|
+
const search = await googleMapsSearch({
|
|
627
|
+
body: {
|
|
628
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
629
|
+
query: 'coffee shops',
|
|
630
|
+
location: 'San Francisco, CA',
|
|
631
|
+
maxResults: 100
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
// Check search progress
|
|
636
|
+
const progress = await checkGoogleMapsResults({
|
|
637
|
+
body: {
|
|
638
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
639
|
+
searchID: search.data.output.projectID
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
console.log(`Progress: ${progress.data.output.percentageCompleted}%`);
|
|
644
|
+
|
|
645
|
+
// Poll for results when complete
|
|
646
|
+
if (progress.data.output.status === 'COMPLETED') {
|
|
647
|
+
const results = await pollGoogleMapsResults({
|
|
648
|
+
body: {
|
|
649
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
650
|
+
projectID: search.data.output.projectID,
|
|
651
|
+
pageSize: 50
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
results.data.output.results.forEach(place => {
|
|
656
|
+
console.log(`${place.name} - ${place.address}`);
|
|
657
|
+
console.log(`Rating: ${place.rating}, Reviews: ${place.numReviews}`);
|
|
658
|
+
console.log(`Website: ${place.website}`);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### AI-Powered Research
|
|
664
|
+
|
|
665
|
+
Use AI agents for intelligent company research and domain lookup.
|
|
666
|
+
|
|
667
|
+
```typescript
|
|
668
|
+
import { domainLookupTrigger, domainLookupPolling } from '@fiberai/sdk';
|
|
669
|
+
|
|
670
|
+
// Trigger domain lookup for company names
|
|
671
|
+
const lookup = await domainLookupTrigger({
|
|
672
|
+
body: {
|
|
673
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
674
|
+
companyNames: [
|
|
675
|
+
'OpenAI',
|
|
676
|
+
'Anthropic',
|
|
677
|
+
'Stripe'
|
|
678
|
+
]
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
// Poll for results
|
|
683
|
+
let lookupDone = false;
|
|
684
|
+
while (!lookupDone) {
|
|
685
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
686
|
+
|
|
687
|
+
const results = await domainLookupPolling({
|
|
688
|
+
body: {
|
|
689
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
690
|
+
domainAgentRunId: lookup.data.output.domainAgentRunId,
|
|
691
|
+
pageSize: 10
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
lookupDone = results.data.output.status === 'DONE';
|
|
696
|
+
|
|
697
|
+
if (lookupDone) {
|
|
698
|
+
results.data.output.data.forEach(company => {
|
|
699
|
+
console.log(`${company.companyName}: ${company.bestDomain}`);
|
|
700
|
+
console.log(`Confidence: ${company.confidence}/10`);
|
|
701
|
+
console.log(`Rationale: ${company.rationale}`);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
## Advanced Usage
|
|
708
|
+
|
|
709
|
+
### Custom Client Configuration
|
|
710
|
+
|
|
711
|
+
```typescript
|
|
712
|
+
import { createClient } from '@fiberai/sdk';
|
|
713
|
+
|
|
714
|
+
// Create a custom client
|
|
715
|
+
const customClient = createClient({
|
|
716
|
+
baseUrl: 'https://api.fiber.ai', // Production URL
|
|
717
|
+
// Add custom headers, interceptors, etc.
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// Use with any SDK function
|
|
721
|
+
import { companySearch } from '@fiberai/sdk';
|
|
722
|
+
|
|
723
|
+
const result = await companySearch({
|
|
724
|
+
client: customClient,
|
|
725
|
+
body: { /* ... */ }
|
|
726
|
+
});
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
### Pagination Helper
|
|
730
|
+
|
|
731
|
+
```typescript
|
|
732
|
+
async function* paginateSearch(searchFn, params) {
|
|
733
|
+
let cursor = null;
|
|
734
|
+
|
|
735
|
+
do {
|
|
736
|
+
const result = await searchFn({
|
|
737
|
+
...params,
|
|
738
|
+
body: {
|
|
739
|
+
...params.body,
|
|
740
|
+
cursor
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
yield result.data.output.data.items;
|
|
745
|
+
cursor = result.data.output.nextCursor;
|
|
746
|
+
} while (cursor);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// Usage
|
|
750
|
+
for await (const companies of paginateSearch(companySearch, {
|
|
751
|
+
body: {
|
|
752
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
753
|
+
searchParams: { /* ... */ },
|
|
754
|
+
pageSize: 100
|
|
755
|
+
}
|
|
756
|
+
})) {
|
|
757
|
+
console.log(`Processing batch of ${companies.length} companies`);
|
|
758
|
+
// Process batch
|
|
759
|
+
}
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### Utility Endpoints
|
|
763
|
+
|
|
764
|
+
```typescript
|
|
765
|
+
import {
|
|
766
|
+
getRegions,
|
|
767
|
+
getLanguages,
|
|
768
|
+
getTimeZones,
|
|
769
|
+
getIndustries,
|
|
770
|
+
getTags,
|
|
771
|
+
getNaicsCodes,
|
|
772
|
+
getAccelerators
|
|
773
|
+
} from '@fiberai/sdk';
|
|
774
|
+
|
|
775
|
+
// Get available regions for filtering
|
|
776
|
+
const regions = await getRegions({
|
|
777
|
+
query: { apiKey: process.env.FIBERAI_API_KEY }
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
// Get available industries
|
|
781
|
+
const industries = await getIndustries({
|
|
782
|
+
query: { apiKey: process.env.FIBERAI_API_KEY }
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
// Get profile and company tags
|
|
786
|
+
const tags = await getTags({
|
|
787
|
+
query: { apiKey: process.env.FIBERAI_API_KEY }
|
|
788
|
+
});
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
## Error Handling
|
|
792
|
+
|
|
793
|
+
### Standard Error Handling
|
|
794
|
+
|
|
795
|
+
```typescript
|
|
796
|
+
import { companySearch } from '@fiberai/sdk';
|
|
797
|
+
|
|
798
|
+
const result = await companySearch({
|
|
799
|
+
body: {
|
|
800
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
801
|
+
searchParams: { /* ... */ }
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
if (result.error) {
|
|
806
|
+
console.error('API Error:', result.error);
|
|
807
|
+
// Handle specific error codes
|
|
808
|
+
if (result.error.message.includes('401')) {
|
|
809
|
+
console.error('Invalid API key');
|
|
810
|
+
} else if (result.error.message.includes('402')) {
|
|
811
|
+
console.error('Insufficient credits');
|
|
812
|
+
} else if (result.error.message.includes('429')) {
|
|
813
|
+
console.error('Rate limit exceeded');
|
|
814
|
+
}
|
|
815
|
+
} else {
|
|
816
|
+
console.log('Success:', result.data);
|
|
817
|
+
}
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
### Throwing on Errors
|
|
821
|
+
|
|
822
|
+
```typescript
|
|
823
|
+
try {
|
|
824
|
+
const result = await companySearch<true>({
|
|
825
|
+
body: {
|
|
826
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
827
|
+
searchParams: { /* ... */ }
|
|
828
|
+
},
|
|
829
|
+
throwOnError: true
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
// result.data is guaranteed to exist
|
|
833
|
+
console.log(result.data.output);
|
|
834
|
+
} catch (error) {
|
|
835
|
+
console.error('Request failed:', error);
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
### Common HTTP Error Codes
|
|
840
|
+
|
|
841
|
+
| Code | Meaning | Solution |
|
|
842
|
+
|------|---------|----------|
|
|
843
|
+
| 400 | Bad Request | Check your request parameters |
|
|
844
|
+
| 401 | Unauthorized | Verify your API key is valid |
|
|
845
|
+
| 402 | Payment Required | Insufficient credits - top up your account |
|
|
846
|
+
| 403 | Forbidden | You don't have access to this resource |
|
|
847
|
+
| 404 | Not Found | Resource doesn't exist |
|
|
848
|
+
| 429 | Too Many Requests | Rate limit exceeded - slow down requests |
|
|
849
|
+
| 500 | Internal Server Error | Contact support |
|
|
850
|
+
|
|
851
|
+
## TypeScript Support
|
|
852
|
+
|
|
853
|
+
All SDK methods are fully typed with TypeScript.
|
|
854
|
+
|
|
855
|
+
```typescript
|
|
856
|
+
import type {
|
|
857
|
+
CompanySearchData,
|
|
858
|
+
CompanySearchResponse,
|
|
859
|
+
PeopleSearchData,
|
|
860
|
+
PeopleSearchResponse,
|
|
861
|
+
TriggerContactEnrichmentData,
|
|
862
|
+
PollContactEnrichmentResultResponse
|
|
863
|
+
} from '@fiberai/sdk';
|
|
864
|
+
|
|
865
|
+
// Type-safe request
|
|
866
|
+
const searchParams: CompanySearchData = {
|
|
867
|
+
body: {
|
|
868
|
+
apiKey: process.env.FIBERAI_API_KEY!,
|
|
869
|
+
searchParams: {
|
|
870
|
+
industriesV2: {
|
|
871
|
+
anyOf: ['Software']
|
|
872
|
+
},
|
|
873
|
+
employeeCountV2: {
|
|
874
|
+
lowerBoundExclusive: 100,
|
|
875
|
+
upperBoundInclusive: 1000
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
pageSize: 25
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
const result: CompanySearchResponse = await companySearch(searchParams);
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
### Runtime Validation
|
|
886
|
+
|
|
887
|
+
The SDK includes Zod schemas for runtime validation. Zod is included automatically with the SDK installation.
|
|
888
|
+
|
|
889
|
+
```typescript
|
|
890
|
+
import { z } from 'zod';
|
|
891
|
+
import { zCompanySearchData } from '@fiberai/sdk/dist/generated/zod.gen';
|
|
892
|
+
|
|
893
|
+
const requestData = {
|
|
894
|
+
body: {
|
|
895
|
+
apiKey: process.env.FIBERAI_API_KEY,
|
|
896
|
+
searchParams: { /* ... */ }
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
// Validate at runtime
|
|
901
|
+
const validatedData = zCompanySearchData.parse(requestData);
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
## Rate Limits & Credits
|
|
905
|
+
|
|
906
|
+
### Rate Limits
|
|
907
|
+
|
|
908
|
+
Each endpoint has its own rate limit. Common limits:
|
|
909
|
+
|
|
910
|
+
- **Company/People Search**: 180 requests/minute
|
|
911
|
+
- **Contact Enrichment**: 120 requests/minute (single), 10 requests/minute (batch)
|
|
912
|
+
- **Live Enrichment**: 60 requests/minute
|
|
913
|
+
- **Utility Endpoints**: 10-50 requests/minute
|
|
914
|
+
|
|
915
|
+
### Credit Costs
|
|
916
|
+
|
|
917
|
+
**Default pricing** (may vary - check your organization settings):
|
|
918
|
+
|
|
919
|
+
| Operation | Cost (credits) |
|
|
920
|
+
|-----------|----------------|
|
|
921
|
+
| Company search | 1 per company found |
|
|
922
|
+
| People search | 1 per profile found |
|
|
923
|
+
| Combined search | 1 per company + 1 per profile |
|
|
924
|
+
| Work email reveal | 2 |
|
|
925
|
+
| Personal email reveal | 2 |
|
|
926
|
+
| Phone number reveal | 3 |
|
|
927
|
+
| All contact data | 5 |
|
|
928
|
+
| Live profile enrichment | 2 |
|
|
929
|
+
| Live company enrichment | 2 |
|
|
930
|
+
| LinkedIn posts (per page) | 2 |
|
|
931
|
+
| Google Maps search | 3 per result |
|
|
932
|
+
|
|
933
|
+
### Free Endpoints
|
|
934
|
+
|
|
935
|
+
The following endpoints are **completely free** (no credits charged):
|
|
936
|
+
|
|
937
|
+
- `getOrgCredits` - Check credit balance
|
|
938
|
+
- `getRegions`, `getLanguages`, `getTimeZones`, `getIndustries`, `getTags`, `getNaicsCodes`, `getAccelerators` - Utility endpoints
|
|
939
|
+
- All exclusion list management endpoints
|
|
940
|
+
|
|
941
|
+
### Check Your Credits
|
|
942
|
+
|
|
943
|
+
```typescript
|
|
944
|
+
import { getOrgCredits } from '@fiberai/sdk';
|
|
945
|
+
|
|
946
|
+
const credits = await getOrgCredits({
|
|
947
|
+
query: { apiKey: process.env.FIBERAI_API_KEY }
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
console.log(`Available: ${credits.data.output.available}`);
|
|
951
|
+
console.log(`Used: ${credits.data.output.used}`);
|
|
952
|
+
console.log(`Max: ${credits.data.output.max}`);
|
|
953
|
+
console.log(`Resets on: ${credits.data.output.usagePeriodResetsOn}`);
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
## Support
|
|
957
|
+
|
|
958
|
+
- **Documentation**: [alpha.api.fiber.ai/docs](https://alpha.api.fiber.ai/docs)
|
|
959
|
+
- **Email**: team@fiber.ai
|
|
960
|
+
- **Website**: [fiber.ai](https://fiber.ai)
|
|
961
|
+
- **Get API Key**: [fiber.ai/app/api](https://fiber.ai/app/api)
|
|
962
|
+
|
|
963
|
+
## License
|
|
964
|
+
|
|
965
|
+
MIT
|
|
966
|
+
|
|
967
|
+
---
|
|
968
|
+
|
|
969
|
+
Made with ❤️ by [Fiber AI](https://fiber.ai)
|