Files
fksar/docs/dhiraaguapi/01-number-lookup.md
2026-05-17 00:32:34 +05:00

182 lines
4.0 KiB
Markdown

# Number Lookup
Validate a Dhiraagu mobile number and determine whether it is prepaid (reload) or postpaid (bill pay).
This is a two-step process: first fetch the Easy Pay page to extract the nonce, then POST the number to the IO API.
---
## Step 1 — Fetch Nonce
### Endpoint
```
GET https://www.dhiraagu.com.mv/services/easy-pay
```
### Request Headers
```
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0
```
### curl Example
```bash
curl --request GET \
--url 'https://www.dhiraagu.com.mv/services/easy-pay' \
--header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0'
```
### Response
The server returns an HTML page. The nonce is embedded in a `<script>` block:
```html
<script>
var nonce = "feb6acb9-a532-428e-a4d6-c4e5515b4bc3";
...
</script>
```
**Extraction regex:**
```
var nonce = "([^"]+)"
```
The nonce is a UUID (36-char string). It is tied to this page load and must be used immediately in Step 2.
---
## Step 2 — Number Lookup
### Endpoint
```
POST https://www.dhiraagu.com.mv/api/sdk-dhr-webapi.ashx?website_id=CA2BB809-3A22-485B-A518-DA6B6DE653A5&sub=dhiraaguIO&act=infoUnlisted
```
### Request Headers
| Header | Value |
|---|---|
| `Content-Type` | `application/json` |
| `User-Agent` | `Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0` |
| `nonce` | UUID extracted from Step 1 |
| `Origin` | `https://dhiraagu.com.mv` |
### Request Body
```json
{
"number": "7654321"
}
```
| Field | Type | Notes |
|---|---|---|
| `number` | `string` | 7-digit Dhiraagu mobile number (local format, no country code) |
### curl Example
```bash
curl --request POST \
--url 'https://www.dhiraagu.com.mv/api/sdk-dhr-webapi.ashx?website_id=CA2BB809-3A22-485B-A518-DA6B6DE653A5&sub=dhiraaguIO&act=infoUnlisted' \
--header 'Content-Type: application/json' \
--header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0' \
--header 'nonce: feb6acb9-a532-428e-a4d6-c4e5515b4bc3' \
--header 'Origin: https://dhiraagu.com.mv' \
--data '{"number":"7654321"}'
```
---
## Responses
### Success — Prepaid (Reload)
```json
{
"respStatus": "OK",
"serviceDetails": [
{
"prepaidIndicator": "Y",
"serviceType": "GSM"
}
],
"accountOwnerInfo": {
"name": "Ahmed Mohamed",
"accountNo": "7654321"
}
}
```
| Field | Type | Description |
|---|---|---|
| `respStatus` | `string` | `"OK"` on success |
| `serviceDetails[0].prepaidIndicator` | `string` | `"Y"` = prepaid (reload), `"N"` = postpaid (bill pay) |
| `accountOwnerInfo.name` | `string` | Account holder's full name |
### Success — Postpaid (Bill Pay)
Same structure as above, with `prepaidIndicator: "N"`.
```json
{
"respStatus": "OK",
"serviceDetails": [
{
"prepaidIndicator": "N",
"serviceType": "GSM"
}
],
"accountOwnerInfo": {
"name": "Fatima Ali",
"accountNo": "7123456"
}
}
```
### Failure — Number Not Found
```json
{
"respStatus": "FAILED",
"respMessage": "Number not found"
}
```
`respStatus` is not `"OK"`. Treat any non-OK status as unsupported.
### Failure — Invalid / Expired Nonce
If the nonce is missing, invalid, or has already been used, the server returns an error response (non-OK status or HTTP 4xx). Re-fetch the Easy Pay page to get a fresh nonce.
---
## Result Mapping
| `prepaidIndicator` | Service |
|---|---|
| `"Y"` | Dhiraagu Reload |
| `"N"` | Dhiraagu Bill Pay |
| absent / `respStatus != "OK"` | Unsupported — fall back to Ooredoo lookup |
## Number Portability
Due to **mobile number portability (MNP)** in the Maldives, a subscriber can port their number between Dhiraagu and Ooredoo while keeping the same number. This means:
- A number starting with **9** (typically Ooredoo) may now be on the Dhiraagu network.
- A number starting with **7** (typically Dhiraagu) may now be on the Ooredoo network.
Always fall back to the other provider's lookup if this API returns a failed/unsupported result, regardless of the number prefix.
---
&nbsp;
---
[← README](README.md)