返回首页

API 文档

Proxy Pool RESTful API 接口说明

Base URL

https://your-domain.com

统计接口

GET /api/stats

获取代理池统计信息,包括总数、高速匿名数量、普通代理数量、检测状态等。

响应示例
JSON
{
  "total": 45000,
  "alive": 42000,
  "elite": 35000,
  "normal": 7000,
  "countries": ["US", "CN", "DE", ...],
  "protocols": ["http", "socks5", ...],
  "checking": false,
  "lastCheckTime": "2024-01-01T12:00:00Z"
}
调用示例
cURL
curl -X GET "https://your-domain.com/api/stats"
Python
import requests

response = requests.get("https://your-domain.com/api/stats")
data = response.json()
print(f"总代理数: {data['total']}")
print(f"高速匿名: {data['elite']}")

代理列表接口

GET /api/proxies

获取代理列表,支持按国家、协议、匿名度筛选。

请求参数
参数 类型 必填 说明
country string 否 国家代码,如 US、CN、DE
protocol string 否 协议类型:http、https、socks4、socks5
anonymity string 否 匿名度:elite、anonymous、transparent
调用示例
cURL
# 获取所有代理
curl "https://your-domain.com/api/proxies"

# 获取美国的 SOCKS5 代理
curl "https://your-domain.com/api/proxies?country=US&protocol=socks5"
GET /api/elite

获取高速匿名代理列表。这些代理经过存活检测,速度快且匿名性高。

请求参数
参数 类型 必填 说明
protocol string 否 协议筛选
limit string 否 数量限制,或 "all" 获取全部
调用示例
Python
import requests

# 获取所有高速匿名代理
response = requests.get("https://your-domain.com/api/elite?limit=all")
proxies = response.json()["data"]

for proxy in proxies[:10]:
    print(f"{proxy['ip']}:{proxy['port']}")
GET /api/normal

获取普通代理列表。

调用示例
cURL
curl "https://your-domain.com/api/normal?limit=100"
GET /api/china

获取中国代理分组。CN 节点不会进入高速匿名或普通代理分组。

cURL
curl "https://your-domain.com/api/china?limit=100"
GET /api/proxyscrape

获取通过提交接口加入的 proxyscrape 分组。

cURL
curl "https://your-domain.com/api/proxyscrape?limit=100"

提交接口

POST /api/proxyscrape

使用 Bearer Token 提交代理。支持 JSON 数组或换行分隔的 content。

cURL
curl -X POST "https://your-domain.com/api/proxyscrape" \
  -H "Authorization: Bearer YOUR_SUBMIT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"1.2.3.4:8080\nsocks5://5.6.7.8:1080"}'

导出接口

GET /api/export

导出代理列表,支持 TXT 和 JSON 格式,可按协议、速度筛选。

请求参数
参数 类型 必填 说明
protocol string 否 http、https、socks4、socks5
speed string 否 fast、good、slow
limit string 否 数量或 "all"
format string 否 txt (默认) 或 json
调用示例
cURL
# 导出所有 HTTP 代理 (TXT 格式)
curl "https://your-domain.com/api/export?protocol=http&limit=all" -o http_proxies.txt

# 导出快速 SOCKS5 代理 (JSON 格式)
curl "https://your-domain.com/api/export?protocol=socks5&speed=fast&format=json"

# 导出所有代理
curl "https://your-domain.com/api/export?limit=all" -o all_proxies.txt
Python - 下载代理文件
import requests

# 下载 HTTP 代理列表
url = "https://your-domain.com/api/export?protocol=http&limit=all"
response = requests.get(url)

with open("http_proxies.txt", "w") as f:
    f.write(response.text)

print(f"已保存 {len(response.text.splitlines())} 个代理")
GET /api/random

获取随机代理。

请求参数
参数 类型 必填 说明
protocol string 否 协议筛选
speed string 否 速度筛选
count number 否 数量 (最大 50)
调用示例
Python - 使用随机代理
import requests

# 获取一个随机快速代理
response = requests.get("https://your-domain.com/api/random?speed=fast")
proxy = response.json()

# 使用这个代理发起请求
proxies = {
    "http": f"http://{proxy['ip']}:{proxy['port']}",
    "https": f"http://{proxy['ip']}:{proxy['port']}"
}

target = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
print(target.text)

操作接口

POST /api/refresh

刷新代理源,从所有配置的代理源重新获取代理列表。

调用示例
cURL
curl -X POST "https://your-domain.com/api/refresh"
POST /api/check

触发代理存活检测。检测完成后会自动分类高速匿名代理和普通代理。

调用示例
Python
import requests
import time

# 触发检测
requests.post("https://your-domain.com/api/check")

# 轮询检测进度
while True:
    progress = requests.get("https://your-domain.com/api/check-progress").json()
    if not progress["checking"]:
        print("检测完成!")
        break
    print(f"进度: {progress['current']}/{progress['total']}")
    time.sleep(2)
GET /api/check-progress

获取当前检测进度。

响应示例
JSON
{
  "checking": true,
  "current": 15000,
  "total": 45000
}
已复制到剪贴板!