0

Get Jobs And Companies Per Job Country Code

by
Published Oct 17, 2025

This endpoint will return all the country codes and the number of jobs whose location's country code is the given one, and the number of companies with jobs in that country. Calls to this endpoint don't cost you credits.

Script their_stack Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type TheirStack = {
3
	apiKey: string
4
}
5
/**
6
 * Get Jobs And Companies Per Job Country Code
7
 * This endpoint will return all the country codes and the number of jobs whose location's country code is the given one, and the number of companies with jobs in that country.
8
    
9
Calls to this endpoint don't cost you credits.
10
 */
11
export async function main(
12
	auth: TheirStack,
13
	country: string | undefined,
14
	page: string | undefined,
15
	limit: string | undefined
16
) {
17
	const url = new URL(`https://api.theirstack.com/v0/catalog/jobs_companies_per_job_country_code`)
18
	for (const [k, v] of [
19
		['country', country],
20
		['page', page],
21
		['limit', limit]
22
	]) {
23
		if (v !== undefined && v !== '' && k !== undefined) {
24
			url.searchParams.append(k, v)
25
		}
26
	}
27
	const response = await fetch(url, {
28
		method: 'GET',
29
		headers: {
30
			Authorization: 'Bearer ' + auth.apiKey
31
		},
32
		body: undefined
33
	})
34
	if (!response.ok) {
35
		const text = await response.text()
36
		throw new Error(`${response.status} ${text}`)
37
	}
38
	return await response.json()
39
}
40