0

Get Companies Per Company Country Code

by
Published Oct 17, 2025

This endpoint will return all country codes and the number of companies whose HQ is 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 Companies Per Company Country Code
7
 * This endpoint will return all country codes and the number of companies whose HQ is 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/companies_per_company_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