How to Use PrivateProxy.me API

如何使用 PrivateProxy.me API

您知道如何使用 PrivateProxy.me API?这是 PrivateProxy.me 官方最全面的介绍。

基本信息

软件包必须处于激活状态,API 才能工作。

您的 API 密钥: 08c5fa8dd63c8adc4b08803df5f68f9d

API 基本 URL: https://app.privateproxy.me/api/v1

授权是标准的基本 auth,api 为用户名,api key 为密码,也可以使用 key 查询参数。

curl -u api:08c5fa8dd63c8adc4b08803df5f68f9d https://app.privateproxy.me/api/v1/package_subscriptions/1/...
curl https://app.privateproxy.me/api/v1/package_subscriptions/1/...?key=08c5fa8dd63c8adc4b08803df5f68f9d

API 请求中不能使用非活动订阅。

所有其他示例都使用基本授权。


所有示例的通用代码

Python 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
# 文件名 proxy_api.py
导入 json
导入请求
导入 pprint

类 ProxyAPIException(Exception):
  通过

class RequestError(ProxyAPIException):
  通过

class ResponseError(ProxyAPIException):
  通过

class ResponseParseError(ProxyAPIException): 通过
  通过

类 ProxyAPI:
  def __init__(self, base, api_key):
    if base.endswith('/'):
      self.base = base
    else:
      self.base = base + '/'
    self.api_key = api_key

  def __is_json_response(self, response):
    if 'Content-Type' not in response.headers:
      返回 False
    for part in response.headers['Content-Type'].split(';'):
      if part == "application/json":
        返回 True

    返回 False

  def __process_response(self, response):
    if response.status_code == 200:
      error = None
      if self.__is_json_response(response):
        try:
          obj = json.loads(response.text)
        except Exception as e:
          error = e
        if error:
          raise ResponseParseError("Error parsing JSON response from the server:%s" % str(error))
        返回 obj
      else:
        return response.text
    else:
      if self.__is_json_response(response):
        failed = False
        try:
          error_json = json.loads(response.text)
        except Exception as e:
          failed = True
        if failed:
          raise ResponseError("Received non-200 code from the server, but failed to parse json response:%s" % response.text)
        否则
          raise ResponseError("Received error from server: %s" % error_json['error'])
      else:
        raise ResponseError("从服务器收到非 200 代码")


  def get(self, endpoint, query_params = {}):
    if endpoint[0] == '/':
      endpoint = endpoint[1:]
    fin_url = self.base + endpoint
    error = None
    try:
      response = requests.get(fin_url, auth=('api', self.api_key), params = query_params)
    except requests.exceptions.RequestException as e:
      error = e

    if error:
      raise RequestError("An error occurred while making a request: %s" % str(error))

    return self.__process_response(response)

  def put(self, endpoint, body = {}):
    if endpoint[0] == '/':
      endpoint = endpoint[1:]
    fin_url = self.base + endpoint
    error = None
    try:
      response = requests.put(
        fin_url、
        auth=('api', self.api_key)、
        data = json.dumps(body)、
        headers = {'Content-Type': 'application/json'} )
      )
    except requests.exceptions.RequestException as e:
      error = e

    if error:
      raise RequestError("An error occurred while making a request: %s" % str(error))

    return self.__process_response(response)
<?php
// filename proxy_api.php
class ProxyAPIException extends Exception {}
class RequestError extends ProxyAPIException {}
class ResponseError extends ProxyAPIException {}
class ResponseParseError extends ProxyAPIException {}

class ProxyAPI {
  private $api_base, $api_key;

  public function __construct($api_base, $api_key) {
    $this->api_base = preg_replace("/\/+$/", "", $api_base);
    $this->api_key = $api_key;
  }

  public function get($endpoint, $query_params = null) {
    $endpoint = "/".preg_replace("/^\/+/", "", $endpoint);
    $url = $this->api_base.$endpoint;

    $query_string = "";
    if ($query_params !== null) {
      $q = null;
      if (is_string($query_params)) {
        $q = explode($url, '&');
      } elseif (is_array($query_params)) {
        $q = $query_params;
      }
      $tmp = [];
      foreach ($q as $key => $value) {
        $tmp[] = urlencode($key) . "=" . urlencode($value);
      }
      $query_string = implode("&", $tmp);
    }

    if ($query_string !== "") {
      $url .= "?".$query_string;
    }

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERNAME, "api");
    curl_setopt($ch, CURLOPT_PASSWORD, $this->api_key);
    $response = curl_exec($ch);

