1 | |
2 | type TheirStack = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Technographics |
7 | * This endpoint lists all the technologies used by a company or group of companies. |
8 | */ |
9 | export async function main( |
10 | auth: TheirStack, |
11 | format: 'json' | 'csv' | undefined, |
12 | body: { |
13 | company_name?: string |
14 | company_domain?: string |
15 | company_name_or?: string[] |
16 | order_by?: { |
17 | desc?: false | true |
18 | field?: |
19 | | 'jobs' |
20 | | 'jobs_last_7_days' |
21 | | 'jobs_last_30_days' |
22 | | 'jobs_last_180_days' |
23 | | 'last_date_found' |
24 | | 'first_date_found' |
25 | | 'relative_occurrence_within_category' |
26 | | 'theirstack_score' |
27 | | 'confidence' |
28 | }[] |
29 | offset?: number |
30 | page?: number |
31 | limit?: number |
32 | include_total_results?: false | true |
33 | technology_slug_or?: string[] |
34 | technology_category_slug_or?: string[] |
35 | technology_parent_category_slug_or?: string[] |
36 | max_rank?: number |
37 | min_jobs?: number |
38 | max_jobs?: number |
39 | min_relative_occurrence?: number |
40 | first_date_found_gte?: string |
41 | first_date_found_lte?: string |
42 | last_date_found_gte?: string |
43 | last_date_found_lte?: string |
44 | confidence_or?: 'low' | 'medium' | 'high'[] |
45 | } |
46 | ) { |
47 | const url = new URL(`https://api.theirstack.com/v1/companies/technologies`) |
48 | for (const [k, v] of [['format', format]]) { |
49 | if (v !== undefined && v !== '' && k !== undefined) { |
50 | url.searchParams.append(k, v) |
51 | } |
52 | } |
53 | const response = await fetch(url, { |
54 | method: 'POST', |
55 | headers: { |
56 | 'Content-Type': 'application/json', |
57 | Authorization: 'Bearer ' + auth.apiKey |
58 | }, |
59 | body: JSON.stringify(body) |
60 | }) |
61 | if (!response.ok) { |
62 | const text = await response.text() |
63 | throw new Error(`${response.status} ${text}`) |
64 | } |
65 | return await response.json() |
66 | } |
67 |
|