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{"ip": "104.28.219.14"}代理连接
每个代理都由相同的四个部分组成——host:port:username:password。你的用户名和密码来自控制台中的代理生成器。国家、城市和会话定位会以令牌形式追加到用户名(见下文)。
global.socksnode.com:9000:USERNAME-country-us:PASSWORD端口与网关
入口网关影响延迟——离你最近的通常最快,所以我们自动选择。如果代理慢,就更换入口网关。出口国家由 country 令牌指定,与入口网关无关。
| 协议 | 轮换端口 | 粘性端口 |
|---|---|---|
| HTTP / HTTPS | 9000 | 10000 |
| SOCKS5 | 11000 | 12000 |
| 网关 | 主机 |
|---|---|
| 离你最近(默认) | 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-androidPools
住宅流量可在全部三个代理池使用,价格相同。在 POST /proxies 中传入 pool 选择代理池;不传即为 Pool 1,与以前一样。Mix 把请求平均分配到 mixPools 中的各个代理池。无法满足目标的代理池会被跳过,只有一个代理池能满足的目标在 Pool 1 上运行:每行的 pool、mixPools 和 poolNote 说明它实际运行在哪里。
| pool | 定位 | Sticky | |
|---|---|---|---|
| 1 | Pool 1 | 国家、州、城市和运营商(ASN),可自由组合 | 1–1440 min |
| 2 | Pool 2 | 国家,再加以下之一:州、城市或运营商 | 1–60 min |
| 3 | Pool 3 | 国家;美国可选州和城市 | 1–1440 min |
| mix | Mix | Pool 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 | 请求主体或参数无效 |
| 401 | API 密钥缺失、无效或已撤销 |
| 402 | 带宽余额不足,无法生成代理 |
| 403 | API 密钥缺少所需的作用域 |
| 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"{
"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默认值:residentialgbinteger可选可选。要报价的 GB 数,5 到 10,240 之间的整数。
curl "https://socksnode.com/api/v1/pricing?product=datacenter&gb=100" \
-H "Authorization: Bearer sk_YOUR_API_KEY"{
"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默认值:residentialgbinteger必填要购买的 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
}'{
"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默认值:24hproductstring可选datacenter 读取数据中心用量;其他值读取住宅用量。
residentialdatacentermobile_rotating默认值:residential
curl "https://socksnode.com/api/v1/usage?range=30d" \
-H "Authorization: Bearer sk_YOUR_API_KEY"{
"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"{
"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必填凭据使用的协议。
httpsocks5countrystring必填两位国家代码,或 ANY 表示全球。
statestring可选美国州名,全称且不含空格,例如 california。
citystring可选城市名,不含空格,例如 losangeles。设置 asn 时会被忽略。
asninteger可选ISP 网络编号,例如 Comcast 为 7922。
sessionModestring必填rotating 每个请求换新 IP;sticky 在 stickyDurationMinutes 内保持同一 IP。
rotatingstickystickyDurationMinutesinteger可选sticky IP 保持时长,1–1440 分钟。sessionMode 为 sticky 时必填。
countinteger可选要创建的凭据数量,1–20。
默认值:
1labelstring可选你的命名,最多 80 个字符。count 大于 1 时每个会加上 #n。
poolstring可选住宅代理池:1(默认)、2、3 或 mix。见 Pools。
123mix默认值:1mixPoolsstring可选pool 为 mix 时:使用哪些代理池,12、13、23 或 123(默认 123)。
121323123默认值:123strictboolean可选true:只用指定的州、城市或运营商;false:该处没有空闲 IP 时回退到整个国家。Pool 1 默认 true,Mix 默认 false;严格的 Mix 只在 Pool 1 上运行。
gatewaystring可选线路使用的入口网关:fr、us 或 sg——或 auto(默认),返回按地理路由的主机名,由 DNS 选择最近的网关。仅住宅代理。
autofrussg默认值:autoosstring可选设备操作系统指纹:windows、android、ios 或 mac。留空则不限设备。
windowsandroidiosmacproductstring可选由哪个余额支付、代理来自哪个网络: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"
}'{
"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"{
"data": { "id": "clx…", "deleted": true }
}定位目录:国家及其州和城市
GET/locations
作用域: read:proxies
查询参数
countrystring可选国家代码。返回其州列表。
statestring可选州代码,需同时提供 country。返回其城市列表。
productstring可选读取哪个产品的目录:residential(默认)、datacenter 或 mobile_rotating。数据中心和轮换移动还会列出该国家的 ASN。
residentialdatacentermobile_rotating默认值:residentialpoolstring可选要列出地点的住宅代理池:1(默认)、2 或 3。Mix 使用 Pool 1 的列表。
123默认值:1
curl "https://socksnode.com/api/v1/locations?country=us" \
-H "Authorization: Bearer sk_YOUR_API_KEY"{
"data": {
"country": "us",
"states": [
{ "code": "california", "name": "California", "cities": 212 },
{ "code": "texas", "name": "Texas", "cities": 187 }
]
}
}