    return $this->process_response($ch, $response);
  }

  public function put($endpoint, $body = null) {
    $endpoint = "/" . preg_replace("/^\/+/", "", $endpoint);
    $url = $this->api_base . $endpoint;

    $data_json = json_encode($body);
    if (json_last_error()) {
      throw new RequestError("Error encoding body as json: ".json_last_error_msg());
    }

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERNAME, "api");
    curl_setopt($ch, CURLOPT_PASSWORD, $this->api_key);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type:application/json", "Content-Length:".strlen($data_json)]);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
    $response = curl_exec($ch);

    return $this->process_response($ch, $response);
  }

  private function process_response($ch, $response) {
    if (curl_error($ch)) {
      throw new RequestError("Received error during request: ".curl_error($ch));
    }
    $response_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
    $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
    $is_json = strstr($content_type, 'application/json') !== false;
    curl_close($ch);

    if ($response_code == '200') {
      if ($is_json) {
        $res = json_decode($response, true, 512);
        $le = json_last_error();
        if ($le != JSON_ERROR_NONE) {
          throw new ResponseParseError("Error parsing response from server as JSON: ".json_last_error_msg());
        }
        return $res;
      } else {
        return $response;
      }
    } else {
      if ($is_json) {
        $res = json_decode($response, true, 512);
        $le = json_last_error();
        if ($le != JSON_ERROR_NONE) {
          throw new ResponseError("Received ".$response_code." code from server, but failed to parse JSON response: ".json_last_error_msg());
        }
        throw new ResponseError("Received ".$response_code." code from server: ".$res['error']);
      } else {
        throw new ResponseError("Received ".$response_code." code from server: ".$response);
      }
    }
  }
}
// filename proxy_api.js
const https = require('https')
const http = require('http')
const querystring = require('querystring');

function process_response(response, body, resolve, reject) {
  const ct = response.headers['content-type'] || '';
  let isJson = false;
  if (ct.includes("application/json")) {
    isJson = true;
  }

  if (response.statusCode == 200) {
    if (isJson) {
      let json;
      try {
        json = JSON.parse(body);
      } catch(e) {
        reject(e);
        return;
      }
      resolve(json);
    } else {
      resolve(body);
    }
  } else {
    const err = "Received status " + response.statusCode + " from server";
    if (isJson) {
      let json;
      try {
        json = JSON.parse(body);
      } catch(e) {
        reject(new Error(err + ", but failed to parse JSON: " + body));
        return;
      }
      reject(new Error(err + ": " + json['error']));
    } else {
      reject(new Error(err + ": " + body));
    }
  }
}

async function get(url, api_key, query_params = {}) {
  const qs = querystring.stringify(query_params);
  let final_url = url;
  if (qs != '') {
    final_url += '?' + qs;
  }
  const options = {
    method: 'GET',
    auth: "api:" + api_key
  }

  const result = await new Promise((resolve, reject) => {
    let t;
    if (final_url.startsWith("http://")) {
      t = http;
    } else if (final_url.startsWith("https://")) {
      t = https;
    }
    const req = t.request(final_url, options, (res) => {
      res.setEncoding('utf8');
      const chunks = [];
      res.on('data', (chunk) => {
        chunks.push(chunk);
      });

      res.on('end', () => {
        const body = chunks.join('');
        process_response(res, body, resolve, reject);
      });
    });

    req.on('error', (e) => {
      reject(e);
    });

    req.end();
  }).catch((e) => (e));

  return result;
}

async function put(url, api_key, request_body = {}) {
  const request_body_str = JSON.stringify(request_body);
  const options = {
    method: 'PUT',
    auth: "api:" + api_key,
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': request_body_str.length
    }
  }

  const result = await new Promise((resolve, reject) => {
    let t;
    if (url.startsWith("http://")) {
      t = http;
    } else if (url.startsWith("https://")) {
      t = https;
    }
    const req = t.request(url, options, (res) => {
      res.setEncoding('utf8');
      const ct = res.headers['content-type'] || '';
      let isJson = false;
      if (ct.includes("application/json")) {
        isJson = true;
      }
      const chunks = []
      res.on('data', (chunk) => {
        chunks.push(chunk);
      });

      res.on('end', () => {
        const body = chunks.join('');
        process_response(res, body, resolve, reject);
      });
    });

    req.on('error', (e) => {
      reject(e);
    });

    req.write(request_body_str);
    req.end();
  }).catch((e) => (e));

  return result;
}

module.exports = {
  get: get,
  put: put
}
# 文件名 proxy_api.rb
require 'net/http
需要 'uri
需要 'json

类 ProxyAPIException < StandardError
结束

class RequestError < ProxyAPIException
结束

类 ResponseError < 代理 APIException
  attr_accessor :code
结束

类 ResponseParseError  e
      err = RequestError.new(e.message)
    结束

    raise err if err

    return process_response(response)
  结束

  def put(endpoint, body = {})
    endpoint = endpoint.gsub(/^\/+/, '/')
    if endpoint[0] != '/'
      endpoint = '/' + endpoint
    结束
    final_url = @base_url + endpoint
    uri = URI.parse(final_url)
    request = Net::HTTP::Put.new(uri)
    req_options = {
      use_ssl: uri.scheme == "https"、
    }
    request.basic_auth('api', @api_key)
    request['Content-Type'] = "application/json
    request.body = body.to_json

    响应 = nil
    err = nil
    开始
      response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
        response = http.request(request)
      结束
    救援 => e
      err = RequestError.new(e.message)
    结束

    raise err if err

    return process_response(response)
  结束

  私有

  def process_response(response)
    如果 response.code == '200'
      err = nil
      res = begin
        if is_json_response?(response)
          则 JSON.parse(response.body)
        否则
          响应正文
        结束
      救援 => e
        err = ResponseParseError.new(e.message)
      结束
      如果出现 err,则引发 err
      返回 res
    否则
      if is_json_response?(response)
        b = JSON.parse(response.body) 返回 nil
        如果 b
          ex = ResponseError.new("Received code #{response.code} from server: #{b['error']}")
          ex.code = response.code.to_i
          引发 ex
        否则
          ex = ResponseError.new("Received code #{response.code} from server, but failed to parse JSON: #{response.body}")
          ex.code = response.code.to_i
          引发 ex
        结束
      否则
        ex = ResponseError.new("Received code #{response.code} from server: #{response.body}")
        ex.code = response.code.to_i
        引发 ex
      结束
    结束
  结束

  def is_json_response?(response)
    response['Content-Type'].to_s.split(';').each do |part|
      如果 part == 'application/json' 则返回 true
    结束
    返回 false
  结束
