2017 © Pedro Peláez
 

library countrycity

API to get all countries and all cities in a country.

image

shivammathur/countrycity

API to get all countries and all cities in a country.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 3 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Country City API

Build Status Code Climate codecov License, (*1)

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., (*2)

, (*3)

:zap: Installing the CountryCity API

  • Make sure you have PHP 7.4 or newer.
$ php -v
  • Download this API using composer using the command below.
composer global require shivammathur/countrycity "dev-main"
  • Then install the API by executing the command below.
composer create-project shivammathur/countrycity countrycity "dev-main" --prefer-dist
  • You are all set, you can use this API.

:hash: API Endpoints

All API responses are in json format., (*4)

  • Get all countries
/countries

# Without URL Rewriting
/index.php/countries
  • Get all countries containing a search keyword
/countries/{search_keyword}

# Without URL Rewriting
/index.php/countries/{search_keyword}
  • Get all cities in a country
/cities/{country}

# Without URL Rewriting
/index.php/cities/{country}
  • Get all cities in a country containing a search keyword
/cities/{country}/{search_keyword}

# Without URL Rewriting
/index.php/cities/{country}/{search_keyword}

:sparkles: Rest API Features

  • Built using Slim micro framework.
  • Caching enabled with following headers
    • ETag
    • Expires
    • Last-Modified
  • Fast and lightweight API
  • PSR 7 Complaint
  • CORS Middleware

:cloud: Hosting configuration

Here are the Configuration Instructions if you want to host this on your server., (*5)

:wrench: Error Format

If there is an error in the API, you will get an error in json format as response, (*6)

{"error":"true", "message": "error message here"}

:rotating_light: Testing

$ vendor/bin/phpunit --configuration phpunit.xml.dist

:scroll: License

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., (*7)

:+1: Contributions

Contributions are welcome! See Contributor's Guide., (*8)

:sparkling_heart: Support this project

  • Please star the project and share it with the community.
  • Support the project by sponsoring my work on GitHub sponsors.

The Versions

04/09 2016

dev-master

9999999-dev http://github.com/shivammathur

API to get all countries and all cities in a country.

  Sources   Download

MIT

The Requires

 

The Development Requires

php rest geolocation psr7 router countries cities

04/09 2016

dev-develop

dev-develop http://github.com/shivammathur

API to get all countries and all cities in a country.

  Sources   Download

MIT

The Requires

 

The Development Requires

php rest geolocation psr7 router countries cities