跳到内容
royalproxy

代理 API 参考

控制台中对订单的操作,也可以用代码完成。API 可以返回余额和代理登录信息、价格和国家,接受从余额支付的订单,并生成带参数的用户名。

快速开始

  1. 1创建账户并登录控制台。
  2. 2在“连接”中创建 API 密钥。完整密钥只显示一次,请立即保存。
  3. 3在每个需要密钥的请求的 Authorization 请求头中填入密钥。
  4. 4调用 /account 确认密钥可用,然后用 /orders 购买。

认证

与您账户相关的接口(account、orders、proxy-user)需要 API 密钥,以 Bearer 令牌形式放在 Authorization 请求头中发送。价格、国家和报价是公开接口,不需要密钥。

我们只保存密钥的哈希值。如果密钥丢失,请在控制台创建新密钥,旧密钥会立即失效。切勿把密钥放在浏览器端代码或公开代码仓库中。

HTTP header
Authorization: Bearer rpk_your_api_key

基础 URL 和数据格式

基础 URL
https://royalproxy.online/api/v1
请求和响应正文
application/json
金额
金额以 USD 计,为数字,例如 807.90
时间
ISO 8601 (UTC)

频率限制

每个 API 密钥每分钟可发送 60 个请求,公开接口每个 IP 每分钟 60 个。超出时返回 HTTP 429,请等待一分钟后重试。

错误响应

出错时会返回 HTTP 状态码,以及包含简短错误代码和说明信息的 JSON 正文。

示例
{
  "error": {
    "code": "insufficient_balance",
    "message": "Your balance is too low for this order. Top up in the dashboard."
  }
}
code
bad_requestHTTP 400缺少必填值,或某个值对该产品无效。
unauthorizedHTTP 401没有发送 API 密钥,或密钥无效。
insufficient_balanceHTTP 402订单金额超过您的余额。未扣款。
not_foundHTTP 404您的账户中没有此 id 的订单。
rate_limitedHTTP 429已达到每分钟请求上限。
server_errorHTTP 500我们这边出现故障。未扣款。

接口

账户信息

GET/api/v1/accountAPI 密钥

您的余额、代理主机和端口、代理用户名和密码,以及白名单 IP。

请求
curl https://royalproxy.online/api/v1/account \
  -H "Authorization: Bearer rpk_your_api_key"
响应
{
  "username": "royal_user",
  "balance_usd": 1300,
  "proxy": {
    "host": "gate.royalproxy.online",
    "http_port": 6100,
    "socks5_port": 6200,
    "username": "rpexample1",
    "password": "your_password"
  },
  "allowed_ips": [
    "203.0.113.10"
  ]
}

产品和价格

GET/api/v1/products无需密钥

所有产品的数量限制、价格档位和折扣,与价格页面读取同一张价格表。

请求
curl https://royalproxy.online/api/v1/products
响应
{
  "currency": "USD",
  "prices_as_of": "2026-11-28",
  "products": [
    {
      "id": "unlimited",
      "unit": "day",
      "quantity": {
        "meaning": "days",
        "min": 1,
        "max": 365
      },
      "...": "..."
    },
    {
      "id": "residential",
      "unit": "gb",
      "...": "..."
    }
  ]
}

国家和城市

GET/api/v1/countries无需密钥

某个产品可用的国家,以及写入代理用户名的城市值。

字段含义
product可选residential、unlimited、isp、datacenter 之一。默认为 residential。
请求
curl "https://royalproxy.online/api/v1/countries?product=datacenter"
响应
{
  "product": "datacenter",
  "countries": [
    {
      "code": "us",
      "name": "United States",
      "region": "americas",
      "datacenter": true,
      "cities": [
        {
          "name": "New York",
          "value": "new_york"
        },
        {
          "name": "Los Angeles",
          "value": "los_angeles"
        }
      ]
    }
  ]
}

订单报价

POST/api/v1/quote无需密钥

计算订单总价,不扣任何费用。请求正文与下单时相同。

字段含义
product必填residential、unlimited、isp、datacenter 之一。
quantity必填residential 为 GB 数(5~5,000),unlimited 为天数(1~365),isp 为 IP 数(1~1,000),datacenter 为 IP 数(5~5,000)。
concurrency可选仅用于 unlimited:200、500、1000 或 2000。
bandwidth可选仅用于 unlimited,单位 Mbps:100、200、500 或 1000。
months可选仅用于 isp 和 datacenter:1、3、6 或 12。
country可选仅用于 isp 和 datacenter:两位字母代码,例如 jp。有效代码来自 /countries。
请求
curl -X POST https://royalproxy.online/api/v1/quote \
  -H "Content-Type: application/json" \
  -d '{"product":"unlimited","quantity":30,"concurrency":1000,"bandwidth":200}'
响应
{
  "product": "unlimited",
  "quantity": 30,
  "unit_price_usd": 6.97,
  "unit": "day",
  "total_usd": 209.1
}

创建订单

POST/api/v1/ordersAPI 密钥

从余额中扣除总价并创建订单。订单初始状态为 pending(开通中),准备好后变为 active。如果开通失败,状态变为 refunded,全部金额退回余额。余额不足时返回 402。