结束
# 文件名 proxy_api.rb
require 'net/http
需要 'uri
需要 'json

类 ProxyAPIException < StandardError
结束

class RequestError < ProxyAPIException
结束

类 ResponseError < 代理 APIException
  attr_accessor :code
结束

类 ResponseParseError  e
      err = RequestError.new(e.message)
    结束

    raise err if err

    return process_response(response)
  结束

  def put(endpoint, body = {})
    endpoint = endpoint.gsub(/^\/+/, '/')
    if endpoint[0] != '/'
      endpoint = '/' + endpoint
    结束
    final_url = @base_url + endpoint
    uri = URI.parse(final_url)
    request = Net::HTTP::Put.new(uri)
    req_options = {
      use_ssl: uri.scheme == "https"、
    }
    request.basic_auth('api', @api_key)
    request['Content-Type'] = "application/json
    request.body = body.to_json

    响应 = nil
    err = nil
    开始
      response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
        response = http.request(request)
      结束
    救援 => e
      err = RequestError.new(e.message)
    结束

    raise err if err

    return process_response(response)
  结束

  私有

  def process_response(response)
    如果 response.code == '200'
      err = nil
      res = begin
        if is_json_response?(response)
          则 JSON.parse(response.body)
        否则
          响应正文
        结束
      救援 => e
        err = ResponseParseError.new(e.message)
      结束
      如果出现 err,则引发 err
      返回 res
    否则
      if is_json_response?(response)
        b = JSON.parse(response.body) 返回 nil
        如果 b
          ex = ResponseError.new("Received code #{response.code} from server: #{b['error']}")
          ex.code = response.code.to_i
          引发 ex
        否则
          ex = ResponseError.new("Received code #{response.code} from server, but failed to parse JSON: #{response.body}")
          ex.code = response.code.to_i
          引发 ex
        结束
      否则
        ex = ResponseError.new("Received code #{response.code} from server: #{response.body}")
        ex.code = response.code.to_i
        引发 ex
      结束
    结束
  结束

  def is_json_response?(response)
    response['Content-Type'].to_s.split(';').each do |part|
      如果 part == 'application/json' 则返回 true
    结束
    返回 false
  结束
结束

获取订阅列表

该端点允许获取所有订阅的列表。
终点 /package_subscriptions
方法 获取
参数
查询参数
JSON 参数
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -u api:08c5fa8dd63c8adc4b08803df5f68f9d https://app.privateproxy.me/api/v1/package_subscriptions

答复示例:

[
  {
    "id":8644、
    "类型": "Backconnect"、
    "包": "Backconnect 入门 (200K 请求)"、
    "活动":false
  },
  {
    "id":8643、
    "类型": "代理"、
    "package": "3 Private Proxies"、
    "活动":true
  }
]
从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.get("/package_subscriptions")
  pprint.PrettyPrinter(indent=2).pprint(result)
except ProxyAPIException as e:
  print(str(e))

答复示例:

[
  {
    "id":8644、
    "类型": "Backconnect"、
    "包": "Backconnect 入门 (200K 请求)"、
    "活动":false
  },
  {
    "id":8643、
    "类型": "代理"、
    "package": "3 Private Proxies"、
    "活动":true
  }
]
get("/package_subscriptions"));
} catch(ProxyAPIException $e) {
  echo $e;
}

答复示例:

[
  {
    "id":8644、
    "类型": "Backconnect"、
    "包": "Backconnect 入门 (200K 请求)"、
    "活动":false
  },
  {
    "id":8643、
    "类型": "代理"、
    "package": "3 Private Proxies"、
    "活动":true
  }
]
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.get('https://app.privateproxy.me/api/v1/package_subscriptions', '08c5fa8dd63c8adc4b08803df5f68f9d');
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
}

main();

答复示例:

[
  {
    "id":8644、
    "类型": "Backconnect"、
    "包": "Backconnect 入门 (200K 请求)"、
    "活动":false
  },
  {
    "id":8643、
    "类型": "代理"、
    "package": "3 Private Proxies"、
    "活动":true
  }
]
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.get("/package_subscriptions").inspect)
rescue ProxyAPIException => e
  puts e.message
结束

答复示例:

[
  {
    "id":8644、
    "类型": "Backconnect"、
    "包": "Backconnect 入门 (200K 请求)"、
    "活动":false
  },
  {
    "id":8643、
    "类型": "代理"、
    "package": "3 Private Proxies"、
    "活动":true
  }
]
主包

