# Package Listing

This endpoint lets you retrieve package listings for operators such as Data Pack&#x20;

#### 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. **Initiate Recharge**:
   * Once you have obtained all the required details (operator, type), you can use the API to initiate a recharge request with the request parameters given below.

## Package Listing API

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

**Headers**

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

**Body**

| Name               | Type   | Description                                          |
| ------------------ | ------ | ---------------------------------------------------- |
| `operator_id`      | int    | ID of the relevant operator                          |
| `operator_type_id` | int    | Operator Type ID                                     |
| `connection_no`    | string | Operator ID of DTH or Mobile no in case of Data Pack |
| `reference_no`     | string | Unique reference no for the request                  |

**Response**

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

```json
{
    "error": false,
    "message": "Success Message",
    "data": [
        {
            "id": "Package ID e.g, PROD_001_inv",
            "name": "Name of the package e.g 100 minute call time",
            "amount": "Amount for package e.g 50"
        },
        ....
    ]
}
```

{% endtab %}

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

```json
{
    "error": true,
    "message": "Description for the error",
}
```

{% endtab %}

{% tab title="Guzzle Request" %}

<pre class="language-php"><code class="lang-php">use GuzzleHttp\Client;

$url    = 'np/recharge/package';

$form_params =
  [
    'operator_type_id' => '3',
    'operator_id'      => '10',
    'connection_no'    => '9841802255',
    'reference_no'     => mt_rand(1000000,9999999)
    
  ];
            
<strong>$client = new Client([
</strong>    '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);

</code></pre>

{% endtab %}

{% tab title="PHP Curl" %}

```php
<?php

$curl = curl_init();

$data = json_encode(array(
    'operator_id' => '10',
    'operator_type_id' => '3',
    'connection_no' => '9865160527',
    'reference_no' => '345678'
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://uatservices.globaltopup.in/api/v1/np/recharge/package',
  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(
    'Content-Type: application/json',
    'Accept: application/json',
    'x-auth-token: Token Provided by Global Topup'
  ),
));

$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/package
     -H 'Content-Type: application/json'
     -H 'Accept: application/json' 
     -H 'x-auth-token: Global Topup Provided Token'
     -d '{"operator_id" : "10","operator_type_id" : "3",
     "connection_no" : "9865160527",
     "reference_no" : "345678"}' // Send JSON payload
```

{% endtab %}
{% endtabs %}

The response contains an error flag and a message, along with an array of objects with package listing data in case of a successful response, where each package object will have `id`, `name` and `amount`


---

# 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/additional-nepal-apis/package-listing.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.
