This is an Locale Application built using Node.js Nest framework, which provides geographical, specifically for regions, states and local governments but includes several other metadatas.
This API uses a database of location data and a caching mechanism for better performance. You will need an API key for authorization. The API endpoints and functionality can be found below.
$ npm install
$ npm run start:dev
$ npm run test
- Node.js: Follow this guide to install Node.js: Node.js Installation Guide
- Nest CLI: Install it by running
npm install -g @nestjs/cli
. - MongoDB: Follow this guide to install and setup MongoDB: MongoDB Tutorial
- Redis: Follow this guide to install Redis: Redis Installation Guide
The API will be accessible at http://localhost:3000/
or https://locale-api.onrender.com/api
.
- Route: auth/signup
- Method: POST
- Body:
{
"username": "John Does",
"email": "john@gmail.com",
"password": "password23",
}
- Responses
Success
{
"api_key" : " generated key"
"message": "Key can only be generated once and refreshes after an hour: save key"
}
- Response statusCodes
- 201: success || Created
- 409: error || Conflict Error
- 400: error || Bad Request
- 500: error || Internal Server Error
Retrieve all state information.
Parameters:
page
(optional): Page number for pagination (default: 1).limit
(optional): Number of results per page (default: 10).sortField
(optional): Field to sort the results by.sortOrder
(optional): Sort order (asc
ordesc
).filter
(optional): Filter the results by state, region, or LGAs.populationGt
(optional): Filter the results by population greater than a value.populationLt
(optional): Filter the results by population less than a value.capital
(optional): Filter the results by exact match on the capital field.slogan
(optional): Filter the results by exact match on the slogan field.landmass
(optional): Filter the results by exact match on the landmass field.dialect
(optional): Filter the results by exact match on the dialect field.map
(optional): Filter the results by exact match on the map field.latitude
(optional): Filter the results by exact match on the latitude field.longitude
(optional): Filter the results by exact match on the longitude field.website
(optional): Filter the results by exact match on the website field.created_date
(optional): Filter the results by exact match on the created_date field.created_by
(optional): Filter the results by exact match on the created_by field.senatorial_districts
(optional): Filter the results by exact match on the senatorial_districts field (supports multiple values).past_governors
(optional): Filter the results by exact match on the past_governors field (supports multiple values).borders
(optional): Filter the results by exact match on the borders field (supports multiple values).known_for
(optional): Filter the results by exact match on the known_for field (supports multiple values).
Filter Samples For Postman:
- URL: http://base_url/search/all
URL: http://base_url/search/all?filter=states/regions/lgas
- URL: http://base_url/search/all?populationGt=1000000&populationLt=5000000(Don't go below the overall population minium no. 1,704,515)
- URL: http://base_url/search/all?capital=Ikeja
- URL: http://your_base_url/search/all?capital=Abuja&slogan=Unity%20and%20Faith
URL: http://base_url/search/all?past_governors=Babatunde%20Fashola&past_governors=Bola%20Tinubu(On swagger add two string items)
Or
URL: http://base_url/search/all?past_governors[]=Babatunde%20Fashola(If you want to search for just one info in the array/. Works for Postman only)
Do for other array fields e.g borders, knownfor etc
URL: http://base_url/search/all?sortField=state&sortOrder=asc
URL: http://base_url/search/all?page=1&limit=10
Response:
- Status: 200 OK
- Body: Array of state information objects.
Search for states by state name.
Parameters:
query
: The query string to search for.
Response:
- Status: 200 OK
- Body: Array of state information objects matching the search query.
Search for LGAs (Local Government Areas) by LGA name.
Parameters:
query
: The query string to search for.
Response:
- Status: 200 OK
- Body: Array of state information objects containing LGAs matching the search query.
Search for regions by region name.
Parameters:
query
: The query string to search for.
Response:
- Status: 200 OK
- Body: Array of state information objects matching the search query.
Retrieve LGAs (Local Government Areas) for a specific state.
Parameters:
state
: The state name.
Response:
- Status: 200 OK
- Body: JSON of LGAs for the specified state.
Retrieve States for a specific region.
Parameters:
region
: The region name.
Response:
- Status: 200 OK
- Body: JSON of states for the specified region.
Nest is MIT licensed.