导入 (
  "编码/json"
  "fmt"
  "net/http"
)

类型 subscriptionEl struct {
  ID int `json: "id"`
  类型字符串 `json: "type"`
  Package string `json: "package"`
  活动 bool `json: "active"`
}

类型 subscriptionsList []*subscriptionEl

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  resp, isJSON, err := api.Get("/package_subscriptions", nil)
  if err != nil {
    fmt.Println(err)
  } else {
    if isJSON {
      var subscriptions subscriptionsList
      json.Unmarshal([]byte(resp), &subscriptions)
      for _, v := range subscriptions {
        fmt.Println(v)
      }
    } else {
      fmt.Println(resp)
    }
  }
}

答复示例:

[
  {
    "id":8644、
    "类型": "Backconnect"、
    "包": "Backconnect 入门 (200K 请求)"、
    "活动":false
  },
  {
    "id":8643、
    "类型": "代理"、
    "package": "3 Private Proxies"、
    "活动":true
  }
]

获取订阅

通过该端点,您可以获取特定的订购信息,如计费周期的开始和结束日期,或当前计费周期内 backconnect 套餐的请求数。
终点 /package_subscriptions/:id
方法 获取
参数 id - 订阅的 id
查询参数
JSON 参数
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -u api:08c5fa8dd63c8adc4b08803df5f68f9d https://app.privateproxy.me/api/v1/package_subscriptions/1

答复示例:

代理订阅 订阅 Backconnect
{
  "id":8643、
  "类型": "代理
  "目的": "谷歌"、
  "国家": "任何国家
  "ip_type": "proxy"、
  包": "3 个私人代理"、
  "price_cents":900、
  "billing_cycle_start":1599563902,
  "billing_cycle_end":1602155902,
  "last_invoice_amount_cents":900、
  "付款方式": "卡"、
  "IP_count":3
}
{
  "id":8644、
  "类型": "backconnect"、
  "目的": "谷歌"、
  "country": "Any"、
  "ip_type": "proxy"、
  "软件包": "Backconnect 初级(20 万次请求)"、
  "price_cents":5900、
  "billing_cycle_start":1599563939,
  "billing_cycle_end":1602155939,
  "last_invoice_amount_cents":5900、
  "付款方式": "卡"、
  "requests_limit":200000,
  "port_count":5、
  "connection_limit":1000,
  "billing_cycle_requests":15749
}

 

从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.get("/package_subscriptions/1")
  pprint.PrettyPrinter(indent=2).pprint(result)
except ProxyAPIException as e:
  print(str(e))

答复示例:

代理订阅 订阅 Backconnect
{
  "id":8643、
  "类型": "代理
  "目的": "谷歌"、
  "国家": "任何国家
  "ip_type": "proxy"、
  包": "3 个私人代理"、
  "price_cents":900、
  "billing_cycle_start":1599563902,
  "billing_cycle_end":1602155902,
  "last_invoice_amount_cents":900、
  "付款方式": "卡"、
  "IP_count":3
}
{
  "id":8644、
  "类型": "backconnect"、
  "目的": "谷歌"、
  "country": "Any"、
  "ip_type": "proxy"、
  "软件包": "Backconnect 初级(20 万次请求)"、
  "price_cents":5900、
  "billing_cycle_start":1599563939,
  "billing_cycle_end":1602155939,
  "last_invoice_amount_cents":5900、
  "付款方式": "卡"、
  "requests_limit":200000,
  "port_count":5、
  "connection_limit":1000,
  "billing_cycle_requests":15749
}
get("/package_subscriptions/1"));
} catch(ProxyAPIException $e) {
  echo $e;
}

答复示例:

代理订阅 订阅 Backconnect
{
  "id":8643、
  "类型": "代理
  "目的": "谷歌"、
  "国家": "任何国家
  "ip_type": "proxy"、
  包": "3 个私人代理"、
  "price_cents":900、
  "billing_cycle_start":1599563902,
  "billing_cycle_end":1602155902,
  "last_invoice_amount_cents":900、
  "付款方式": "卡"、
  "IP_count":3
}
{
  "id":8644、
  "类型": "backconnect"、
  "目的": "谷歌"、
  "country": "Any"、
  "ip_type": "proxy"、
  "软件包": "Backconnect 初级(20 万次请求)"、
  "price_cents":5900、
  "billing_cycle_start":1599563939,
  "billing_cycle_end":1602155939,
  "last_invoice_amount_cents":5900、
  "付款方式": "卡"、
  "requests_limit":200000,
  "port_count":5、
  "connection_limit":1000,
  "billing_cycle_requests":15749
}
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.get('https://app.privateproxy.me/api/v1/package_subscriptions/1', '08c5fa8dd63c8adc4b08803df5f68f9d');
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
}

main();

答复示例:

