# 产品

## 获取产品

<mark style="color:green;">`GET`</mark>  `/products`

返回包含**套餐、地理位置、问题**和**阶梯折扣**的产品列表。

**响应案例：**

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

```
curl -X GET "https://apid.iproyal.com/v1/reseller/products" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
```

{% endtab %}

{% tab title="PHP" %}

```php
const https = require('https');

const api_token = '<your_access_token>';

const options = {
  hostname: 'apid.iproyal.com',
  path: '/v1/reseller/products',
  method: 'GET',
  headers: {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(responseData);
  });
});

req.on('error', (error) => {
  console.error('Error:', error.message);
});

req.end();
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_token = '<your_access_token>'
url = 'https://apid.iproyal.com/v1/reseller/products'

headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

response = requests.get(url, headers=headers)

print(response.status_code)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require('https');

const api_token = '<your_access_token>';

const options = {
  hostname: 'apid.iproyal.com',
  path: '/v1/reseller/products',
  method: 'GET',
  headers: {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(responseData);
  });
});

req.on('error', (error) => {
  console.error('Error:', error.message);
});

req.end();
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ApiRequest {
    public static void main(String[] args) {
        String apiToken = "<your_access_token>";
        String urlString = "https://apid.iproyal.com/v1/reseller/products";

        try {
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("X-Access-Token", apiToken);
            connection.setRequestProperty("Content-Type", "application/json");

            int responseCode = connection.getResponseCode();
            System.out.println("Response Code: " + responseCode);

            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder content = new StringBuilder();

                while ((inputLine = in.readLine()) != null) {
                    content.append(inputLine);
                }
                in.close();

                System.out.println("Response Body: " + content.toString());
            } else {
                System.out.println("GET request failed. Response Code: " + responseCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
)

const (
	apiToken = "<your_access_token>"
	url      = "https://apid.iproyal.com/v1/reseller/products"
)

func main() {
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		log.Fatal("Error creating request:", err)
	}

	req.Header.Set("X-Access-Token", apiToken)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal("Error making request:", err)
	}
	defer resp.Body.Close()

	fmt.Println("Status Code:", resp.StatusCode)

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Error reading response body:", err)
	}

	var jsonResponse map[string]interface{}
	err = json.Unmarshal(responseBody, &jsonResponse)
	if err != nil {
		log.Fatal("Error unmarshaling JSON:", err)
	}

	fmt.Printf("%+v\n", jsonResponse)
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_access_token>";
        string url = "https://apid.iproyal.com/v1/reseller/products";

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);
            client.DefaultRequestHeaders.Add("Content-Type", "application/json");

            HttpResponseMessage response = await client.GetAsync(url);

            Console.WriteLine((int)response.StatusCode);

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JObject.Parse(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}
```

{% endtab %}
{% endtabs %}

**响应示例：**

```json
{
    "data": [
        {
            "id": 9,
            "name": "Static Residential",
            "plans": [
                {
                    "id": 4,
                    "name": "30 Days",
                    "price": 2,
                    "min_quantity": 5,
                    "max_quantity": 100000
                },
                ...
            ],
            "locations": [
                {
                    "id": 51,
                    "name": "Australia",
                    "out_of_stock": false,
                    "available_proxies_count": 1142
                },
                ...
            ],
            "questions": [
                {
                    "id": 5,
                    "text": "On which website do you plan to use them?",
                    "is_required": false
                }
            ],
            "quantity_discounts": [
                {
                    "quantity_from": 99,
                    "discount_percent": 5
                },
                ...
            ]
        },
        ...
    ]
}
```


---

# 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.iproyal.com/cn/dai-li/yun-dong-xie-shu-ju-zhong-xin-dai-li/api/chan-pin.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.