字段含义
product必填residential、unlimited、isp、datacenter 之一。
quantity必填residential 为 GB 数(5~5,000),unlimited 为天数(1~365),isp 为 IP 数(1~1,000),datacenter 为 IP 数(5~5,000)。
concurrency可选仅用于 unlimited:200、500、1000 或 2000。
bandwidth可选仅用于 unlimited,单位 Mbps:100、200、500 或 1000。
months可选仅用于 isp 和 datacenter:1、3、6 或 12。
country可选仅用于 isp 和 datacenter:两位字母代码,例如 jp。有效代码来自 /countries。
请求
curl -X POST https://royalproxy.online/api/v1/orders \
  -H "Authorization: Bearer rpk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"product":"unlimited","quantity":30,"concurrency":1000,"bandwidth":200}'
响应
{
  "order": {
    "id": "RP-7KQ2M-X4HTD",
    "product": "unlimited",
    "quantity": 30,
    "months": null,
    "concurrency": 1000,
    "bandwidth_mbps": 200,
    "country": null,
    "unit_price_usd": 6.97,
    "total_usd": 209.1,
    "status": "pending",
    "created_at": "2026-10-31T09:12:44.120Z",
    "updated_at": "2026-10-31T09:12:44.120Z"
  },
  "balance_usd": 1090.9
}

您的订单

GET/api/v1/ordersAPI 密钥

您账户中最近的 100 个订单,最新的在前。

字段含义
status可选pending、active 或 refunded。省略则列出全部。
请求
curl "https://royalproxy.online/api/v1/orders?status=pending" \
  -H "Authorization: Bearer rpk_your_api_key"
响应
{
  "orders": [
    {
      "id": "RP-7KQ2M-X4HTD",
      "product": "unlimited",
      "quantity": 30,
      "months": null,
      "concurrency": 1000,
      "bandwidth_mbps": 200,
      "country": null,
      "unit_price_usd": 6.97,
      "total_usd": 209.1,
      "status": "pending",
      "created_at": "2026-10-31T09:12:44.120Z",
      "updated_at": "2026-10-31T09:12:44.120Z"
    }
  ]
}

单个订单

GET/api/v1/orders/{id}API 密钥

按 id 查询单个订单,方便确认是否已开通。

字段含义
id必填订单 id,例如 RP-7KQ2M-X4HTD。
请求
curl https://royalproxy.online/api/v1/orders/RP-7KQ2M-X4HTD \
  -H "Authorization: Bearer rpk_your_api_key"
响应
{
  "order": {
    "id": "RP-7KQ2M-X4HTD",
    "product": "unlimited",
    "quantity": 30,
    "months": null,
    "concurrency": 1000,
    "bandwidth_mbps": 200,
    "country": null,
    "unit_price_usd": 6.97,
    "total_usd": 209.1,
    "status": "active",
    "created_at": "2026-10-31T09:12:44.120Z",
    "updated_at": "2026-10-31T09:40:02.511Z"
  }
}

代理用户名生成

GET/api/v1/proxy-userAPI 密钥

根据您的参数生成代理用户名,并返回可直接使用的 HTTP 和 SOCKS5 代理 URL。session 留空时,IP 按请求轮换。

字段含义
product可选residential、unlimited、isp、datacenter 之一。默认为 unlimited。
country可选两位字母国家代码,例如 jp。
city可选来自 /countries 的城市值,例如 tokyo。需要同时填写 country。
session可选1~32 位字母或数字。共用同一 session 的请求保持同一个 IP。
ttl可选会话保持 IP 的分钟数,1~60。默认为 30。
请求
curl "https://royalproxy.online/api/v1/proxy-user?product=residential&country=jp&city=tokyo&session=job42&ttl=30" \
  -H "Authorization: Bearer rpk_your_api_key"
响应
{
  "username": "rpexample1-zone-res-cc-jp-city-tokyo-sid-job42-ttl-30",
  "password": "your_password",
  "http": "http://rpexample1-zone-res-cc-jp-city-tokyo-sid-job42-ttl-30:your_password@gate.royalproxy.online:6100",
  "socks5": "socks5h://rpexample1-zone-res-cc-jp-city-tokyo-sid-job42-ttl-30:your_password@gate.royalproxy.online:6200"
}

完整示例

报价、从余额购买,并通过日本 IP 发送请求。

Python (requests)
import requests

API = "https://royalproxy.online/api/v1"
HEAD = {"Authorization": "Bearer rpk_your_api_key"}

# 1) Check the price first
plan = {"product": "residential", "quantity": 100}
print(requests.post(f"{API}/quote", json=plan).json())

# 2) Order from your balance
r = requests.post(f"{API}/orders", json=plan, headers=HEAD)
order = r.json()["order"]
print(order["id"], order["status"])

# 3) Get a username for Japanese IPs
u = requests.get(f"{API}/proxy-user", headers=HEAD,
                 params={"product": "residential", "country": "jp"}).json()
proxies = {"http": u["http"], "https": u["http"]}
print(requests.get("https://ipinfo.io/json", proxies=proxies, timeout=30).json())
Node.js 18+
const API = "https://royalproxy.online/api/v1";
const HEAD = { Authorization: "Bearer rpk_your_api_key", "Content-Type": "application/json" };

// Check the balance
const acc = await fetch(`${API}/account`, { headers: HEAD }).then((r) => r.json());
console.log(acc.balance_usd);

// Order 7 days of unlimited
const res = await fetch(`${API}/orders`, {
  method: "POST",
  headers: HEAD,
  body: JSON.stringify({ product: "unlimited", quantity: 7, concurrency: 500, bandwidth: 100 }),
});
if (res.status === 402) console.log("Top up first");
else console.log((await res.json()).order.id);

API 订单与控制台订单相同,会显示在“记录”中。请把 rpk_your_api_key 换成您真实的密钥。

在您自己的代码中使用 RoyalProxy

注册后,在控制台创建 API 密钥。