GET Get Countries
This endpoint returns a paginated list of all available countries for eSIM services.
Configure the API Endpoint
https://esim.betatel.com/api/v1/esim/countries
- Method:
GET
Set Up the Headers
| Param | Value | Description |
|---|---|---|
| Content-Type | application/json | Specifies the payload format. |
| x-api-key | {{x-api-key}} | Your unique API key for secure access. |
| x-user-id | {{x-user-id}} | Your user identifier for added security and tracking. |
Query Parameters
Info: Pagination options assist in navigating the array of countries available for eSIM services, crucial for managing global operations.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
| offset | integer | optional | 0 | Pagination offset |
| count | integer | optional | 20 | Number of items to return |
Example Response
Status Code: 200 OK
Content-Type: application/json
Example Response
{
"total": 195,
"offset": 0,
"count": 20,
"countries": [
{
"id": "US",
"name": "United States",
"iso_code": "US",
"country_code": "+1"
}
]
}
The response includes the total number of countries available, current pagination offset, number of items returned, and an array of country objects.
| Field | Type | Description |
|---|---|---|
| total | integer | Total number of countries available |
| offset | integer | Current pagination offset |
| count | integer | Number of items returned |
| countries | array | Array of country objects |
Country Object
| Field | Type | Description |
|---|---|---|
| id | string | Country identifier |
| name | string | Country name |
| iso_code | string | ISO country code |
| country_code | string | International dialing code |
Code Snippets
Note: Adapt the code snippets to fetch and display a list of countries supported, enhancing your system's geographic capabilities.
- cUrl
- Python
- Node.js
- PHP
- Java
- C#
Example - cURL
curl --location 'https://esim.betatel.com/api/v1/esim/countries?offset=0&count=20' \
--header 'Accept: application/json' \
--header 'x-api-key: {{x-api-key}}' \
--header 'x-user-id: {{x-user-id}}'
Example - Python
import http.client
conn = http.client.HTTPSConnection("esim.betatel.com")
headers = {
'Accept': 'application/json',
'x-api-key': '{{x-api-key}}',
'x-user-id': '{{x-user-id}}'
}
conn.request("GET", "/api/v1/esim/countries?offset=0&count=20", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Example - Node.js
const axios = require('axios');
axios.get('https://esim.betatel.com/api/v1/esim/countries', {
params: {
offset: 0,
count: 20
},
headers: {
'Accept': 'application/json',
'x-api-key': '{{x-api-key}}',
'x-user-id': '{{x-user-id}}'
}
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error);
});
Example - PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://esim.betatel.com/api/v1/esim/countries?offset=0&count=20',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'x-api-key: {{x-api-key}}',
'x-user-id: {{x-user-id}}'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Example - Java
HttpResponse<String> response = Unirest.get("https://esim.betatel.com/api/v1/esim/countries?offset=0&count=20")
.header("Accept", "application/json")
.header("x-api-key", "{{x-api-key}}")
.header("x-user-id", "{{x-user-id}}")
.asString();
System.out.println(response.getBody());
Example - C#
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://esim.betatel.com/api/v1/esim/countries?offset=0&count=20");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("x-api-key", "{{x-api-key}}");
request.Headers.Add("x-user-id", "{{x-user-id}}");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Error Handling
Important: Improper query parameters can result in '400' status codes. Verify input carefully.
- 400 - Bad Request - Invalid parameters
- 401 - Unauthorized - Invalid or missing API key