IPRoyal Documentation
CN
CN
  • 概述
  • 代理
    • 皇家住宅代理
      • 仪表板
        • 统计数据
        • 配置
          • 自动充值
          • 代理访问
          • 白名单IP
          • 跳过IP
          • 权限管理
        • 订单
        • 子用户
      • 代理
        • 位置
        • 轮换类型
        • 高端池
        • 跳过静态ISP
        • IP白名单
        • 跳过IP
        • 权限管理
        • 协议
        • 提出请求
      • 子用户
      • API
        • 会话
        • 用户
        • 访问
        • 子用户
        • 白名单
        • 跳过IP
      • 域名访问条款
    • 静态住宅代理
      • 仪表板
        • 订单
        • 订单配置
        • 续期订单
      • 使用代理字符串
      • API
        • 用户
        • 产品
        • 订单
        • 代理
    • 数据中心代理
      • 仪表板
        • 订单
        • 订单配置
        • 续期订单
      • 使用代理字符串
      • API
        • 用户
        • 产品
        • 订单
        • 代理
    • 移动代理
      • 仪表板
        • 订单
        • 订单配置
        • 续期订单
      • 使用代理字符串
      • 故障排除
      • API
        • 用户
        • 代理
Powered by GitBook
On this page
  • 获取多个订单
  • 获取订单
  • 计算价格
  • 创建订单
  • 续期订单
  1. 代理
  2. 静态住宅代理
  3. API

订单

诸如product_id、location_id等选项可以使用产品端点进行检索。

产品

获取多个订单

GET /orders

查询参数

名称
类型
描述
可用选项

product_id

整型

产品ID

page

整型

页数

per_page

整型

每页获取的订单数

location_id

整型

位置ID

status

字符串

订单状态

note_search

字符串

要搜索的订单备注字段中的短语

order_ids

数组

目标订单的ID

响应案例:

curl -X GET "https://apid.iproyal.com/v1/reseller/orders?product_id=123&page=1&per_page=10&location_id=456&status=in-progress&note_search=example%20note&order_ids[]=789&order_ids[]=1011" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
<?php
$api_token = '<your_access_token>';

$params = [
    'product_id' => 123,
    'page' => 1,
    'per_page' => 10,
    'location_id' => 456,
    'status' => 'in-progress',
    'note_search' => 'example note',
    'order_ids' => [789, 1011]
];

$query = http_build_query($params);
$url = "https://apid.iproyal.com/v1/reseller/orders?$query";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
import requests

api_token = '<your_access_token>'
params = {
    'product_id': 123,
    'page': 1,
    'per_page': 10,
    'location_id': 456,
    'status': 'in-progress',
    'note_search': 'example note',
    'order_ids[]': [789, 1011]
}

url = 'https://apid.iproyal.com/v1/reseller/orders'
headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

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

print(response.status_code)
print(response.json())
const https = require('https');

const api_token = '<your_access_token>';

const params = new URLSearchParams({
  product_id: 123,
  page: 1,
  per_page: 10,
  location_id: 456,
  status: 'in-progress',
  note_search: 'example note',
});

const orderIds = [789, 1011];
orderIds.forEach(id => params.append('order_ids[]', id));

const options = {
  hostname: 'apid.iproyal.com',
  path: `/v1/reseller/orders?${params.toString()}`,
  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();
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;

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

        Map<String, String> params = Map.of(
                "product_id", "123",
                "page", "1",
                "per_page", "10",
                "location_id", "456",
                "status", "in-progress",
                "note_search", "example note"
        );

        List<String> orderIds = List.of("789", "1011");

        StringBuilder queryParams = new StringBuilder();
        try {
            for (Map.Entry<String, String> entry : params.entrySet()) {
                if (queryParams.length() > 0) {
                    queryParams.append("&");
                }
                queryParams.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
                        .append("=")
                        .append(URLEncoder.encode(entry.getValue(), "UTF-8"));
            }

            for (String orderId : orderIds) {
                if (queryParams.length() > 0) {
                    queryParams.append("&");
                }
                queryParams.append(URLEncoder.encode("order_ids[]", "UTF-8"))
                        .append("=")
                        .append(URLEncoder.encode(orderId, "UTF-8"));
            }

            URL url = new URL(urlString + "?" + queryParams.toString());
            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();
        }
    }
}
package main

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

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

