PHPackages                             ngarak-dev/nida-parse - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ngarak-dev/nida-parse

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ngarak-dev/nida-parse
=====================

A Laravel package that attempts to reverse engineer how NIDA (National Identification Authority) numbers are generated and extract basic information from National Identification Numbers (NIN) without using the official NIDA API.

v0.1(3mo ago)02MITPHPPHP ^8.2

Since Jan 23Pushed 3mo agoCompare

[ Source](https://github.com/ngarak-dev/nida-parse)[ Packagist](https://packagist.org/packages/ngarak-dev/nida-parse)[ RSS](/packages/ngarak-dev-nida-parse/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

NIDA Parse
==========

[](#nida-parse)

A Laravel package that attempts to reverse engineer how NIDA (National Identification Authority) numbers are generated and extract basic information from National Identification Numbers (NIN) without using the official NIDA API.

This is a fork of the Python implementation: [reverse\_nida](https://github.com/Henryle-hd/reverse_nida)

⚠️ Disclaimer
-------------

[](#️-disclaimer)

This project is for educational and research purposes only. It attempts to understand the structure and patterns in NIDA numbers through reverse engineering. The accuracy of extracted information is not guaranteed, and this should not be used for official verification purposes.

🚀 Installation
--------------

[](#-installation)

### Requirements

[](#requirements)

- PHP &gt;= 8.2
- Composer
- Laravel 11.x or 12.x

### Install via Composer

[](#install-via-composer)

```
composer require ngarak-dev/nida-parse
```

### Publish Configuration and Assets

[](#publish-configuration-and-assets)

Publish the configuration file:

```
php artisan vendor:publish --tag=nida-parse-config
```

Publish the CSV location files to storage:

```
php artisan vendor:publish --tag=nida-parse-csv
```

Or publish both at once:

```
php artisan vendor:publish --provider="NidaParse\NidaParseServiceProvider"
```

📖 Usage
-------

[](#-usage)

### Using the Helper Function

[](#using-the-helper-function)

```
// The helper function is autoloaded globally
// Analyze a NIDA number (supports both dashed and compact formats)
$ninDashed = "19990504-35710-00001-28";
$ninCompact = "19990504357100000128";

// Get basic information
$info = get_basic_info($ninDashed, null, false);
print_r($info);
// Output: [
//   'BIRTHDATE' => '1999-05-04',
//   'GENDER' => 'FEMALE',
//   'REGIONCODE' => '35',
//   'REGION' => 'MOROGORO',
//   'DISTRICT' => 'MOROGORO URBAN',
//   'WARDCODE' => '35710',
//   'WARD' => 'Mazimbu',
//   'STREET' => '',
//   'PLACES' => '',
// ]

// Get full information with debug
$info = get_basic_info("19990504-35710-00001-28", null, true);
```

### Using the Service Classes Directly

[](#using-the-service-classes-directly)

```
use NidaParse\Services\NidaService;
use NidaParse\Services\LocationLookup;
use NidaParse\Services\NidaParser;

// Parse NIN
$parsed = NidaParser::parse("19990504-35710-00001-28");

// Lookup location
$lookup = new LocationLookup();
$location = $lookup->getAdministrativeHierarchy("35710");

// Get complete info using dependency injection
$service = app(NidaService::class);
$info = $service->getBasicInfo("19990504-35710-00001-28");
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use NidaParse\Services\NidaService;

class YourController extends Controller
{
    public function __construct(
        protected NidaService $nidaService
    ) {}

    public function parseNin(string $nin)
    {
        $info = $this->nidaService->getBasicInfo($nin);
        return response()->json($info);
    }
}
```

🔧 Configuration
---------------

[](#-configuration)

After publishing the configuration file, you can customize the package behavior in `config/nida-parse.php`:

```
return [
    'csv_directory' => storage_path('app/location_files_code'),
    'combined_csv_path' => null, // Set to path of combined CSV if available
];
```

### How Location Lookup Works

[](#how-location-lookup-works)

The package uses a smart lookup strategy:

1. **Combined File (Preferred)**: If `tanzania_locations_combined.csv` exists in `storage/app/` (after publishing), it will be used first for faster lookups.
2. **Individual Files (Fallback)**: If the combined file is not found or doesn't contain the ward code, the package falls back to individual region CSV files (11.csv, 21.csv, etc.).

The combined file is automatically published when you run:

```
php artisan vendor:publish --tag=nida-parse-csv
```

You can also override the CSV directory or combined file path when instantiating `LocationLookup`:

```
// Custom CSV directory
$lookup = new LocationLookup('/custom/path/to/csv/files');

// Custom combined file path
$lookup = new LocationLookup(null, '/path/to/combined.csv');
```

📝 NIN Format
------------

[](#-nin-format)

The package supports two NIN formats:

1. **Dashed format**: `YYYYMMDD-LLLLL-SSSSS-XX`

    - Example: `19990504-35710-00001-28`
2. **Compact format**: `YYYYMMDDWWWWWSSSSSXX`

    - Example: `19990504357100000128`

Where:

- `YYYYMMDD`: Birth date (Year, Month, Day)
- `LLLLL`: Ward code (5 digits)
- `SSSSS`: Sequence number (5 digits)
- `XX`: Unknown/check digits (2 digits, first digit indicates gender)

📁 Package Structure
-------------------

[](#-package-structure)

```
nida-parse/
├── src/
│   ├── Services/
│   │   ├── LocationLookup.php
│   │   ├── NidaParser.php
│   │   └── NidaService.php
│   ├── Helpers/
│   │   └── nida_helper.php
│   └── NidaParseServiceProvider.php
├── config/
│   └── nida-parse.php
├── resources/
│   ├── location_files_code/
│   │   ├── 11.csv
│   │   ├── 21.csv
│   │   └── ... (other region CSV files)
│   └── tanzania_locations_combined.csv
└── composer.json

```

🧪 Testing
---------

[](#-testing)

```
composer test
```

📄 License
---------

[](#-license)

MIT

🙏 Credits
---------

[](#-credits)

- Original Python implementation by [Henrylee](https://github.com/Henryle-hd/reverse-nida)
- Laravel package conversion by Ngara Wambura

🔗 Links
-------

[](#-links)

- [Original Python Package](https://github.com/Henryle-hd/reverse_nida)
- [PyPI Package](https://pypi.org/project/r-nida/)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance78

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

115d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c0572a40244530b70a2c4fc907ca8b797efa0dd22cef7e44c8256d6fdcc8c1a?d=identicon)[ngarak-dev](/maintainers/ngarak-dev)

---

Top Contributors

[![ngarak-dev](https://avatars.githubusercontent.com/u/26841409?v=4)](https://github.com/ngarak-dev "ngarak-dev (1 commits)")

---

Tags

laravelparseridentificationtanzanianinnida

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ngarak-dev-nida-parse/health.svg)

```
[![Health](https://phpackages.com/badges/ngarak-dev-nida-parse/health.svg)](https://phpackages.com/packages/ngarak-dev-nida-parse)
```

###  Alternatives

[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[mischasigtermans/laravel-toon

Token-Optimized Object Notation encoder/decoder for Laravel with intelligent nested object handling

13113.1k](/packages/mischasigtermans-laravel-toon)[pherum/laravel-bbcode

Parse your BBCode easy with this library.

2427.5k](/packages/pherum-laravel-bbcode)[illuminated/wikipedia-grabber

Wikipedia/MediaWiki Grabber for Laravel.

477.3k](/packages/illuminated-wikipedia-grabber)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
