1 | |
2 | type TheirStack = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Search Companies |
7 | * This endpoint lets you search for companies filtering them by company attributes, technology attributes, and jobs attributes. |
8 | */ |
9 | export async function main( |
10 | auth: TheirStack, |
11 | format: 'json' | 'csv' | undefined, |
12 | body: { |
13 | expand_technology_slugs?: string[] |
14 | order_by?: { |
15 | desc?: false | true |
16 | field: |
17 | | 'name' |
18 | | 'num_jobs' |
19 | | 'num_jobs_last_30_days' |
20 | | 'num_jobs_found' |
21 | | 'employee_count' |
22 | | 'alexa_ranking' |
23 | | 'founded_year' |
24 | | 'annual_revenue_usd' |
25 | | 'total_funding_usd' |
26 | | 'last_funding_round_date' |
27 | | 'confidence' |
28 | | 'jobs' |
29 | | 'first_date_found' |
30 | }[] |
31 | offset?: number |
32 | page?: number |
33 | limit?: number |
34 | company_description_pattern_or?: string[] |
35 | company_description_pattern_not?: string[] |
36 | company_description_pattern_accent_insensitive?: false | true |
37 | min_revenue_usd?: number |
38 | max_revenue_usd?: number |
39 | min_employee_count?: number |
40 | max_employee_count?: number |
41 | min_employee_count_or_null?: number |
42 | max_employee_count_or_null?: number |
43 | min_funding_usd?: number |
44 | max_funding_usd?: number |
45 | funding_stage_or?: string[] |
46 | industry_or?: string[] |
47 | industry_not?: string[] |
48 | industry_id_or?: number[] |
49 | industry_id_not?: number[] |
50 | company_tags_or?: string[] |
51 | company_type?: 'recruiting_agency' | 'direct_employer' | 'all' |
52 | company_investors_or?: string[] |
53 | company_investors_partial_match_or?: string[] |
54 | company_technology_slug_or?: string[] |
55 | company_technology_slug_and?: string[] |
56 | company_technology_slug_not?: string[] |
57 | only_yc_companies?: false | true |
58 | company_location_pattern_or?: string[] |
59 | company_country_code_or?: string[] |
60 | company_country_code_not?: string[] |
61 | company_list_id_or?: number[] |
62 | company_list_id_not?: number[] |
63 | company_linkedin_url_exists?: false | true |
64 | revealed_company_data?: false | true |
65 | last_funding_round_date_lte?: string |
66 | last_funding_round_date_gte?: string |
67 | company_name_or?: string[] |
68 | company_name_case_insensitive_or?: string[] |
69 | company_id_or?: string[] |
70 | company_domain_or?: string[] |
71 | company_domain_not?: string[] |
72 | company_name_not?: string[] |
73 | company_name_partial_match_or?: string[] |
74 | company_name_partial_match_not?: string[] |
75 | company_linkedin_url_or?: string[] |
76 | include_total_results?: false | true |
77 | blur_company_data?: false | true |
78 | job_filters?: { |
79 | job_title_or?: string[] |
80 | job_title_not?: string[] |
81 | job_title_pattern_and?: string[] |
82 | job_title_pattern_or?: string[] |
83 | job_title_pattern_not?: string[] |
84 | job_country_code_or?: string[] |
85 | job_country_code_not?: string[] |
86 | posted_at_max_age_days?: number |
87 | posted_at_gte?: string |
88 | posted_at_lte?: string |
89 | discovered_at_max_age_days?: number |
90 | discovered_at_min_age_days?: number |
91 | discovered_at_gte?: string |
92 | discovered_at_lte?: string |
93 | job_description_pattern_or?: string[] |
94 | job_description_pattern_not?: string[] |
95 | job_description_pattern_is_case_insensitive?: false | true |
96 | remote?: false | true |
97 | only_jobs_with_reports_to?: false | true |
98 | reports_to_exists?: false | true |
99 | final_url_exists?: false | true |
100 | only_jobs_with_hiring_managers?: false | true |
101 | hiring_managers_exists?: false | true |
102 | job_id_or?: number[] |
103 | job_id_not?: number[] |
104 | job_ids?: number[] |
105 | job_seniority_or?: 'c_level' | 'staff' | 'senior' | 'junior' | 'mid_level'[] |
106 | min_salary_usd?: number |
107 | max_salary_usd?: number |
108 | job_technology_slug_or?: string[] |
109 | job_technology_slug_not?: string[] |
110 | job_technology_slug_and?: string[] |
111 | job_location_pattern_or?: string[] |
112 | job_location_pattern_not?: string[] |
113 | scraper_name_pattern_or?: string[] |
114 | easy_apply?: false | true |
115 | } |
116 | tech_filters?: { |
117 | technology_slug_or?: string[] |
118 | technology_category_slug_or?: string[] |
119 | technology_parent_category_slug_or?: string[] |
120 | max_rank?: number |
121 | min_jobs?: number |
122 | max_jobs?: number |
123 | min_relative_occurrence?: number |
124 | first_date_found_gte?: string |
125 | first_date_found_lte?: string |
126 | last_date_found_gte?: string |
127 | last_date_found_lte?: string |
128 | confidence_or?: 'low' | 'medium' | 'high'[] |
129 | } |
130 | } |
131 | ) { |
132 | const url = new URL(`https://api.theirstack.com/v1/companies/search`) |
133 | for (const [k, v] of [['format', format]]) { |
134 | if (v !== undefined && v !== '' && k !== undefined) { |
135 | url.searchParams.append(k, v) |
136 | } |
137 | } |
138 | const response = await fetch(url, { |
139 | method: 'POST', |
140 | headers: { |
141 | 'Content-Type': 'application/json', |
142 | Authorization: 'Bearer ' + auth.apiKey |
143 | }, |
144 | body: JSON.stringify(body) |
145 | }) |
146 | if (!response.ok) { |
147 | const text = await response.text() |
148 | throw new Error(`${response.status} ${text}`) |
149 | } |
150 | return await response.json() |
151 | } |
152 |
|