0

List mobile network operators

by
Published Apr 8, 2025

Telnyx has a set of GSM mobile operators partners that are available through our mobile network roaming. This resource is entirely managed by Telnyx and may change over time. That means that this resource won't allow any write operations for it. Still, it's available so it can be used as a support resource that can be related to other resources or become a configuration option.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * List mobile network operators
7
 * Telnyx has a set of GSM mobile operators partners that are available through our mobile network roaming. This resource is entirely managed by Telnyx and may change over time. That means that this resource won't allow any write operations for it. Still, it's available so it can be used as a support resource that can be related to other resources or become a configuration option.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	page_number_: string | undefined,
12
	page_size_: string | undefined,
13
	filter_name__starts_with_: string | undefined,
14
	filter_name__contains_: string | undefined,
15
	filter_name__ends_with_: string | undefined,
16
	filter_country_code_: string | undefined,
17
	filter_mcc_: string | undefined,
18
	filter_mnc_: string | undefined,
19
	filter_tadig_: string | undefined,
20
	filter_network_preferences_enabled_: string | undefined
21
) {
22
	const url = new URL(`https://api.telnyx.com/v2/mobile_network_operators`)
23
	for (const [k, v] of [
24
		['page[number]', page_number_],
25
		['page[size]', page_size_],
26
		['filter[name][starts_with]', filter_name__starts_with_],
27
		['filter[name][contains]', filter_name__contains_],
28
		['filter[name][ends_with]', filter_name__ends_with_],
29
		['filter[country_code]', filter_country_code_],
30
		['filter[mcc]', filter_mcc_],
31
		['filter[mnc]', filter_mnc_],
32
		['filter[tadig]', filter_tadig_],
33
		['filter[network_preferences_enabled]', filter_network_preferences_enabled_]
34
	]) {
35
		if (v !== undefined && v !== '' && k !== undefined) {
36
			url.searchParams.append(k, v)
37
		}
38
	}
39
	const response = await fetch(url, {
40
		method: 'GET',
41
		headers: {
42
			Authorization: 'Bearer ' + auth.apiKey
43
		},
44
		body: undefined
45
	})
46
	if (!response.ok) {
47
		const text = await response.text()
48
		throw new Error(`${response.status} ${text}`)
49
	}
50
	return await response.json()
51
}
52