代理订阅 订阅 Backconnect
{
  "id":8643、
  "类型": "代理
  "目的": "谷歌"、
  "国家": "任何国家
  "ip_type": "proxy"、
  包": "3 个私人代理"、
  "price_cents":900、
  "billing_cycle_start":1599563902,
  "billing_cycle_end":1602155902,
  "last_invoice_amount_cents":900、
  "付款方式": "卡"、
  "IP_count":3
}
{
  "id":8644、
  "类型": "backconnect"、
  "目的": "谷歌"、
  "country": "Any"、
  "ip_type": "proxy"、
  "软件包": "Backconnect 初级(20 万次请求)"、
  "price_cents":5900、
  "billing_cycle_start":1599563939,
  "billing_cycle_end":1602155939,
  "last_invoice_amount_cents":5900、
  "付款方式": "卡"、
  "requests_limit":200000,
  "port_count":5、
  "connection_limit":1000,
  "billing_cycle_requests":15749
}
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.get("/package_subscriptions/1").inspect)
rescue ProxyAPIException => e
  puts e.message
结束

答复示例:

代理订阅 订阅 Backconnect
{
  "id":8643、
  "类型": "代理
  "目的": "谷歌"、
  "国家": "任何国家
  "ip_type": "proxy"、
  包": "3 个私人代理"、
  "price_cents":900、
  "billing_cycle_start":1599563902,
  "billing_cycle_end":1602155902,
  "last_invoice_amount_cents":900、
  "付款方式": "卡"、
  "IP_count":3
}
{
  "id":8644、
  "类型": "backconnect"、
  "目的": "谷歌"、
  "country": "Any"、
  "ip_type": "proxy"、
  "软件包": "Backconnect 初级(20 万次请求)"、
  "price_cents":5900、
  "billing_cycle_start":1599563939,
  "billing_cycle_end":1602155939,
  "last_invoice_amount_cents":5900、
  "付款方式": "卡"、
  "requests_limit":200000,
  "port_count":5、
  "connection_limit":1000,
  "billing_cycle_requests":15749
}
主包

导入 (
  "编码/json"
  "fmt"
  "net/http"
)

类型 订阅 结构 {
  ID int `json: "id"`
  类型字符串 `json: "type"`
  目的字符串 `json: "purpose"`
  国家字符串 `json: "country"`
  IPType string `json: "IP_type"`
  包装字符串 `json: "package"`
  PriceCents int `json: "price_cents"`
  BillingCycleStart uint64 `json: "billing_cycle_start"`
  BillingCycleEnd uint64 `json: "billing_cycle_end"`
  LastInvoiceAmountCents int `json: "last_invoice_amount_cents"`
  付款方式字符串 `json: "payment_method"`

  // 仅代理
  IPCount int `json: "IP_count"`

  // 仅反向连接
  RequestsLimit int `json: "requests_limit"`
  PortCount int `json: "port_count"`
  ConnectionLimit int `json: "connection_limit"`
  BillingCycleRequests int `json: "billing_cycle_requests"`
}

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  resp, isJSON, err := api.Get("/package_subscriptions/1", nil)
  if err != nil {
    fmt.Println(err)
  } else {
    if isJSON {
      子订阅
      json.Unmarshal([]byte(resp), &sub)
      fmt.Println(sub)
    } else {
      fmt.Println(resp)
    }
  }
}

答复示例:

代理订阅 订阅 Backconnect
{
  "id":8643、
  "类型": "代理
  "目的": "谷歌"、
  "国家": "任何国家
  "ip_type": "proxy"、
  包": "3 个私人代理"、
  "price_cents":900、
  "billing_cycle_start":1599563902,
  "billing_cycle_end":1602155902,
  "last_invoice_amount_cents":900、
  "付款方式": "卡"、
  "IP_count":3
}
{
  "id":8644、
  "类型": "backconnect"、
  "目的": "谷歌"、
  "country": "Any"、
  "ip_type": "proxy"、
  "软件包": "Backconnect 初级(20 万次请求)"、
  "price_cents":5900、
  "billing_cycle_start":1599563939,
  "billing_cycle_end":1602155939,
  "last_invoice_amount_cents":5900、
  "付款方式": "卡"、
  "requests_limit":200000,
  "port_count":5、
  "connection_limit":1000,
  "billing_cycle_requests":15749
}

IP/Port 列表

该端点允许获取软件包的代理/后连接网关 IP 列表。
终点 /package_subscriptions/:id/ips
方法 获取
参数 id - 订阅的 id
查询参数 hide_auth - 如果存在,从列表中隐藏证书
hide_port - 隐藏端口(仅限静态软件包)
端口 - 显示不同的端口,可用值为 2534、3389、5432 和 5433,默认值为 5432(仅限静态软件包)
JSON 参数
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -u api:08c5fa8dd63c8adc4b08803df5f68f9d https://app.privateproxy.me/api/v1/package_subscriptions/1/ips

答复示例:

无 hide_auth 使用 hide_auth
1.1.1.1:5432:login:password
2.2.2.2:5432:login:password
3.3.3.3:5432:login:password
1.1.1.1:5432
2.2.2.2:5432
3.3.3.3:5432

 

从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.get("/package_subscriptions/1/ips")
  pprint.PrettyPrinter(indent=2).pprint(result)
  result = api.get("/package_subscriptions/1/ips", query_params={'hide_auth': ''})
  pprint.PrettyPrinter(indent=2).pprint(result)
