代理
获取代理的可用性
GET
/access/availability/dc
返回包含可用代理数量的国家列表。
此功能须由管理员启用后方可使用。此功能要求最低总花费为10000美元。
响应案例:
curl -X GET "https://apid.iproyal.com/v1/reseller/access/availability/dc" \
-H "X-Access-Token: <your_access_token>" \
-H "Content-Type: application/json"
<?php
$api_token = '<your_access_token>';
$url = "https://apid.iproyal.com/v1/reseller/access/availability/dc";
$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>'
url = 'https://apid.iproyal.com/v1/reseller/access/availability/dc'
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 options = {
hostname: 'apid.iproyal.com',
path: '/v1/reseller/access/availability/dc',
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>";
String urlString = "https://apid.iproyal.com/v1/reseller/access/availability/dc";
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>"
url = "https://apid.iproyal.com/v1/reseller/access/availability/dc"
)
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)
}
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>";
string url = "https://apid.iproyal.com/v1/reseller/access/availability/dc";
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);
}
}
}
响应示例:
{
"data": [
{
"country_code": "DE",
"country_name": "Germany",
"available_ips": 2887
},
{
"country_code": "GB",
"country_name": "United Kingdom",
"available_ips": 2351
},
{
"country_code": "US",
"country_name": "United States",
"available_ips": 1112
},
{
"country_code": "NL",
"country_name": "Netherlands",
"available_ips": 1293
},
{
"country_code": "IT",
"country_name": "Italy",
"available_ips": 1812
},
...
]
}
更改凭证
GET
/orders/proxies/change-credentials
正文参数
名称 | 类型 | Description |
---|---|---|
order_id | 整型 | 订单ID |
proxies | 数组 | 代理列表 |
username | 字符串 | 代理连接用户名 |
password | 字符串 | 代理连接密码 |
random_password | 布尔值 | 是否要指定随机密码 |
is_reset | 布尔值 | 是否要指定随机用户名和密码 |
响应案例:
curl -X GET "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials?order_id=12345&username=new_username&password=new_password&random_password=false&is_reset=true" \
-H "X-Access-Token: <your_access_token>" \
-H "Content-Type: application/json" \
-d '{"proxies": ["proxy1", "proxy2"]}'
<?php
$api_token = '<your_access_token>';
$order_id = 12345;
$proxies = ['proxy1', 'proxy2'];
$username = 'new_username';
$password = 'new_password';
$random_password = false;
$is_reset = true;
$url = "https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials?order_id=$order_id&username=$username&password=$password&random_password=$random_password&is_reset=$is_reset";
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Access-Token: $api_token",
'Content-Type: application/json'
],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['proxies' => $proxies])
];
$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
proxies = ['proxy1', 'proxy2']
username = 'new_username'
password = 'new_password'
random_password = False
is_reset = True
url = f'https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials?order_id={order_id}&username={username}&password={password}&random_password={random_password}&is_reset={is_reset}'
headers = {
'X-Access-Token': api_token,
'Content-Type': 'application/json'
}
response = requests.get(url, json={'proxies': proxies}, headers=headers)
print(response.status_code)
print(response.json())
const https = require('https');
const api_token = '<your_access_token>';
const order_id = 12345;
const proxies = ['proxy1', 'proxy2'];
const username = 'new_username';
const password = 'new_password';
const random_password = false;
const is_reset = true;
const data = JSON.stringify({
proxies: proxies
});
const options = {
hostname: 'apid.iproyal.com',
path: `/v1/reseller/orders/proxies/change-credentials?order_id=${order_id}&username=${username}&password=${password}&random_password=${random_password}&is_reset=${is_reset}`,
method: 'GET',
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/proxies/change-credentials" +
"?order_id=12345&username=new_username&password=new_password&random_password=false&is_reset=true";
String requestBody = """
{
"proxies": ["proxy1", "proxy2"]
}
""";
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"
"net/url"
)
const (
apiToken = "<your_access_token>"
orderID = 12345
)
func main() {
proxies := []string{"proxy1", "proxy2"}
username := "new_username"
password := "new_password"
randomPassword := false
isReset := true
params := url.Values{}
params.Add("order_id", fmt.Sprintf("%d", orderID))
params.Add("username", username)
params.Add("password", password)
params.Add("random_password", fmt.Sprintf("%t", randomPassword))
params.Add("is_reset", fmt.Sprintf("%t", isReset))
fullURL := fmt.Sprintf("https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials?%s", params.Encode())
jsonData, err := json.Marshal(map[string]interface{}{
"proxies": proxies,
})
if err != nil {
log.Fatal("Error marshaling JSON:", err)
}
req, err := http.NewRequest(http.MethodGet, fullURL, 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 username = "new_username";
string password = "new_password";
bool randomPassword = false;
bool isReset = true;
string[] proxies = { "proxy1", "proxy2" };
string url = $"https://apid.iproyal.com/v1/reseller/orders/proxies/change-credentials?order_id={orderId}&username={username}&password={password}&random_password={randomPassword}&is_reset={isReset}";
var data = new
{
proxies = proxies
};
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);
}
}
}
Last updated