开发者

API 与集成文档

集成 SocksNode 有两种方式:通过 HTTP(S) 或 SOCKS5 直接连接到代理网关,或通过 REST API 以编程方式管理带宽、用量和代理。

本页内容

轮换代理(住宅、数据中心、移动)

Quickstart

将任意 HTTP(S) 或 SOCKS5 客户端指向网关,并使用你的代理用户名和密码进行认证。定位设置写在用户名中。

通过 HTTP 的轮换美国代理。将 USERNAME 和 PASSWORD 替换为你的凭据。

入口网关按你的所在位置选择——最近的门通常最快。你也可以自行更改。

想要针对你的技术栈进行完整讲解?每份指南都涵盖设置、轮换和粘性会话,以及国家/地区定向。

curl -x http://global.socksnode.com:9000 \
  -U "USERNAME-country-us:PASSWORD" \
  https://api.ipify.org?format=json
响应200
{"ip": "104.28.219.14"}

代理连接

每个代理都由相同的四个部分组成——host:port:username:password。你的用户名和密码来自控制台中的代理生成器。国家、城市和会话定位会以令牌形式追加到用户名(见下文)。

global.socksnode.com:9000:USERNAME-country-us:PASSWORD

端口与网关

入口网关影响延迟——离你最近的通常最快,所以我们自动选择。如果代理慢,就更换入口网关。出口国家由 country 令牌指定,与入口网关无关。

协议轮换端口粘性端口
HTTP / HTTPS900010000
SOCKS51100012000
网关主机
离你最近(默认)global.socksnode.com
欧洲fr.socksnode.com
美国us.socksnode.com
新加坡sg.socksnode.com
# 9000: a new exit IP on every request
curl -x http://global.socksnode.com:9000 \
  -U "USERNAME-country-us:PASSWORD" \
  https://api.ipify.org

定位与会话

将令牌以连字符分隔追加到用户名,以控制出口位置和会话行为:

令牌含义
-country-<cc>ISO 国家代码,例如 -country-us
-state-<name>州(美国),例如 state-california(全名,无空格)。可与城市或 ISP 组合。
-city-<name>城市,例如 city-losangeles(无空格或下划线)。
-asn-<number>按 ASN 指定 ISP,例如 asn-7922(Comcast)。可与州或城市组合。
-os-<name>仅返回单一设备 OS 的 IP:windows、android、ios 或 mac。池子会变小,IP 数量可能更少。
-session-<id>在多次请求间保持相同 IP(粘性)
-lifetime-<min>粘性会话时长,1–1440 分钟
# Rotating: a fresh IP on every request
USERNAME-country-us

# Sticky: the same IP for 30 minutes
USERNAME-country-us-session-a1b2c3d4-lifetime-30

# State + city
USERNAME-country-us-state-california-city-losangeles

# City + ISP (ASN)
USERNAME-country-us-city-chicago-asn-7922

# Device OS
USERNAME-country-us-os-android

Pools

住宅流量可在全部三个代理池使用,价格相同。在 POST /proxies 中传入 pool 选择代理池;不传即为 Pool 1,与以前一样。Mix 把请求平均分配到 mixPools 中的各个代理池。无法满足目标的代理池会被跳过,只有一个代理池能满足的目标在 Pool 1 上运行:每行的 pool、mixPools 和 poolNote 说明它实际运行在哪里。

pool定位Sticky
1Pool 1国家、州、城市和运营商(ASN),可自由组合1–1440 min
2Pool 2国家,再加以下之一:州、城市或运营商1–60 min
3Pool 3国家;美国可选州和城市1–1440 min
mixMixPool 1 的地点;Mix 中每个代理池各自服务能满足的部分含 Pools 1 + 3 时为 1–1440 分钟(超过 60 分钟 Pool 2 会被跳过);其他情况 1–60 分钟

Pool 2 和 Pool 3 的地点:GET /locations?pool=2(或 3)。名称和代码都可以:"Los Angeles"、"losangeles" 和 "los_angeles" 是同一个城市。

# Pool 3, Los Angeles, the same IP for 30 minutes
curl -X POST "https://socksnode.com/api/v1/proxies" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pool": "3", "protocol": "http", "country": "us",
       "state": "california", "city": "losangeles",
       "sessionMode": "sticky", "stickyDurationMinutes": 30}'

# A Mix of all three pools, a new IP on every request
curl -X POST "https://socksnode.com/api/v1/proxies" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pool": "mix", "mixPools": "123", "protocol": "http",
       "country": "gb", "sessionMode": "rotating", "count": 5}'

# Pool 2's own states, cities and ISPs in one country
curl "https://socksnode.com/api/v1/locations?pool=2&country=gb" \
  -H "Authorization: Bearer YOUR_API_KEY"

REST API

鉴权