except ProxyAPIException as e:
  print(str(e))

答复示例:

无 hide_auth 使用 hide_auth
1.1.1.1:5432:login:password
2.2.2.2:5432:login:password
3.3.3.3:5432:login:password
1.1.1.1:5432
2.2.2.2:5432
3.3.3.3:5432
get("/package_subscriptions/1/ips"));
  var_dump($api->get("/package_subscriptions/1/ips", [
    "hide_auth" => ""
  ]));
} catch(ProxyAPIException $e) {
  echo $e;
}

答复示例:

无 hide_auth 使用 hide_auth
1.1.1.1:5432:login:password
2.2.2.2:5432:login:password
3.3.3.3:5432:login:password
1.1.1.1:5432
2.2.2.2:5432
3.3.3.3:5432
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.get('https://app.privateproxy.me/api/v1/package_subscriptions/1/ips', '08c5fa8dd63c8adc4b08803df5f68f9d');
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
  const res2 = await proxy_api.get('https://app.privateproxy.me/api/v1/package_subscriptions/1/ips', '08c5fa8dd63c8adc4b08803df5f68f9d', {
    "hide_auth":""
  });
  if (res2 instanceof Error) {
    console.log("Error:")+ res2.toString());
  } else {
    console.log(res2);
  }
}

main();

答复示例:

无 hide_auth 使用 hide_auth
1.1.1.1:5432:login:password
2.2.2.2:5432:login:password
3.3.3.3:5432:login:password
1.1.1.1:5432
2.2.2.2:5432
3.3.3.3:5432
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.get("/package_subscriptions/1/ips").inspect)
  puts(api.get("/package_subscriptions/1/ips", hide_auth: '').inspect)
rescue ProxyAPIException => e
  puts e.message
结束

答复示例:

无 hide_auth 使用 hide_auth
1.1.1.1:5432:login:password
2.2.2.2:5432:login:password
3.3.3.3:5432:login:password
1.1.1.1:5432
2.2.2.2:5432
3.3.3.3:5432
主包

导入 (
  "fmt"
  "net/http"
)

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  resp, _, err := api.Get("/package_subscriptions/1/ips", nil)
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(resp)
  }

  resp,_,err = api.Get("/package_subscriptions/1/ips",map[string]string{"hide_auth": ""})
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(resp)
  }
}

答复示例:

无 hide_auth 使用 hide_auth
1.1.1.1:5432:login:password
2.2.2.2:5432:login:password
3.3.3.3:5432:login:password
1.1.1.1:5432
2.2.2.2:5432
3.3.3.3:5432

获取订阅设置

该端点允许获取软件包的特定设置,如授权 ips 和交换间隔(用于 backconnect)。
终点 /package_subscriptions/:id/settings
方法 获取
参数 id - 订阅的 id
查询参数
JSON 参数
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -u api:08c5fa8dd63c8adc4b08803df5f68f9d https://app.privateproxy.me/api/v1/package_subscriptions/1/settings

答复示例:

代理订阅 订阅 Backconnect
{
  "authorized_ips":[
    "15.25.5.11"
  ]
}
{
  "authorized_ips":[
    "15.25.5.11",
    "1.1.1.1"
  ],
  "swap_interval":120
}
从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.get("/package_subscriptions/1/settings")
  pprint.PrettyPrinter(indent=2).pprint(result)
except ProxyAPIException as e:
  print(str(e))

答复示例:

代理订阅 订阅 Backconnect
{
  "authorized_ips":[
    "15.25.5.11"
  ]
}
{
  "authorized_ips":[
    "15.25.5.11",
    "1.1.1.1"
  ],
  "swap_interval":120
}
get("/package_subscriptions/1/settings"));
} catch(ProxyAPIException $e) {
  echo $e;
}

答复示例:

代理订阅 订阅 Backconnect
{
  "authorized_ips":[
    "15.25.5.11"
  ]
}
{
  "authorized_ips":[
    "15.25.5.11",
    "1.1.1.1"
  ],
  "swap_interval":120
}
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.get('https://app.privateproxy.me/api/v1/package_subscriptions/1/settings', '08c5fa8dd63c8adc4b08803df5f68f9d');
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
}

main();

答复示例:

代理订阅 订阅 Backconnect
{
  "authorized_ips":[
    "15.25.5.11"
  ]
}
{
  "authorized_ips":[
    "15.25.5.11",
    "1.1.1.1"
  ],
  "swap_interval":120
}
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.get("/package_subscriptions/1/settings").inspect)
rescue ProxyAPIException => e
  puts e.message
结束

答复示例:

代理订阅 订阅 Backconnect
{
  "authorized_ips":[
    "15.25.5.11"
  ]
}
{
  "authorized_ips":[
    "15.25.5.11",
    "1.1.1.1"
  ],
  "swap_interval":120
}
主包

导入 (
  "编码/json"
  "fmt"
  "net/http"
)

类型 packageSettings struct {
  授权 IPs []string `json: "authorized_ips"`

  //仅回连
  交换间隔 int `json: "swap_interval"`
}

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  resp, _, err := api.Get("/package_subscriptions/1/settings", nil)
  if err != nil {
    fmt.Println(err)
  } else {
    var ps packageSettings
    json.Unmarshal([]byte(resp), &ps)
    fmt.Println(ps)
  }
}

