Edits history of script submission #20970 for ' Search Jobs (their_stack)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type TheirStack = {
    	apiKey: string
    }
    /**
     * Search Jobs
     * 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.
     */
    export async function main(
    	auth: TheirStack,
    	format: 'json' | 'csv' | undefined,
    	body: {
    		order_by?: {
    			desc?: false | true
    			field?: 'date_posted' | 'discovered_at' | 'salary' | 'job_title' | 'company' | 'num_jobs'
    		}[]
    		offset?: number
    		page?: number
    		limit?: number
    		job_title_or?: string[]
    		job_title_not?: string[]
    		job_title_pattern_and?: string[]
    		job_title_pattern_or?: string[]
    		job_title_pattern_not?: string[]
    		job_country_code_or?: string[]
    		job_country_code_not?: string[]
    		posted_at_max_age_days?: number
    		posted_at_gte?: string
    		posted_at_lte?: string
    		discovered_at_max_age_days?: number
    		discovered_at_min_age_days?: number
    		discovered_at_gte?: string
    		discovered_at_lte?: string
    		job_description_pattern_or?: string[]
    		job_description_pattern_not?: string[]
    		job_description_pattern_is_case_insensitive?: false | true
    		remote?: false | true
    		only_jobs_with_reports_to?: false | true
    		reports_to_exists?: false | true
    		final_url_exists?: false | true
    		only_jobs_with_hiring_managers?: false | true
    		hiring_managers_exists?: false | true
    		job_id_or?: number[]
    		job_id_not?: number[]
    		job_ids?: number[]
    		job_seniority_or?: 'c_level' | 'staff' | 'senior' | 'junior' | 'mid_level'[]
    		min_salary_usd?: number
    		max_salary_usd?: number
    		job_technology_slug_or?: string[]
    		job_technology_slug_not?: string[]
    		job_technology_slug_and?: string[]
    		job_location_pattern_or?: string[]
    		job_location_pattern_not?: string[]
    		scraper_name_pattern_or?: string[]
    		easy_apply?: false | true
    		company_name_or?: string[]
    		company_name_case_insensitive_or?: string[]
    		company_id_or?: string[]
    		company_domain_or?: string[]
    		company_domain_not?: string[]
    		company_name_not?: string[]
    		company_name_partial_match_or?: string[]
    		company_name_partial_match_not?: string[]
    		company_linkedin_url_or?: string[]
    		company_description_pattern_or?: string[]
    		company_description_pattern_not?: string[]
    		company_description_pattern_accent_insensitive?: false | true
    		min_revenue_usd?: number
    		max_revenue_usd?: number
    		min_employee_count?: number
    		max_employee_count?: number
    		min_employee_count_or_null?: number
    		max_employee_count_or_null?: number
    		min_funding_usd?: number
    		max_funding_usd?: number
    		funding_stage_or?: string[]
    		industry_or?: string[]
    		industry_not?: string[]
    		industry_id_or?: number[]
    		industry_id_not?: number[]
    		company_tags_or?: string[]
    		company_type?: 'recruiting_agency' | 'direct_employer' | 'all'
    		company_investors_or?: string[]
    		company_investors_partial_match_or?: string[]
    		company_technology_slug_or?: string[]
    		company_technology_slug_and?: string[]
    		company_technology_slug_not?: string[]
    		only_yc_companies?: false | true
    		company_location_pattern_or?: string[]
    		company_country_code_or?: string[]
    		company_country_code_not?: string[]
    		company_list_id_or?: number[]
    		company_list_id_not?: number[]
    		company_linkedin_url_exists?: false | true
    		revealed_company_data?: false | true
    		last_funding_round_date_lte?: string
    		last_funding_round_date_gte?: string
    		include_total_results?: false | true
    		blur_company_data?: false | true
    	}
    ) {
    	const url = new URL(`https://api.theirstack.com/v1/jobs/search`)
    	for (const [k, v] of [['format', format]]) {
    		if (v !== undefined && v !== '' && k !== undefined) {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago