OpenAPI 接口文档
OpenAPI 接口文档

生成动态代理连接凭据

按可选地区和轮换方式生成一组完整代理连接凭据。此操作不会创建新的动态子账号。

接口信息

项目 内容
Method POST
Path /open-api/v1/dynamic/accounts/{id}/proxy-credentials
认证 X-API-Key
Content-Type application/json
处理方式 同步

路径参数

参数 类型 必填 说明
id string 动态子账号 ID

请求体

字段 类型 必填 说明
country_code string 国家编码,使用地区接口返回的值
province_code string 省州编码;传入时必须同时传国家编码
city_code string 城市编码;传入时必须同时传国家和省州编码
rotation_type string ROTATINGSTICKY
session_duration_minutes integer 条件必填 STICKY 会话时长,当前支持范围为 1120 分钟

地区必须连续填写:不能只传省州或城市。未指定地区时,三个地区字段都应省略。

  • ROTATING:不能传 session_duration_minutes
  • STICKY:必须传整数 session_duration_minutes。当前支持 1120 分钟;大于 120 的值可能被接受,但不在当前支持范围内,实际会话保持效果不保证。

请求示例

轮换方式:

curl --request POST \
  --url 'https://api-test.puraroute.com/gin/open-api/v1/dynamic/accounts/1912345678901234567/proxy-credentials' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <YOUR_API_KEY>' \
  --data '{
    "country_code": "US",
    "rotation_type": "ROTATING"
  }'

固定会话方式:

{
  "country_code": "US",
  "province_code": "US_CA",
  "rotation_type": "STICKY",
  "session_duration_minutes": 30
}

地区示例只说明字段关系。实际值请从查询动态代理地区获取。

响应参数

字段 类型 说明
proxy_username string 按地区和轮换方式生成的代理用户名
password string 代理连接密码
host string 代理连接主机名
http_port integer HTTP 代理端口
socks5_port integer SOCKS5 代理端口

成功响应示例

{
  "code": 0,
  "msg": "success",
  "data": {
    "proxy_username": "customer-zone-us-session-example",
    "password": "example-secret",
    "host": "gateway.example.com",
    "http_port": 8000,
    "socks5_port": 1080
  },
  "next": null
}

可能的错误码

code 说明
300001 动态子账号不存在或不可访问
300323 指定地区不存在、不可用或不支持生成凭据
400001 认证失败
400009 地区层级、轮换方式、会话时长或请求体不符合要求
500000 系统处理失败,请求未完成

响应中的所有字段都属于敏感信息,不应写入普通日志、前端页面源码或公开工单。

On this page

生成动态代理连接凭据