List all States belongs to Country
Use this endpoint to effortlessly retrieve a comprehensive list of states, providing essential data such as unique identifiers and states names.
Required Parameter
-
ciso2
- string
-
Country iso2 string to retrive a country.
Optional query param
-
isPaginate
- boolean
-
Return you the paginated result
-
limit
- integer
-
Limit the countries returned
-
page
- integer
-
Return the contents of that page after pagination
Request
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => '/countries/IN/states',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => ['X-API-KEY' => 'your-api-key'],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
$data = json_decode($response);
}
const axios = require("axios");
const options = {
method: 'GET',
url: '/countries/IN/states',
headers: {
'X-API-KEY': 'your-api-key'
},
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("/countries/IN/states"),
Headers =
{
{ "X-API-KEY", "your-api-key" }
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("/countries/IN/states")
.addHeader("X-API-KEY", "your-api-key")
.build();
Response response = client.newCall(request).execute();
Retrive a State
Retrieve detailed information about a state using its ISO2 code. This endpoint is useful for obtaining specific state data based on the ISO2 standard.
Required parameter
-
ciso2
- string
-
Country iso2 string.
-
siso2
- string
-
State iso2 string.
Request
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => '/countries/IN/states/MP',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => ['X-API-KEY' => 'your-api-key'],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
$data = json_decode($response);
}
const axios = require("axios");
const options = {
method: 'GET',
url: '/countries/IN/states/MP',
headers: {
'X-API-KEY': 'your-api-key'
},
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("/countries/IN/states/MP"),
Headers =
{
{ "X-API-KEY", "your-api-key" }
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("/countries/IN/states/MP")
.addHeader("X-API-KEY", "your-api-key")
.build();
Response response = client.newCall(request).execute();
Autocomplete country
This endpoint allows you to get all the states which is like the name you provide, it is useful for the searching of the state in your application.
Required parameter
-
stateName
- string
-
Any State iso2, iso3, full name can search the country.
Optional query param
-
isPaginate
- boolean
-
Return you the paginated result
-
limit
- integer
-
Limit the countries returned
-
page
- integer
-
Return the contents of that page after pagination
Request
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => '/countries/IN/states/autoComplete',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => ['X-API-KEY' => 'your-api-key'],
CURLOPT_POSTFIELDS => "stateName='your-search-string'"
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
$data = json_decode($response);
}
const axios = require("axios");
const encodedParams = new URLSearchParams();
encodedParams.append("stateName", "your-search-string");
const options = {
method: 'POST',
url: '/countries/IN/states/autoComplete',
headers: {
'X-API-KEY': 'your-api-key'
},
data: encodedParams
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("/countries/IN/states/autoComplete"),
Headers =
{
{ "X-API-KEY", "your-api-key" }
},
Content = new FormUrlEncodedContent(new Dictionary
{
{"stateName", "your-search-string"}
}),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("stateName", "your-search-string")
.build();
Request request = new Request.Builder()
.url("/countries/IN/states/autoComplete")
.post(body)
.addHeader("X-API-KEY", "your-api-key")
.build();
Response response = client.newCall(request).execute();