func main() {
	params := url.Values{}
	params.Add("product_id", "123")
	params.Add("page", "1")
	params.Add("per_page", "10")
	params.Add("location_id", "456")
	params.Add("status", "in-progress")
	params.Add("note_search", "example note")

	orderIds := []string{"789", "1011"}
	for _, id := range orderIds {
		params.Add("order_ids[]", id)
	}

	fullURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())

	req, err := http.NewRequest(http.MethodGet, fullURL, 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)
}
using System.Text.Json;

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

        var queryParams = new Dictionary<string, string>
        {
            { "product_id", "123" },
            { "page", "1" },
            { "per_page", "10" },
            { "location_id", "456" },
            { "status", "in-progress" },
            { "note_search", "example note" },
        };

        List<string> orderIds = new List<string> { "789", "1011" };

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            var query = new List<string>();
            
            foreach (var param in queryParams)
            {
                query.Add($"{Uri.EscapeDataString(param.Key)}={Uri.EscapeDataString(param.Value)}");
            }
            
            foreach (var orderId in orderIds)
            {
                query.Add($"{Uri.EscapeDataString("order_ids[]")}={Uri.EscapeDataString(orderId)}");
            }

            string queryString = string.Join("&", query);
            string urlWithParams = $"{url}?{queryString}";

            HttpResponseMessage response = await client.GetAsync(urlWithParams);

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

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}

响应示例:

{
    "data": [
        {
            "id": 420,
            "note": null,
            "product_name": "Static Residential",
            "expire_date": "2024-04-20 10:25:12",
            "plan_name": "30 Days",
            "status": "confirmed",
            "location": "United States",
            "quantity": 5,
            "questions_answers": [
                {
                    "question": "Extra requirements (if you have any):",
                    "answer": "I need 128.158.97"
                }
            ],
            "proxy_data": {
                "ports": {
                    "socks5": 12324,
                    "http|https": 12323
                },
                "proxies": []
            },
            "auto_extend_settings": null,
            "extended_history": []
        },
        ...
    ],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "path": "https://apid.iproyal.com/v1/reseller/orders",
        "per_page": 10,
        "to": 10,
        "total": 14
    }
}

获取订单

GET /orders/{order_id}

响应案例:

curl -X GET "https://apid.iproyal.com/v1/reseller/orders/12345" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
<?php
$api_token = '<your_access_token>';
$order_id = 12345;

$url = "https://apid.iproyal.com/v1/reseller/orders/$order_id";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
import requests

api_token = '<your_access_token>'
order_id = 12345

url = f'https://apid.iproyal.com/v1/reseller/orders/{order_id}'
headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

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

print(response.status_code)
print(response.json())
const https = require('https');

const api_token = '<your_access_token>';
const order_id = 12345;

const options = {
  hostname: 'apid.iproyal.com',
  path: `/v1/reseller/orders/${order_id}`,
  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();
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>";
        int orderId = 12345;
        String urlString = String.format("https://apid.iproyal.com/v1/reseller/orders/%d", orderId);

        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();
        }
    }
}
package main

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

const (
	apiToken = "<your_access_token>"
	orderID  = 12345
)

func main() {
	url := fmt.Sprintf("https://apid.iproyal.com/v1/reseller/orders/%d", orderID)

	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)
}
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

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

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            HttpResponseMessage response = await client.GetAsync(url);

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

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}

响应示例:

{
    "id": 420,
    "note": null,
    "product_name": "Static Residential",
    "expire_date": "2024-04-20 10:25:12",
    "plan_name": "30 Days",
    "status": "expired",
    "location": "Canada",
    "quantity": 5,
    "questions_answers": [],
    "proxy_data": {
        "ports": {
            "socks5": 12324,
            "http|https": 12323
        },
        "proxies": []
    },
    "auto_extend_settings": null,
    "extended_history": []
}

计算价格

GET /orders/calculate-pricing

查询参数

名称
类型
描述

product_id

整型

产品ID

product_plan_id

整型

产品套餐ID

product_location_id

整型

产品地理位置ID

quantity

整型

代理数量

coupon_code

字符串

优惠码

响应案例:

curl -X GET "https://apid.iproyal.com/v1/reseller/orders/calculate-pricing?product_id=123&product_plan_id=456&product_location_id=789&quantity=10&coupon_code=DISCOUNT2024" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
<?php
$api_token = '<your_access_token>';

$params = [
    'product_id' => 123,
    'product_plan_id' => 456,
    'product_location_id' => 789,
    'quantity' => 10,
    'coupon_code' => 'DISCOUNT2024'
];

$query = http_build_query($params);
$url = "https://apid.iproyal.com/v1/reseller/orders/calculate-pricing?$query";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
import requests

api_token = '<your_access_token>'
params = {
    'product_id': 123,
    'product_plan_id': 456,
    'product_location_id': 789,
    'quantity': 10,
    'coupon_code': 'DISCOUNT2024'
}

url = 'https://apid.iproyal.com/v1/reseller/orders/calculate-pricing'
headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

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

print(response.status_code)
print(response.json())
const https = require('https');

const api_token = '<your_access_token>';

const params = new URLSearchParams({
  product_id: 123,
  product_plan_id: 456,
  product_location_id: 789,
  quantity: 10,
  coupon_code: 'DISCOUNT2024'
}).toString();