答复示例:

代理订阅 订阅 Backconnect
{
  "authorized_ips":[
    "15.25.5.11"
  ]
}
{
  "authorized_ips":[
    "15.25.5.11",
    "1.1.1.1"
  ],
  "swap_interval":120
}

设置订阅设置

该端点允许设置软件包的特定设置,如授权 ips 或交换间隔(用于 backconnect)。
终点 /package_subscriptions/:id
方法 输入
必要的 HTTP 标头 Content-Type: 应用程序/json
参数 id - 订阅的 id
查询参数
JSON 参数 authorized_ips - 列表 - 允许无凭证访问代理的授权 IP 地址
swap_interval - 整数 >= 0 - 为反向连接代理更换 IP 的频率,0 表示每次请求都更换。普通代理软件包忽略不计。
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -X PUT -H "Content-Type: application/json" -u api:08c5fa8dd63c8adc4b08803df5f68f9d --data '{"swap_interval":180, "authorized_ips":["1.1.1.1"]}' https://app.privateproxy.me/api/v1/package_subscriptions/1

成功时 {"success":true}将返回 JSON 文件,错误时,哈希值中的 success 将为 false,error 将包含任何错误:

{
  "success": false、
  "error":"Authorized ips contain invalid IP 441.2.3.4 on line 1, Swap interval must be greater than or equal to 0" (授权的 ips 在第 1 行包含无效 IP 441.2.3.4,交换间隔必须大于或等于 0)
}
从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.put("/package_subscriptions/1", body = {'swap_interval': 180, 'authorized_ips':['1.2.3.4', '2.5.6.7']})
  print(result)
  result = api.put("/package_subscriptions/1", body = {'swap_interval': -180, 'authorized_ips':['441.2.3.4']})
  print(result)
except ProxyAPIException as e:
  print(str(e))

成功时 {"success":true}将返回 JSON 文件,错误时,哈希值中的 success 将为 false,error 将包含任何错误:

{
  "success": false、
  "error":"Authorized ips contain invalid IP 441.2.3.4 on line 1, Swap interval must be greater than or equal to 0" (授权的 ips 在第 1 行包含无效 IP 441.2.3.4,交换间隔必须大于或等于 0)
}
put("/package_subscriptions/1", [
    "authorized_ips" => ["1.5.4.4", "1.5.6.7"]、
    "swap_interval" => 3600
  ]));
  var_dump($api->put("/package_subscriptions/1", [
    "authorized_ips" => ["1.5.4.444", "1.5.6.7"]、
    "swap_interval" => -3600
  ]));
} catch(ProxyAPIException $e) {
  echo $e;
}

成功时 {"success":true}将返回 JSON 文件,错误时,哈希值中的 success 将为 false,error 将包含任何错误:

{
  "success": false、
  "error":"Authorized ips contain invalid IP 441.2.3.4 on line 1, Swap interval must be greater than or equal to 0" (授权的 ips 在第 1 行包含无效 IP 441.2.3.4,交换间隔必须大于或等于 0)
}
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.put(
    'https://app.privateproxy.me/api/v1/package_subscriptions/1'、
    '08c5fa8dd63c8adc4b08803df5f68f9d',
    {
      "authorized_ips":["77.66.55.44", "1.87.31.3"],
      "swap_interval":1200
    }
  );
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
}

main();

成功时 {"success":true}将返回 JSON 文件,错误时,哈希值中的 success 将为 false,error 将包含任何错误:

{
  "success": false、
  "error":"Authorized ips contain invalid IP 441.2.3.4 on line 1, Swap interval must be greater than or equal to 0" (授权的 ips 在第 1 行包含无效 IP 441.2.3.4,交换间隔必须大于或等于 0)
}
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.put("/package_subscriptions/1", authorized_ips: ['1.2.3.2'], swap_interval: 30).inspect)
  puts(api.put("/package_subscriptions/1", authorized_ips:[412.2.3.2'], swap_interval: -30).inspect)
rescue ProxyAPIException => e
  puts e.message
结束

成功时 {"success":true}将返回 JSON 文件,错误时,哈希值中的 success 将为 false,error 将包含任何错误:

{
  "success": false、
  "error":"Authorized ips contain invalid IP 441.2.3.4 on line 1, Swap interval must be greater than or equal to 0" (授权的 ips 在第 1 行包含无效 IP 441.2.3.4,交换间隔必须大于或等于 0)
}
主包

导入 (
  "fmt"
  "net/http"
  "字符串
)

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  ips := strings.Join([]string{"1.2.3.1", "1.3.1.2", "1.1.1.1"}, "\",\"")
  settings := fmt.Sprintf("{\"authorized_ips\": [\"%s\"], \"swap_interval\": 4242}", ips)

  resp, _, err := api.Put("/package_subscriptions/1", settings)
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(resp)
  }

  ips = strings.Join([]string{"1.2.3.1", "1.3.1.2", "1.1.1.1000"}, "\",\"")
  settings = fmt.Sprintf("{\"authorized_ips\": [\"%s\"], \"swap_interval\": -4242}", ips)

  resp, _, err = api.Put("/package_subscriptions/1", settings)
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(resp)
  }
}