基础 URL https://socksnode.com/api/v1。在 Dashboard → API access 下创建密钥,并以 Bearer 令牌形式发送。密钥具有作用域——只请求你需要的权限。

作用域授予权限
read:usage余额与用量分析
read:proxies列出已保存的代理凭据
write:proxies生成新的代理凭据
purchase为轮换住宅、数据中心和移动代理购买 GB,购买和续费静态 IP 与 ISP IP,租用和续费 4G/5G 端口,开启自动续费,购买 24 小时 IP 以及 IP Vault 地址和流量——从余额扣款。

速率限制:每个密钥每分钟 120 次请求(代理生成会被进一步限流)。请对密钥保密并保存在服务器端。

GET /api/v1/account HTTP/1.1
Host: socksnode.com
Authorization: Bearer sk_YOUR_API_KEY

错误

错误会返回 JSON 主体 { "error": { "code", "message" } },并附带相应的 HTTP 状态码:

状态含义
400请求主体或参数无效
401API 密钥缺失、无效或已撤销
402带宽余额不足,无法生成代理
403API 密钥缺少所需的作用域
404未找到,或不属于你。
429超出速率限制——参见 Retry-After 响应头
503产品维护中。请稍后重试。
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": {
    "code": "no_bandwidth",
    "message": "…"
  }
}

带宽余额

GET/account

作用域: read:usage

无参数。

curl "https://socksnode.com/api/v1/account" \
  -H "Authorization: Bearer sk_YOUR_API_KEY"
响应200
{
  "balance": {
    "purchasedGb": 50,
    "usedGb": 12.34,
    "remainingGb": 37.66
  },
  "datacenterBalance": {
    "purchasedGb": 0,
    "usedGb": 0,
    "remainingGb": 0
  },
  "mobileRotatingBalance": {
    "purchasedGb": 10,
    "usedGb": 1.2,
    "remainingGb": 8.8
  },
  "creditUsd": 40
}

轮换 GB 的价格阶梯与报价

GET/pricing

作用域: read:usage

查询参数

  • productstring可选

    网络类型:residential(默认)、datacenter 或 mobile_rotating。

    residentialdatacentermobile_rotating默认值: residential

  • gbinteger可选

    可选。要报价的 GB 数,5 到 10,240 之间的整数。

curl "https://socksnode.com/api/v1/pricing?product=datacenter&gb=100" \
  -H "Authorization: Bearer sk_YOUR_API_KEY"
响应200
{
  "product": "datacenter",
  "currency": "USD",
  "minGb": 5,
  "maxGb": 10240,
  "bandwidthExpires": false,
  "tiers": [
    { "gb": 5, "priceUsd": 3.05, "perGbUsd": 0.61 },
    { "gb": 100, "priceUsd": 49, "perGbUsd": 0.49 },
    { "gb": 10240, "priceUsd": 2969.6, "perGbUsd": 0.29 }
  ],
  "quote": { "gb": 100, "totalUsd": 49, "perGbUsd": 0.49 }
}

用余额购买轮换 GB

POST/orders

作用域: purchase

请求体参数

  • productstring可选

    网络类型:residential(默认)、datacenter 或 mobile_rotating。

    residentialdatacentermobile_rotating默认值: residential

  • gbinteger必填

    要购买的 GB 数,5 到 10,240。按价格阶梯从余额扣款,并享受您等级的折扣;GB 立即到账,永不过期。

curl -X POST "https://socksnode.com/api/v1/orders" \
  -H "Authorization: Bearer sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "product": "datacenter",
    "gb": 100
  }'
响应201
{
  "order": {
    "id": "cmv…",
    "orderNumber": "SN-MVFRMPRO-B26F94",
    "product": "datacenter",
    "gb": 100,
    "amountUsd": 49,
    "discountUsd": 0,
    "status": "paid"
  },
  "balanceUsd": 51
}

分析

GET/usage

作用域: read:usage

查询参数

  • rangestring可选

    时间范围。未知值按 24h 处理。

    1h24h7d30d90dtodaymonth12mall默认值: 24h

  • productstring可选

    datacenter 读取数据中心用量;其他值读取住宅用量。

    residentialdatacentermobile_rotating默认值: residential

curl "https://socksnode.com/api/v1/usage?range=30d" \
  -H "Authorization: Bearer sk_YOUR_API_KEY"
响应200
{
  "range": "30d",
  "product": "residential",
  "granularity": "day",
  "totalGb": 12.34,
  "series": [{ "period": "2026-09-01", "gb": 1.2 }],
  "requests": {
    "total": 10420,
    "successful": 10310,
    "failed": 110,
    "successRate": 98.9,
    "avgLatencyMs": 280
  },
  "byCountry": [{ "country": "us", "requests": 8200, "gb": 9.1 }],
  "truncated": false
}

列出已保存的凭据

GET/proxies

作用域: read:proxies

无参数。

