BjLocationData is an open JavaScript library providing departments, towns, districts, and neighborhoods for Benin Republic. Drop a ready-made hierarchical selector into any web page — no backend, no API keys, no dependencies.
# location_data_bj
> Benin Republic administrative location data for JavaScript/TypeScript web and Node.js applications.
Covers the full four-level administrative hierarchy — **departments → towns → districts → neighborhoods** — with lookup, relational query, search, and an optional drop-in UI widget.
**Related packages**
| Platform | Package |
|---|---|
| Dart / Flutter | location_data_bj on pub.dev |
| Raw data | bj_location_data_raw on GitHub |
---
## Table of Contents
- Data Snapshot
- Demo
- Installation
- Quick Start
- API Reference
- List All
- Lookup by Code
- Relational Queries
- Search
- Widget
- TypeScript Types
- Contributing
- Acknowledgments
- Disclaimer
- License
---
## Data Snapshot
> Last updated: 2023-12-21
| Level | Count |
|---|---|
| Departments | 12 |
| Towns | 77 |
| Districts | 546 |
| Neighborhoods | 5 303 |
> **Note:** The `code` field in each record is an auto-generated identifier. See bj_location_data_raw for the raw source and generation details.
---
## Demo
Live demo:
dahkenangnon.github.io
---
## Installation
```bash
# npm
npm install location_data_bj
# yarn
yarn add location_data_bj
# pnpm
pnpm add location_data_bj
```
**Browser — CDN**
```html
```
**Browser — local bundle**
Download the latest release from GitHub Releases, then:
```html
```
---
## Quick Start
```ts
import {
departmentList,
townsOfDepartment,
searchNeighborhoods,
} from 'location_data_bj';
// List all departments, sorted A → Z (default)
const departments = departmentList();
// Get every town in a specific department
const towns = townsOfDepartment('DEP-01');
// Search neighborhoods by name
const results = searchNeighborhoods('Zongo');
```
---
## API Reference
All functions that return collections accept an optional `sortBy` parameter (`'asc'` | `'desc'`, default `'asc'`) that sorts results alphabetically by `name`.
### List All
| Function | Returns | Description |
|---|---|---|
| `departmentList(sor …