Nigeria GeoData is an npm package that provides easy-to-use functions to retrieve Nigerian states, their local government areas (LGAs), and cities/areas within those LGAs. This package is ideal for developers building applications that require geographic data of Nigeria, such as dropdown selectors, data validation, or any location-based feature.
# Nigeria GeoData
Nigeria GeoData is an npm package that provides easy-to-use functions to retrieve Nigerian states, their local government areas (LGAs), and cities/areas within those LGAs. This package is ideal for developers building applications that require geographic data of Nigeria, such as dropdown selectors, data validation, or any location-based feature.
## Installation
Install the package using npm:
```bash
npm install nigeria-geodata
Or using Yarn:
yarn add nigeria-geodata
```
### Usage
Import the functions in your TypeScript or JavaScript project:
```TypeScript Example
import { getAllStates, getLocalGovernments, getCities } from 'nigeria-geodata';
//Get all Nigerian states (alphabetically sorted)
const states = getAllStates();
console.log('States:', states);
// Get Local Government Areas for a specific state (case insensitive)
const stateName = 'Abia';
const lgas = getLocalGovernments(stateName);
console.log(`Local Governments in ${stateName}:`, lgas);
// Get Cities/Areas for a specific LGA within a state (case insensitive)
const localGovernment = 'Aba North';
const cities = getCities(stateName, localGovernment);
console.log(`Cities/Areas in ${localGovernment}, ${stateName}:`, cities);
```
``` JavaScript Example
const { getAllStates, getLocalGovernments, getCities } = require('nigeria-geodata');
// Get all Nigerian states
const states = getAllStates();
console.log('States:', states);
// Get LGAs for a specific state
const stateName = 'Abia';
const lgas = getLocalGovernments(stateName);
console.log(`Local Governments in ${stateName}:`, lgas);
// Get Cities/Areas for a specific LGA in the state
const localGovernment = 'Aba North';
const cities = getCities(stateName, localGovernment);
console.log(`Cities/Areas in ${localGovernment}, ${stateName}:`, cities);
```
### API Reference
**getAllStates()**
Returns: string[]
Description:
Extracts and returns a sorted array of all unique Nigerian state names from the data.
**stateName: The name of …