Simple Country-API
A simple country API that manages data about countries, cities and their population counts!
Installation
Use npm to install dependancies.
npm i
In order to seed the database with info run this command in the terminal.
npm run seed
Wait untill its ready ( You will get this msg in the console prompted to you :
Seeding Finished!
Starting the server
Open the terminal and type this command
npm start
Enpoints
- Get all countries
api/countries
-Returns in the following format :
[
{
"_id": "62af0085fe6ff5df6cadb982",
"name": "Åland Islands"
},
{
"_id": "62af0085fe6ff5df6cadb98b",
"name": "Albania"
},
]
-Possible queries:
page={pageNumber} size={pageSize}
sort={asc/desc} – Sorts by country name in either ascending or deschending
- Get one country by name
api/countries/{countryName}
-Returns in the following format :
{
"_id": "62af04e266de9d1a27af78e5",
"cities": [
{
"_id": "62af04e266de9d1a27af78dc",
"name": "Bulawayo"
},
{
"_id": "62af04e266de9d1a27af78e9",
"name": "Chitungwiza"
},
[...]
],
"name": "Zimbabwe",
"__v": 4
}
-Possible queries:
*No queries
- Get all cities in a specific country by country name
api/cities/{countryName}
-Returns in the following format :
[
{
"_id": "62af04e266de9d1a27af78dc",
"populationCounts": [
{
"_id": "62af04e266de9d1a27af78e1",
"year": 1992,
"value": 621742,
"sex": "Both Sexes",
"reliabilty": "Final figure, complete",
"__v": 0
},
[...]
],
"name": "Bulawayo",
"__v": 0,
"countryId": "62af04e266de9d1a27af78e5",
"countryName": "Zimbabwe"
},
{
"_id": "62af04e266de9d1a27af78e9",
"populationCounts": [
{
"_id": "62af04e266de9d1a27af78ec",
"year": 1992,
"value": 274912,
"sex": "Both Sexes",
"reliabilty": "Final figure, complete",
"__v": 0
},
[...]
],
"name": "Chitungwiza",
"__v": 0,
"countryId": "62af04e266de9d1a27af78e5",
"countryName": "Zimbabwe"
},
]
-Possible queries:
page={pageNumber} size={pageSize}
sortName={asc/desc} – Sorts by city name in either ascending or descending
sortPop={asc/desc} – Sorts by population value in either ascending or descending
- Get specific city in a specific country by name
api/cities/{countryName}/{cityName}
-Returns in the following format :
[
{
"_id": "62af0085fe6ff5df6cadb982",
"name": "Åland Islands"
},
{
"_id": "62af0085fe6ff5df6cadb98b",
"name": "Albania"
},
]
-Possible queries:
*None