const options = {
  hostname: 'apid.iproyal.com',
  path: `/v1/reseller/orders/calculate-pricing?${params}`,
  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();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String accessToken = "<your_access_token>";
        String url = "https://apid.iproyal.com/v1/reseller/orders/calculate-pricing" +
                "?product_id=123&product_plan_id=456&product_location_id=789&quantity=10&coupon_code=DISCOUNT2024";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("X-Access-Token", accessToken)
                .GET()
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println("Response Code: " + response.statusCode());
        System.out.println("Response Body: " + response.body());
    }
}
package main

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

const (
	apiToken = "<your_access_token>"
	baseURL  = "https://apid.iproyal.com/v1/reseller/orders/calculate-pricing"
)

func main() {
	params := url.Values{}
	params.Add("product_id", fmt.Sprintf("%d", 123))
	params.Add("product_plan_id", fmt.Sprintf("%d", 456))
	params.Add("product_location_id", fmt.Sprintf("%d", 789))
	params.Add("quantity", fmt.Sprintf("%d", 10))
	params.Add("coupon_code", "DISCOUNT2024")

	fullURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())

	req, err := http.NewRequest(http.MethodGet, fullURL, 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)
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;

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

        var queryParams = new Dictionary<string, string>
        {
            { "product_id", "123" },
            { "product_plan_id", "456" },
            { "product_location_id", "789" },
            { "quantity", "10" },
            { "coupon_code", "DISCOUNT2024" }
        };

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            var urlWithParams = new UriBuilder(url) { Query = await new FormUrlEncodedContent(queryParams).ReadAsStringAsync() }.ToString();

            HttpResponseMessage response = await client.GetAsync(urlWithParams);

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

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}

响应示例:

{
    "pre_discount_price": 30,
    "price_with_vat": 30,
    "vat": null,
    "price": 30,
    "pre_discount_price_per_item": 3,
    "price_per_item": 3,
    "plan_discount_percent": 0,
    "location_discount_percent": 0,
    "coupon_discount_percent": 0,
    "quantity_discount_percent": 0,
    "total_discount_percent": 0,
    "quantity_required_for_next_discount": {
        "quantity": 90,
        "discount": 5
    },
    "message": null
}

创建订单

POST /orders

正文参数

名称
类型
描述

product_id

整型

产品ID

product_plan_id

整型

产品套餐ID

product_location_id

整型

产品地理位置ID

quantity

整型

代理数量

coupon_code

字符串

优惠码

auto_extend

布尔值

订单是否会自动续期 預設值為 true

product_question_answers

数组

问题解答

响应案例:

curl -X POST "https://apid.iproyal.com/v1/reseller/orders" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json" \
     -d '{
           "product_id": 123,
           "product_plan_id": 456,
           "product_location_id": 789,
           "quantity": 10,
           "coupon_code": "DISCOUNT2024",
           "auto_extend": true,
           "product_question_answers": {
               "question_id_1": "answer_1",
               "question_id_2": "answer_2"
           }
         }'
<?php
$api_token = '<your_access_token>';

$url = "https://apid.iproyal.com/v1/reseller/orders";

$data = [
    'product_id' => 123,
    'product_plan_id' => 456,
    'product_location_id' => 789,
    'quantity' => 10,
    'coupon_code' => 'DISCOUNT2024',
    'auto_extend' => true,
    'product_question_answers' => [
        'question_id_1' => 'answer_1',
        'question_id_2' => 'answer_2'
    ]
];

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode($data)
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
import requests

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

data = {
    'product_id': 123,
    'product_plan_id': 456,
    'product_location_id': 789,
    'quantity': 10,
    'coupon_code': 'DISCOUNT2024',
    'auto_extend': True,
    'product_question_answers': {
        'question_id_1': 'answer_1',
        'question_id_2': 'answer_2'
    }
}

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

response = requests.post(url, json=data, headers=headers)

print(response.status_code)
print(response.json())
const https = require('https');

