1 | |
2 | type TheirStack = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Search Jobs |
7 | * This endpoint lets you search for jobs posted on thousands of websites and filter by multiple filters, such as job titles, companies, locations, company attributes, dates and many more. |
8 | */ |
9 | export async function main( |
10 | auth: TheirStack, |
11 | format: 'json' | 'csv' | undefined, |
12 | body: { |
13 | order_by?: { |
14 | desc?: false | true |
15 | field?: 'date_posted' | 'discovered_at' | 'salary' | 'job_title' | 'company' | 'num_jobs' |
16 | }[] |
17 | offset?: number |
18 | page?: number |
19 | limit?: number |
20 | job_title_or?: string[] |
21 | job_title_not?: string[] |
22 | job_title_pattern_and?: string[] |
23 | job_title_pattern_or?: string[] |
24 | job_title_pattern_not?: string[] |
25 | job_country_code_or?: string[] |
26 | job_country_code_not?: string[] |
27 | posted_at_max_age_days?: number |
28 | posted_at_gte?: string |
29 | posted_at_lte?: string |
30 | discovered_at_max_age_days?: number |
31 | discovered_at_min_age_days?: number |
32 | discovered_at_gte?: string |
33 | discovered_at_lte?: string |
34 | job_description_pattern_or?: string[] |
35 | job_description_pattern_not?: string[] |
36 | job_description_pattern_is_case_insensitive?: false | true |
37 | remote?: false | true |
38 | only_jobs_with_reports_to?: false | true |
39 | reports_to_exists?: false | true |
40 | final_url_exists?: false | true |
41 | only_jobs_with_hiring_managers?: false | true |
42 | hiring_managers_exists?: false | true |
43 | job_id_or?: number[] |
44 | job_id_not?: number[] |
45 | job_ids?: number[] |
46 | job_seniority_or?: 'c_level' | 'staff' | 'senior' | 'junior' | 'mid_level'[] |
47 | min_salary_usd?: number |
48 | max_salary_usd?: number |
49 | job_technology_slug_or?: string[] |
50 | job_technology_slug_not?: string[] |
51 | job_technology_slug_and?: string[] |
52 | job_location_pattern_or?: string[] |
53 | job_location_pattern_not?: string[] |
54 | scraper_name_pattern_or?: string[] |
55 | easy_apply?: false | true |
56 | company_name_or?: string[] |
57 | company_name_case_insensitive_or?: string[] |
58 | company_id_or?: string[] |
59 | company_domain_or?: string[] |
60 | company_domain_not?: string[] |
61 | company_name_not?: string[] |
62 | company_name_partial_match_or?: string[] |
63 | company_name_partial_match_not?: string[] |
64 | company_linkedin_url_or?: string[] |
65 | company_description_pattern_or?: string[] |
66 | company_description_pattern_not?: string[] |
67 | company_description_pattern_accent_insensitive?: false | true |
68 | min_revenue_usd?: number |
69 | max_revenue_usd?: number |
70 | min_employee_count?: number |
71 | max_employee_count?: number |
72 | min_employee_count_or_null?: number |
73 | max_employee_count_or_null?: number |
74 | min_funding_usd?: number |
75 | max_funding_usd?: number |
76 | funding_stage_or?: string[] |
77 | industry_or?: string[] |
78 | industry_not?: string[] |
79 | industry_id_or?: number[] |
80 | industry_id_not?: number[] |
81 | company_tags_or?: string[] |
82 | company_type?: 'recruiting_agency' | 'direct_employer' | 'all' |
83 | company_investors_or?: string[] |
84 | company_investors_partial_match_or?: string[] |
85 | company_technology_slug_or?: string[] |
86 | company_technology_slug_and?: string[] |
87 | company_technology_slug_not?: string[] |
88 | only_yc_companies?: false | true |
89 | company_location_pattern_or?: string[] |
90 | company_country_code_or?: string[] |
91 | company_country_code_not?: string[] |
92 | company_list_id_or?: number[] |
93 | company_list_id_not?: number[] |
94 | company_linkedin_url_exists?: false | true |
95 | revealed_company_data?: false | true |
96 | last_funding_round_date_lte?: string |
97 | last_funding_round_date_gte?: string |
98 | include_total_results?: false | true |
99 | blur_company_data?: false | true |
100 | } |
101 | ) { |
102 | const url = new URL(`https://api.theirstack.com/v1/jobs/search`) |
103 | for (const [k, v] of [['format', format]]) { |
104 | if (v !== undefined && v !== '' && k !== undefined) { |
105 | url.searchParams.append(k, v) |
106 | } |
107 | } |
108 | const response = await fetch(url, { |
109 | method: 'POST', |
110 | headers: { |
111 | 'Content-Type': 'application/json', |
112 | Authorization: 'Bearer ' + auth.apiKey |
113 | }, |
114 | body: JSON.stringify(body) |
115 | }) |
116 | if (!response.ok) { |
117 | const text = await response.text() |
118 | throw new Error(`${response.status} ${text}`) |
119 | } |
120 | return await response.json() |
121 | } |
122 |
|