如何开始?
- 1注册并登录控制台。
- 2打开“连接”页面,创建 API 密钥。完整密钥只显示一次,请复制到安全的地方。
- 3在每个需要认证的请求中,通过 Authorization 请求头发送密钥。
- 4调用 /account 确认密钥可用,然后用 /orders 下单。
如何认证?
涉及您自己账户的请求(account、orders、proxy-user)需要 API 密钥。请在 Authorization 请求头中以 Bearer 令牌的形式发送。价格、国家和报价是公开接口,无需密钥。
我们只保存密钥的哈希值。如果丢失,请在控制台创建新密钥,旧密钥会立即失效。不要把密钥放在浏览器端代码或公开代码仓库中。
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."
}
}| HTTP | code | 含义 |
|---|---|---|
| bad_requestHTTP 400缺少某个值,或该值不适用于此产品。 | 缺少某个值,或该值不适用于此产品。 | |
| unauthorizedHTTP 401API 密钥缺失或无效。 | API 密钥缺失或无效。 | |
| insufficient_balanceHTTP 402余额低于订单总额。未产生任何扣费。 | 余额低于订单总额。未产生任何扣费。 | |
| not_foundHTTP 404您的账户中没有此 id 的订单。 | 您的账户中没有此 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-10-31",
"products": [
{
"id": "unlimited",
"unit": "day",
"quantity": {
"meaning": "days",
"min": 1,
"max": 365
},
"...": "..."
},
{
"id": "residential",
"unit": "gb",
"...": "..."
}
]
}国家和城市列表
GET/api/v1/countries无需密钥
返回某个产品可用的国家,以及可以写入代理用户名的城市值。
| 字段 | 类型 | 含义 |
|---|---|---|
product可选 | string | unlimited、residential、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必填 | string | unlimited、residential、isp 或 datacenter。 |
quantity必填 | integer | unlimited 为天数(1~365),residential 为 GB(5~5,000),isp 为 IP 数(1~1,000),datacenter 为 IP 数(5~5,000)。 |
concurrency可选 | integer | 仅限 unlimited:200、500、1000 或 2000。 |
bandwidth可选 | integer | 仅限 unlimited,单位 Mbps:100、200、500 或 1000。 |
months可选 | integer | 仅限 isp 和 datacenter:1、3、6 或 12。 |
country可选 | string | 仅限 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": 8.97,
"unit": "day",
"total_usd": 269.1
}下单
POST/api/v1/ordersAPI 密钥
从余额中扣除总额并创建订单。新订单初始状态为 pending(开通中),就绪后变为 active。如果订单无法开通,状态变为 refunded,全部金额退回余额。余额不足时返回 402。
| 字段 | 类型 | 含义 |
|---|---|---|
product必填 | string | unlimited、residential、isp 或 datacenter。 |
quantity必填 | integer | unlimited 为天数(1~365),residential 为 GB(5~5,000),isp 为 IP 数(1~1,000),datacenter 为 IP 数(5~5,000)。 |
concurrency可选 | integer | 仅限 unlimited:200、500、1000 或 2000。 |
bandwidth可选 | integer | 仅限 unlimited,单位 Mbps:100、200、500 或 1000。 |
months可选 | integer | 仅限 isp 和 datacenter:1、3、6 或 12。 |
country可选 | string | 仅限 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": 8.97,
"total_usd": 269.1,
"status": "pending",
"created_at": "2026-10-31T09:12:44.120Z",
"updated_at": "2026-10-31T09:12:44.120Z"
},
"balance_usd": 1030.9
}列出您的订单
GET/api/v1/ordersAPI 密钥
返回最近 100 个订单,最新的在前。
| 字段 | 类型 | 含义 |
|---|---|---|
status可选 | string | 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": 8.97,
"total_usd": 269.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必填 | string | 订单 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": 8.97,
"total_usd": 269.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可选 | string | unlimited、residential、isp 或 datacenter。默认为 unlimited。 |
country可选 | string | 两位国家代码,例如 jp。 |
city可选 | string | /countries 中的城市值,例如 tokyo。需同时填写 country。 |
session可选 | string | 任意 1~32 位字母或数字。session 相同的请求使用同一个 IP。 |
ttl可选 | integer | 会话 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 连接。
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())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 换成您自己的密钥。