const api_token = '<your_access_token>';
const data = JSON.stringify({
  product_id: 123,
  product_plan_id: 456,
  product_location_id: 789,
  quantity: 10,
  coupon_code: 'DISCOUNT2024',
  auto_extend: true,
  product_question_answers: {
    question_id_1: 'answer_1',
    question_id_2: 'answer_2'
  }
});

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

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.write(data);
req.end();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String accessToken = "<your_access_token>";
        String url = "https://apid.iproyal.com/v1/reseller/orders";

        String requestBody = """
            {
                "product_id": 123,
                "product_plan_id": 456,
                "product_location_id": 789,
                "quantity": 10,
                "coupon_code": "DISCOUNT2024",
                "auto_extend": true,
                "product_question_answers": {
                    "question_id_1": "answer_1",
                    "question_id_2": "answer_2"
                }
            }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("X-Access-Token", accessToken)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println("Response Code: " + response.statusCode());
        System.out.println("Response Body: " + response.body());
    }
}
package main

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

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

func main() {
	data := map[string]interface{}{
		"product_id":              123,
		"product_plan_id":         456,
		"product_location_id":     789,
		"quantity":                10,
		"coupon_code":             "DISCOUNT2024",
		"auto_extend":             true,
		"product_question_answers": map[string]string{
			"question_id_1": "answer_1",
			"question_id_2": "answer_2",
		},
	}

	jsonData, err := json.Marshal(data)
	if err != nil {
		log.Fatal("Error marshaling JSON:", err)
	}

	req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData))
	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)
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

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

        var data = new
        {
            product_id = 123,
            product_plan_id = 456,
            product_location_id = 789,
            quantity = 10,
            coupon_code = "DISCOUNT2024",
            auto_extend = true,
            product_question_answers = new
            {
                question_id_1 = "answer_1",
                question_id_2 = "answer_2"
            }
        };

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            var jsonData = JsonSerializer.Serialize(data);
            var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

            HttpResponseMessage response = await client.PostAsync(url, content);

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

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}

响应示例:

{
    "id": 420,
    "note": null,
    "product_name": "Static Residential",
    "plan_name": "30 Days",
    "expire_date": "2024-04-20 10:25:12",
    "status": "expired",
    "location": "Canada",
    "quantity": 5,
    "questions_answers": [],
    "proxy_data": {
        "ports": {
            "socks5": 12324,
            "http|https": 12323
        },
        "proxies": []
    },
    "auto_extend_settings": null,
    "extended_history": []
}

续期订单

POST /orders/{order_id}/extend

正文参数

名称
类型
描述

product_plan_id

整型

产品套餐ID

响应案例:

curl -X POST "https://apid.iproyal.com/v1/reseller/orders/12345/extend" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json" \
     -d '{
           "product_plan_id": 678
         }'
<?php
$api_token = '<your_access_token>';
$order_id = 12345;
$product_plan_id = 678;

$url = "https://apid.iproyal.com/v1/reseller/orders/$order_id/extend";

$data = [
    'product_plan_id' => $product_plan_id
];

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode($data)
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
import requests

api_token = '<your_access_token>'
order_id = 12345  # pakeiskite su tikru order_id
url = f'https://apid.iproyal.com/v1/reseller/orders/{order_id}/extend'

data = {
    'product_plan_id': 678  # pakeiskite su tikru product_plan_id
}

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

response = requests.post(url, json=data, headers=headers)

print(response.status_code)
print(response.json())
const https = require('https');

const api_token = '<your_access_token>';
const order_id = 12345;
const data = JSON.stringify({
  product_plan_id: 678
});

const options = {
  hostname: 'apid.iproyal.com',
  path: `/v1/reseller/orders/${order_id}/extend`,
  method: 'POST',
  headers: {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json',
    'Content-Length': data.length
  }
};

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.write(data);
req.end();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String accessToken = "<your_access_token>"; 
        String orderId = "12345";
        String url = "https://apid.iproyal.com/v1/reseller/orders/" + orderId + "/extend";

        String requestBody = """
            {
                "product_plan_id": 678
            }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("X-Access-Token", accessToken)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println("Response Code: " + response.statusCode());
        System.out.println("Response Body: " + response.body());
    }
}
package main

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

const (
	apiToken = "<your_access_token>"
	orderID  = 12345
)

func main() {
	url := fmt.Sprintf("https://apid.iproyal.com/v1/reseller/orders/%d/extend", orderID)

	data := map[string]interface{}{
		"product_plan_id": 678,
	}

	jsonData, err := json.Marshal(data)
	if err != nil {
		log.Fatal("Error marshaling JSON:", err)
	}

	req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData))
	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)
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_access_token>";
        int orderId = 12345;
        string url = $"https://apid.iproyal.com/v1/reseller/orders/{orderId}/extend";

        var data = new
        {
            product_plan_id = 678
        };

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            var jsonData = JsonSerializer.Serialize(data);
            var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

            HttpResponseMessage response = await client.PostAsync(url, content);

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

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}

响应示例:

{
    "id": 420,
    "note": null,
    "product_name": "Static Residential",
    "plan_name": "30 Days",
    "expire_date": "2024-04-20 10:25:12",
    "status": "expired",
    "location": "Canada",
    "quantity": 5,
    "questions_answers": [],
    "proxy_data": {
        "ports": {
            "socks5": 12324,
            "http|https": 12323
        },
        "proxies": []
    },
    "auto_extend_settings": null,
    "extended_history": []
}
Previous产品Next代理

Last updated 1 month ago

unpaid
in-progress
confirmed
refunded
expired
{ question_id: answer, ... }