curl "https://socksnode.com/api/v1/proxies" \
  -H "Authorization: Bearer sk_YOUR_API_KEY"
响应200
{
  "data": [
    {
      "id": "clx…",
      "product": "residential",
      "label": "scraper",
      "protocol": "http",
      "country": "us",
      "sessionMode": "rotating",
      "host": "global.socksnode.com",
      "port": 9000,
      "username": "USERNAME-country-us",
      "pool": "1",
      "status": "active",
      "createdAt": "2026-09-30T08:12:44.000Z"
    }
  ]
}

生成凭据(密码仅返回一次)

POST/proxies

作用域: write:proxies

请求体参数

  • protocolstring必填

    凭据使用的协议。

    httpsocks5

  • countrystring必填

    两位国家代码,或 ANY 表示全球。

  • statestring可选

    美国州名,全称且不含空格,例如 california。

  • citystring可选

    城市名,不含空格,例如 losangeles。设置 asn 时会被忽略。

  • asninteger可选

    ISP 网络编号,例如 Comcast 为 7922。

  • sessionModestring必填

    rotating 每个请求换新 IP;sticky 在 stickyDurationMinutes 内保持同一 IP。

    rotatingsticky

  • stickyDurationMinutesinteger可选

    sticky IP 保持时长,1–1440 分钟。sessionMode 为 sticky 时必填。

  • countinteger可选

    要创建的凭据数量,1–20。

    默认值: 1

  • labelstring可选

    你的命名,最多 80 个字符。count 大于 1 时每个会加上 #n。

  • poolstring可选

    住宅代理池:1(默认)、2、3 或 mix。见 Pools。

    123mix默认值: 1

  • mixPoolsstring可选

    pool 为 mix 时:使用哪些代理池,12、13、23 或 123(默认 123)。

    121323123默认值: 123

  • strictboolean可选

    true:只用指定的州、城市或运营商;false:该处没有空闲 IP 时回退到整个国家。Pool 1 默认 true,Mix 默认 false;严格的 Mix 只在 Pool 1 上运行。

  • gatewaystring可选

    线路使用的入口网关:fr、us 或 sg——或 auto(默认),返回按地理路由的主机名,由 DNS 选择最近的网关。仅住宅代理。

    autofrussg默认值: auto

  • osstring可选

    设备操作系统指纹:windows、android、ios 或 mac。留空则不限设备。

    windowsandroidiosmac

  • productstring可选

    由哪个余额支付、代理来自哪个网络:residential(默认)、datacenter 或 mobile_rotating。 mobile_rotating 默认按国家定位;按州、城市和 ASN 定位时流量按双倍计算,sticky IP 最长保持 120 分钟。

    residentialdatacentermobile_rotating默认值: residential

curl -X POST "https://socksnode.com/api/v1/proxies" \
  -H "Authorization: Bearer sk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "protocol": "http",
    "country": "us",
    "sessionMode": "rotating",
    "count": 2,
    "label": "scraper"
  }'
响应201
{
  "data": [
    {
      "id": "clx…",
      "host": "global.socksnode.com",
      "port": 9000,
      "username": "USERNAME-country-us",
      "password": "shown once",
      "protocol": "http",
      "country": "us",
      "state": null,
      "city": null,
      "sessionMode": "rotating",
      "stickyDurationMinutes": null,
      "label": "scraper #1",
      "product": "residential",
      "pool": "1",
      "mixPools": null,
      "poolNote": null
    }
  ]
}

删除已保存的凭据

DELETE/proxies/{id}

作用域: write:proxies

路径参数

  • idstring必填

    已保存代理的 id,由 GET /proxies 返回。

curl -X DELETE "https://socksnode.com/api/v1/proxies/PROXY_ID" \
  -H "Authorization: Bearer sk_YOUR_API_KEY"
响应200
{
  "data": { "id": "clx…", "deleted": true }
}

定位目录:国家及其州和城市

GET/locations

作用域: read:proxies

查询参数

  • countrystring可选

    国家代码。返回其州列表。

  • statestring可选

    州代码,需同时提供 country。返回其城市列表。

  • productstring可选

    读取哪个产品的目录:residential(默认)、datacenter 或 mobile_rotating。数据中心和轮换移动还会列出该国家的 ASN。

    residentialdatacentermobile_rotating默认值: residential

  • poolstring可选

    要列出地点的住宅代理池:1(默认)、2 或 3。Mix 使用 Pool 1 的列表。

    123默认值: 1

curl "https://socksnode.com/api/v1/locations?country=us" \
  -H "Authorization: Bearer sk_YOUR_API_KEY"
响应200
{
  "data": {
    "country": "us",
    "states": [
      { "code": "california", "name": "California", "cities": 212 },
      { "code": "texas", "name": "Texas", "cities": 187 }
    ]
  }
}

准备好开始构建了吗?

在控制台生成凭据,或创建 API 密钥以实现自动化。