Skip to content
Shivam Mathur edited this page Sep 15, 2016 · 3 revisions

Country City API

Build Status Code Climate Coverage Status codecov License

Country City API is a REST API to get a list of all the countries in the world. It can also be used to get a list of all the cities in a country.

Installing the API

  • Before installing this API you need to install MongoDB pecl extension by following installation instructions from here

  • Download this API using composer by executing the command below.

composer global require shivammathur/countrycity "master-dev"
  • Then install the API using by executing the command below.
composer create-project shivammathur/countrycity countrycity "master-dev" --prefer-dist
  • Download and install MongoDB from here
  • Start MongoDB server by executing the below command.
mongod --dbpath {countrycityapipath}/data/db
  • Restore the data into the MongoDB Database by using the below command in a new terminal.
mongorestore {countrycityapipath}/data/db/dump/countrycity/geo.bson
  • You are all set.

API Endpoints

Get All Countries

/get/countries/

Get All Cities in a Country

/get/cities/{countryName}

Error Format

{"error":"true", "message": "error message here"}
Clone this wiki locally