Edits history of script submission #20971 for ' Technographics (their_stack)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type TheirStack = {
    	apiKey: string
    }
    /**
     * Technographics
     * This endpoint lists all the technologies used by a company or group of companies.
     */
    export async function main(
    	auth: TheirStack,
    	format: 'json' | 'csv' | undefined,
    	body: {
    		company_name?: string
    		company_domain?: string
    		company_name_or?: string[]
    		order_by?: {
    			desc?: false | true
    			field?:
    				| 'jobs'
    				| 'jobs_last_7_days'
    				| 'jobs_last_30_days'
    				| 'jobs_last_180_days'
    				| 'last_date_found'
    				| 'first_date_found'
    				| 'relative_occurrence_within_category'
    				| 'theirstack_score'
    				| 'confidence'
    		}[]
    		offset?: number
    		page?: number
    		limit?: number
    		include_total_results?: false | true
    		technology_slug_or?: string[]
    		technology_category_slug_or?: string[]
    		technology_parent_category_slug_or?: string[]
    		max_rank?: number
    		min_jobs?: number
    		max_jobs?: number
    		min_relative_occurrence?: number
    		first_date_found_gte?: string
    		first_date_found_lte?: string
    		last_date_found_gte?: string
    		last_date_found_lte?: string
    		confidence_or?: 'low' | 'medium' | 'high'[]
    	}
    ) {
    	const url = new URL(`https://api.theirstack.com/v1/companies/technologies`)
    	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