API - Countries, States, Cities¶
List Countries & States¶
URL: /api/countries-states/
Method: GET
Code sample:¶
$api_id = 1;
$api_key = 'testpass';
$hostname = 'https://example.com'; // no trailing slash
# fetch data
$url = '/api/countries-states/';
$post_data = array();
$extra_headers = array(
'X-API-ID: ' . $api_id,
'X-API-Hash: ' . md5($api_key . $url. http_build_query($post_data))
);
header('Content-Type: application/json; charset=utf-8');
echo sendRequest($hostname . $url, $post_data, $extra_headers);
Succes message:
{ has_error: false, messages: [ ], results: { countries: {}, states: [] } }
List Cities for a State¶
URL: /api/cities/?state=9
Method: GET
Code sample:¶
...
$url = '/api/cities/?state=9';
...
Succes message:
{ has_error: false, messages: [ ], results: [ { id: "13818", name: "Sector 1", distance: "0" }, { id: "13819", name: "Sector 2", distance: "0" }, { id: "13820", name: "Sector 3", distance: "0" }, { id: "13821", name: "Sector 4", distance: "0" }, { id: "13822", name: "Sector 5", distance: "0" }, { id: "13823", name: "Sector 6", distance: "0" } ] }
Go to top