# Code Deb Nepal Geo SDK

**Target version:** `@codedeb/nepal-geo@0.2.0` — implemented source candidate; **not yet verified on npm**. The earlier `0.1.0` was independently verified but does **not** include the 753-local-level bundle.

Offline bilingual Nepal administrative hierarchy: **7 provinces, 77 districts and 753 local levels** (6 metropolitan, 11 sub-metropolitan, 276 municipalities, 460 rural municipalities). Name records contain English and Devanagari text and validated parent district/province references.

## End-to-end integration procedure

1. Choose a province using `provinces`, then list the 77 districts filtered by `provinceId`.
2. Use `listNepalLocalLevels({provinceId,districtId})` or `searchNepalGeo(query)` to select one of 753 local levels.
3. Collect the ward number and street. A structural number is **not** confirmation that the ward exists; use an externally verified per-municipality ward cap.
4. Validate and canonicalize with `normalizeNepalAddress`. Persist the stable Code Deb IDs, locale-independent ward number and your own source revision.
5. Keep official code mapping, boundaries, ward shapefiles and delivery zones in separately verified, versioned adapters.

## Quickstart — TypeScript

```ts
import {
  provinces,districts,localLevels,
  listNepalLocalLevels,searchNepalGeo,
  normalizeNepalAddress,formatCanonicalNepalAddress,
} from '@codedeb/nepal-geo';

console.log(provinces.length,districts.length,localLevels.length); // 7, 77, 753
const locations=listNepalLocalLevels({provinceId:'P4'});
const matches=searchNepalGeo('पोखरा');
const address=normalizeNepalAddress({
  province:'Gandaki',district:'Kaski',municipality:'Pokhara',
  ward:'८',street:'Lakeside',
});
if (address.valid && address.value) {
  console.log(formatCanonicalNepalAddress(address.value,'ne'));
} else {
  console.error(address.issues);
}
```

## API reference

| Export | Purpose |
| --- | --- |
| `provinces / districts / localLevels` | Immutable bilingual 7/77/753 data. |
| `searchNepalGeo(query,index?,filters?)` | Bilingual relevance-ordered search; defaults to bundled levels. |
| `listNepalLocalLevels(filters)` | Filter by province, district and local-level type. |
| `nepalGeoHierarchy(provinceId)` | Get one province, its districts and municipalities. |
| `createGeoIndex(spec)` | Validate a separately versioned, attributed municipality dataset. |
| `normalizeNepalAddress(input,options?)` | Strict parent relationship, ward and canonical ID checks. |
| `formatCanonicalNepalAddress(value,locale)` | Format validated English/Devanagari street and ward address. |
| `formatNepalAddress` | Format legacy caller-provided address strings. |

## Source provenance and update history

- **2026-11-25:** Imported [Abin Rimal's MIT Nepal Administrative Divisions JSON](https://github.com/abinrimal/nepal-administrative-divisions-json). Preserved license notice and source/update history in `packages/sdk-nepal-geo/SOURCE_LICENSE_MIT.txt` and `DATA_PROVENANCE.md`.
- **Government cross-reference:** [Nepal National Statistics Office](https://ec.nsonepal.gov.np/html/admin_code.html) lists 7 provinces, 77 districts and 753 local levels. The SDK does **not** claim each spellings field was individually government-certified.
- **2026-11:** Existing 7-province/77-district Code Deb snapshot; custom municipality import only.
- Upstream local-level `code` repeats within districts. This SDK therefore generates its **own unique internal IDs**, not government identifiers. Do not use those IDs as CBS/NSO codes.
- Ward inventories, polygons, coordinates, postal codes and municipal boundaries are **not included**. Never infer them from the hierarchy.

## Production readiness tests

Run `npm run test:nepal-sdks`, `npm run sdk:build` and `npm run sdk:pack:verify` in the repo. Use the attributed dataset's migration/reconciliation process for changes or splits. Verify local names and ward counts against appropriate current government sources for regulated workflows.

## Install and verify

```bash
npm view @codedeb/nepal-geo@0.2.0 version
# Install only after the exact version is verified
npm install @codedeb/nepal-geo@0.2.0
```

The exact `0.2.0` candidate is **not claimed to be published**. Source package remains private until the guarded npm release; the previously confirmed `0.1.0` contains only provinces/districts.

## Troubleshooting

**Cannot find a place:** search the Nepali spelling or filter by parent district; check source snapshot spelling. **Wrong ward:** supply authoritative `wardMaximumByMunicipality`. **npm 404:** stage and review the candidate, then publish only through the trusted release workflow. **Unknown government ID:** internal identifiers intentionally differ from official codes.

## Licensing

The candidate Code Deb-authored SDK code is intended for Apache-2.0 staging; the embedded third-party local-level data remains MIT with its preserved copyright notice. Consult the eventual npm tarball for actual grants and third-party notices.

[SDK directory](/docs/sdk) · [Tax SDK](/docs/sdk/nepal-tax) · [Developer resources](/docs/resources)
