:earth_americas: Geodata API - Get countries, and cities to plug in drop-downs.
Geodata API to get the list of countries and cities in the world. This can be plugged in country and city picker drop-downs in forms. You can find a select2 implementation here. Code for this implementation is in example
directory.
$ php -v
composer global require shivammathur/countrycity "dev-main"
composer create-project shivammathur/countrycity countrycity "dev-main" --prefer-dist
All API responses are in json
format.
/countries
# Without URL Rewriting
/index.php/countries
/countries/{search_keyword}
# Without URL Rewriting
/index.php/countries/{search_keyword}
/cities/{country}
# Without URL Rewriting
/index.php/cities/{country}
/cities/{country}/{search_keyword}
# Without URL Rewriting
/index.php/cities/{country}/{search_keyword}
Here are the Configuration Instructions if you want to host this on your server.
If there is an error in the API, you will get an error in json
format as response
{"error":"true", "message": "error message here"}
$ vendor/bin/phpunit --configuration phpunit.xml.dist
The scripts and documentation in this project are released under the MIT License. This project has multiple dependencies and their licenses can be found in their respective repositories.
Contributions are welcome! See Contributor's Guide.