# DTH

This API allows you to recharge DTH operators such as:

1. Dish Home Operator Id: 36
2. SIM Tv Operator Id : 37
3. Mero Tv Operator Id : 38
4. Sky Tv Operator Id : 39
5. Clear Tv Operator Id : 40
6. Jagriti Cable Operator Id : 42
7. Max Tv Operator Id : 43
8. Nijgadh Cable Operator Id : 58
9. Net Tv Operator Id: 100
10. Png Network Operator Id : 112

* To get a list of available operators, use the [Operator Lookup API](/additional-nepal-apis/operator-lookup.md).
* To get a list of available operator types, use the [Operator Type Lookup API.](/additional-nepal-apis/operator-type-lookup.md)
* To find a list of available packages, refer to the [Package Listing API](/additional-nepal-apis/package-listing.md).

#### How To Use:

1. **Identify the Operator**:
   * First, use the [Operator Lookup API ](/additional-nepal-apis/operator-lookup.md)to get the correct operator based on user input or selection.
2. **Determine Operator Type**:
   * Use the [Operator Type Lookup API ](/additional-nepal-apis/operator-type-lookup.md)to confirm the type (e.g., Mobile, DTH, Data Pack, etc).
3. **Retrieve Package Listing**:
   * For the DTH operator, you will need an `package_id`. Use the [DTH Package API](/nepal-recharge/dth/dth-package.md) to find the appropriate package list for the user's selection.
4. **Initiate Recharge**:
   * Once you have obtained all the required details (operator, type,  package\_id), you can use the API to initiate a recharge request.

## Execute the recharge for DTH

<mark style="color:green;">`POST`</mark> `/np/recharge/execute`

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |
| x-auth-token | `<token>`          |

**Body**

| Name               | Type   | Description                                                                                                                    |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `operator_id`      | number | The ID of the operator to recharge                                                                                             |
| `operator_type_id` | number | The type ID of the operator                                                                                                    |
| `connection_no`    | string | Enter the customer ID of the user                                                                                              |
| `package_id`       | string | Package ID  ( [DTH package](/nepal-recharge/dth/dth-package.md) )                                                              |
| `reference_no`     | string | The unique reference number received in response of  Package Listing API( [DTH package](/nepal-recharge/dth/dth-package.md) ). |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "error": false,
  "message": "Additional message about the recharge"
 "data" : [
  "transaction_id" => "Transaction ID of the recharge e.g 12345",
  "reference_no"   => "Unique reference number provided by you for later reference",
  "amount"         => "Amount for which recharge has been done",
  "credit_consumed": 
       {
          "service_charge": " Processing fees charged by Company e.g 0.5 ",
          "instant_discount": " Any Discount Offered by Company e.g 0.2 ",
          "debit_amount": " Recharged amount + Service charge - instant discount e.g 10.3 "
        },
   "credit_available": "Available wallet balance after transaction e.g 8313.58",
   "commission" : "Commission Amount Received from Company if any e.g 1.00",
   "status"         => "Status of the recharge e.g queued, success,failed, etc"
 ]
}
```

{% endtab %}

{% tab title="4XX/5XX" %}

```json
{
  "type": "object",
  "properties": {
    "status": {
      "type": "boolean",
      "description": "The status of the recharge execution either true or false"
    },
    "message": {
      "type": "string",
      "description": "A message providing additional information about the error of the recharge execution."
    },
     "data": {
      "type": "error",
      "description": "Blank array in case of error"
    }
  }
}
```

{% endtab %}

{% tab title="Guzzle" %}

```php
use GuzzleHttp\Client;

$url    = 'np/recharge/execute';

$form_params =
  [
    'operator_type_id' => '2',
    'operator_id'      => '36',
    'connection_no'    => '71910718965',
    'reference_no'     => mt_rand(1000000,9999999),
    'package_id'       => 'Package Id selected by User'
  ];
            
$client = new Client([
    'base_uri' => 'https://uatservices.globaltopup.in/api/v1/',
          ]);
          $res = $client->post($url, [
          'json' => $form_params, // Send JSON payload
          'headers' => 
        [
             'x-auth-token' => 'Token Provided by Global Topup',
             'Content-Type' => 'application/json'
        ]
                ]);
              
   $response       =   json_decode($res->getBody()->getContents(), true);

```

{% endtab %}

{% tab title="PHP" %}

```php
$curl = curl_init();

$data = json_encode(array(
    'operator_id'       => '36',
    'operator_type_id'  => '2',
    'connection_no'     => '71910718965',
    'reference_no'      => '345678',
    'package_id'        => 'Package Id selected by User'
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://uatservices.globaltopup.in/api/v1/np/recharge/execute',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data, // Send JSON payload
  CURLOPT_HTTPHEADER => array(
    'x-auth-token: Token Provided by Global Topup',
    'Accept: application/json',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Curl" %}

```php

curl -X POST https://uatservices.globaltopup.in/api/v1/np/recharge/execute
     -H 'Content-Type: application/json'
     -H 'Accept: application/json' 
     -H 'x-auth-token: Global Topup Provided Token'
     -d '{"operator_id" : "36","operator_type_id" : "2",
     "connection_no" : "71910718965",
     "reference_no" : "345678","package_id" : "Package Id selected by User"}' // Send JSON payload
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.globaltopup.in/nepal-recharge/dth.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