成功时 {"success":true}将返回 JSON 文件,错误时,哈希值中的 success 将为 false,error 将包含任何错误:

{
  "success": false、
  "error":"Authorized ips contain invalid IP 441.2.3.4 on line 1, Swap interval must be greater than or equal to 0" (授权的 ips 在第 1 行包含无效 IP 441.2.3.4,交换间隔必须大于或等于 0)
}

添加授权 IP

该端点允许在授权 IP 列表中添加新的授权 IP,而不会为了方便而列出所有 IP。
终点 /package_subscriptions/:id/add_authorized_ip
方法 输入
必要的 HTTP 标头 Content-Type: 应用程序/json
参数 id - 订阅的 id
查询参数
JSON 参数 ip - 字符串 - 要添加的 IP 地址
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -X PUT -H "Content-Type: application/json" -u api:08c5fa8dd63c8adc4b08803df5f68f9d --data '{"ip":"1.1.1.1"}' https://app.privateproxy.me/api/v1/package_subscriptions/1/add_authorized_ip
从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.put("/package_subscriptions/1/add_authorized_ip", body = {'ip': '121.23.1.25'})
  print(result)
  result = api.put("/package_subscriptions/1/add_authorized_ip", body = {'ip': '266.1.2.3'})
  print(result)
except ProxyAPIException as e:
  print(str(e))
put("/package_subscriptions/1/add_authorized_ip", [
    "ip" => "7.7.7.7" [ "ip" => "7.7.7.7"
  ]));
} catch(ProxyAPIException $e) {
  echo $e;
}
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.put(
    'https://app.privateproxy.me/api/v1/package_subscriptions/1/add_authorized_ip'、
    '08c5fa8dd63c8adc4b08803df5f68f9d',
    {
      "ip":"1.2.3.4"
    }
  );
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
}

main();
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.put("/package_subscriptions/1/add_authorized_ip", ip: '1.2.3.2').inspect)
  puts(api.put("/package_subscriptions/1/add_authorized_ip", ip: '412.2.3.2').inspect)
rescue ProxyAPIException => e
  puts e.message
结束
主包

导入 (
  "fmt"
  "net/http"
)

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  ip := "{\"ip\":\"1.7.2.5\"}"
  resp, _, err := api.Put("/package_subscriptions/1/add_authorized_ip", ip)
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(resp)
  }
}

删除授权 IP

为方便起见,该端点允许删除授权 IP,而无需列出所有 IP。如果没有提供 IP,该端点将返回错误信息,否则即使没有删除 IP,也会成功删除。
终点 /package_subscriptions/:id/remove_authorized_ip
方法 输入
必要的 HTTP 标头 Content-Type: 应用程序/json
参数 id - 订阅的 id
查询参数
JSON 参数 ip - 字符串 - 要删除的 IP 地址
在 *nix shell 中使用 curlPython 3 + 请求PHP + libcurlNode.js + stdlibRuby + stdlibGolang + stdlib
curl -X PUT -H "Content-Type: application/json" -u api:08c5fa8dd63c8adc4b08803df5f68f9d --data '{"ip":"1.1.1.1"}' https://app.privateproxy.me/api/v1/package_subscriptions/1/remove_authorized_ip
从 proxy_api 导入 *

api = ProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
try:
  result = api.put("/package_subscriptions/1/remove_authorized_ip", body = {'ip':'121.23.1.25'})
  print(result)
except ProxyAPIException as e:
  print(str(e))
put("/package_subscriptions/1/remove_authorized_ip", [
    "ip" => "7.7.7.7" [ "ip" => "7.7.7.7"
  ]));
} catch(ProxyAPIException $e) {
  echo $e;
}
const proxy_api = require('./proxy_api');

async 函数 main() {
  const res = await proxy_api.put(
    'https://app.privateproxy.me/api/v1/package_subscriptions/1/remove_authorized_ip'、
    '08c5fa8dd63c8adc4b08803df5f68f9d',
    {
      "ip":"1.2.3.4"
    }
  );
  if (res instanceof Error) {
    console.log("Error:")+ res.toString());
  } else {
    console.log(res);
  }
}

main();
require_relative './proxy_api

开始
  api = ProxyAPI.new("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d")
  puts(api.put("/package_subscriptions/1/add_authorized_ip", ip: '11.22.33.212').inspect)
rescue ProxyAPIException => e
  puts e.message
结束
主包

导入 (
  "fmt"
  "net/http"
)

func main() {
  api := NewProxyAPI("https://app.privateproxy.me/api/v1", "08c5fa8dd63c8adc4b08803df5f68f9d", &http.Client{})

  ip := "{\"ip\":\"1.7.2.5\"}"
  resp, _, err := api.Put("/package_subscriptions/1/remove_authorized_ip", ip)
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(resp)
  }
}

Last Updated on 2 月 22, 2023

您推荐代理服务吗?

点击奖杯即可颁奖!

平均评分 0 /5.计票: 0

目前没有投票!成为第一个给本帖评分的人。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

zh_CNChinese
滚动到顶部