充值
文档充值

充值(Top-up)

使用钱包余额为活跃的代理套餐添加 GB,并查看该套餐过去的充值记录。

POST /packages/{id}/top-up

从钱包余额扣款并向套餐添加请求的流量(整数 GB)。计价沿用与原购买相同的批量阶梯。成功时套餐配额立即增长,流量在同一请求中在上游提供商完成配置。

仅支持钱包余额支付

此端点要求由钱包余额全额承担费用。余额不足返回 402 且无副作用。如需购买新套餐或用加密货币 / Stripe 充值钱包,请使用网页结算。 Billing · Buy.

POST/api/v1/packages/{id}/top-up
request.json
{ "quantity_gb": 25 }
response.json
{
  "data": {
    "order_id":            8421,
    "traffic_added_gb":    25,
    "new_quota_gb":        125.0,
    "amount_charged_usd":  42.25,
    "balance_usd":         157.7500
  },
  "meta": { "version": "v1" }
}
402.json
{
  "error": { "code": "payment_required", "message": "Insufficient balance" },
  "meta":  { "version": "v1" }
}

GET /packages/{id}/top-ups

返回该套餐过去的充值记录,最新优先。limit 与 offset 用于分页;默认 50 与 0。

GET/api/v1/packages/{id}/top-ups?limit=50&offset=0
history.json
{
  "data": {
    "package_id": 12,
    "limit":      50,
    "offset":     0,
    "top_ups": [
      { "order_id": 8421, "traffic_gb": 25.0, "amount_usd": 42.25, "paid_at": "2026-05-29T11:00:00+00:00" },
      { "order_id": 8127, "traffic_gb": 10.0, "amount_usd": 16.90, "paid_at": "2026-05-15T08:32:00+00:00" }
    ]
  },
  "meta": { "version": "v1" }
}

代码示例

topup.sh
curl -X POST https://raxyproxy.com/api/v1/packages/12/top-up \
     -H "Authorization: Bearer raxy_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     -H "Content-Type: application/json" \
     -d '{"quantity_gb": 25}'

# History (paginated)
curl "https://raxyproxy.com/api/v1/packages/12/top-ups?limit=20&offset=0" \
     -H "Authorization: Bearer raxy_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
topup.py
import requests, sys

API_KEY    = 'raxy_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
PACKAGE_ID = 12

# Top up by 10 GB; on insufficient balance the call returns 402
r = requests.post(
    f'https://raxyproxy.com/api/v1/packages/{PACKAGE_ID}/top-up',
    headers={'Authorization': f'Bearer {API_KEY}'},
    json={'quantity_gb': 10},
    timeout=15,
)

if r.status_code == 402:
    sys.exit('Wallet balance too low — top up your wallet via the web app first.')

r.raise_for_status()
data = r.json()['data']
print(f"Now {data['new_quota_gb']} GB quota; balance left $${data['balance_usd']:.2f}")