API Collection
Koson Technology
  • COUNTRY-STATE-CITY
  • INDIA-RAILWAY-TRAIN
  • SHANGHAI METRO API
    • All Line Number
    • All Line Timetable
    • Last Line Timetable
    • Line History
    • Line Colour
    • All Station Information
    • Search Station With Line
    • Search Station With Station ID
    • Search Station With Station Name
    • Last Station Timetable
    • Estimate Arrival Time
    • Check Price
    • Check Route
  • AIRPORT-INFO
  • INDIA-HOTEL
  • HK-FERRY-ROUTE
  • FLIGHT-TRACK
  • MALAYSIA-STATES
  • SINGAPORE-BUS
Powered by GitBook
On this page
  • Usage
  • Parameter Guidelines
  • ISO2 Code
  • Demo
  • Download

COUNTRY-STATE-CITY

Country State City API Data Retrieval Script Documentation

NextINDIA-RAILWAY-TRAIN

Last updated 1 year ago

GET https://api.kosontechnology.com/country-state-city.php

Path Parameters

Name
Type
Description

country

String

To specify the desired country.

state

String

to specify the desired state within the selected country.

city

String

To specify the desired city within the selected country and state

download

-

To download the json file

This API script is designed to retrieve information from the CountryStateCity API using provided parameters. The script constructs the appropriate URL based on the parameters provided and then fetches data from the API. Please follow the instructions below to use this script effectively.

Usage

  1. Making an HTTP request via a web browser or API Platform etc. .

  2. The following parameters are accepted:

Name
Description
Format

country

To specify the desired country.

  • ISO2 Code of Country

  • 'ALL' or 'all'

state

To specify the desired state within the selected country.

  • ISO2 Code of State

  • 'ALL' or 'all'

city

To specify the desired city within the selected country and state.

  • 'ALL' or 'all'

download

To download the JSON output

  • This parameter does not require the content, Leave empty or Type anything is acceptable

  1. Depending on the parameters provided, the script will construct a URL to fetch information from the CountryStateCity API.

Parameter Guidelines

  • country Parameter:

    • If you provide a country parameter as 'all' or 'ALL', the script will retrieve information about all countries.

    • If you specify a valid country ISO2 Code as the country parameter, the script will retrieve information about that specific country.

  • state Parameter:

    • If you provide a state parameter as 'all' or 'ALL' in addition to the country parameter, the script will retrieve information about all states within the selected country.

    • If you specify a valid state ISO2 Code as the state parameter, the script will retrieve information about that specific state within the selected country.

  • city Parameter:

    • If you provide a city parameter as 'all' or 'ALL' in addition to the country and state parameters, the script will retrieve information about all cities within the selected state and country.

  • download Parameter:

ISO2 Code

Below is a sample how to find Malaysia ISO2 Code:

  1. Find Malaysia and you will see country code at the left column.

Demo

  1. Retrieve information about all countries:

  1. Retrieve information about a specific country:

  1. Retrieve information about all states:

  1. Retrieve information about all states within a specific country:

  1. Retrieve information about a specific state within a specific country:

  1. Retrieve information about all cities within a specific state and country:

  1. Retrieve information about all cities within a specific country:

Download

Add download parameter to download the output json, below is some example of it:

If you want to download the JSON output of these parameter, define the parameter with empty or any input will able you to auto download it. See the download sample at .

Refer this to find your ISO2 Code.

Onclick on the code then wikipedia with direct you to where you can find its state code.

Postman
wikipedia
ISO 3166-2:MY
here
https://api.kosontechnology.com/country-state-city.php?country=ALL
Retrieve all countries data
https://api.kosontechnology.com/country-state-city.php?country=MY
Retrieve Malaysia data
https://api.kosontechnology.com/country-state-city.php?state=ALL
Retrieve all states data
https://api.kosontechnology.com/country-state-city.php?country=MY&state=ALL
Retrieve all state data from Malaysia
https://api.kosontechnology.com/country-state-city.php?country=MY&state=01
Retrieve Johor state data from Malaysia
https://api.kosontechnology.com/country-state-city.php?city=ALL&country=MY&state=01
Retrieve all cities data from Malaysia's Johor
https://api.kosontechnology.com/country-state-city.php?city=ALL&country=MY
Retrieve all cities data from Malaysia
https://api.kosontechnology.com/country-state-city.php?country=MY&download=api.kosontechnology.com
Download Malaysia's Json File
https://api.kosontechnology.com/country-state-city.php?city=all&country=my&download=&state=01api.kosontechnology.com
Download cities Json File from Malaysia's Johor
'MY' is Malaysia's ISO2 Code
'01' is Johor's ISO2 Code