# 移动端口和 IP 轮换

> LocalSERP Proxy API：4G/5G 端口、IP 轮换（立即、定时或通过链接）和每日流量。参数、响应示例、curl、Python 和 Node.js 代码。

- URL: https://localserpproxy.com/zh/docs/api/mobile/
- 最后更新: 2026-10-15
- Publisher: LocalSERP Proxy (https://localserpproxy.com)

专用 4G/5G 端口：立即或按定时计划更换 IP，使用轮换链接并查看每日流量。

**本页端点**

- `GET /v1/mobile`：列出移动代理端口
- `GET /v1/mobile/{portId}`：获取移动代理端口
- `PATCH /v1/mobile/{portId}`：重命名、切换自动续费，或设置自动轮换
- `POST /v1/mobile/{portId}/rotate`：立即更换 IP
- `GET /v1/mobile/{portId}/rotate`：轮换链接（在查询字符串中通过 GET 传入 API 密钥）
- `POST /v1/mobile/{portId}/reset-password`：为端口生成新的代理密码
- `GET /v1/mobile/{portId}/usage`：端口每日流量（仅供参考：流量不限，但须遵守公平使用政策）
- `GET /v1/catalog/countries/{countryCode}/carriers`：一个国家/地区中提供 4G/5G 端口的移动运营商

基础 URL `https://localserpproxy.com/api/v1`。身份验证、错误和限制：请参阅 [API 概览](https://localserpproxy.com/zh/docs/api/)。

## 查看移动代理端口

`GET /v1/mobile`

身份验证：在 `Authorization: Bearer API_KEY` 请求头中提供 API 密钥。

**响应** `200 OK`

```json
{
  "data": [
    {
      "id": "mob_2v8k1q",
      "label": "US Verizon #1",
      "status": "active",
      "country": "US",
      "city": null,
      "carrier": "verizon",
      "carrierName": "Verizon",
      "networkType": "4G",
      "currentIp": "203.0.113.201",
      "ipChangedAt": "2026-10-05T14:03:11Z",
      "endpoint": {
        "host": "gw.localserpproxy.com",
        "httpPort": 7777,
        "socksPort": 7778
      },
      "username": "USERNAME",
      "password": "PASSWORD",
      "rotation": {
        "mode": "interval",
        "intervalMinutes": 10
      },
      "minRotationIntervalSeconds": 30,
      "rotationLink": "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/rotate?key=API_KEY",
      "planId": "mob-us-30d",
      "autoRenew": false,
      "createdAt": "2026-10-05T14:03:11Z",
      "expiresAt": "2026-11-04T14:03:11Z"
    }
  ]
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/mobile" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/mobile", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 获取移动代理端口

`GET /v1/mobile/{portId}`

身份验证：在 `Authorization: Bearer API_KEY` 请求头中提供 API 密钥。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `portId` | path | string | 是 | — |

**响应** `200 OK`

```json
{
  "id": "mob_2v8k1q",
  "label": "US Verizon #1",
  "status": "active",
  "country": "US",
  "city": null,
  "carrier": "verizon",
  "carrierName": "Verizon",
  "networkType": "4G",
  "currentIp": "203.0.113.201",
  "ipChangedAt": "2026-10-05T14:03:11Z",
  "endpoint": {
    "host": "gw.localserpproxy.com",
    "httpPort": 7777,
    "socksPort": 7778
  },
  "username": "USERNAME",
  "password": "PASSWORD",
  "rotation": {
    "mode": "interval",
    "intervalMinutes": 10
  },
  "minRotationIntervalSeconds": 30,
  "rotationLink": "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/rotate?key=API_KEY",
  "planId": "mob-us-30d",
  "autoRenew": false,
  "createdAt": "2026-10-05T14:03:11Z",
  "expiresAt": "2026-11-04T14:03:11Z"
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/mobile/mob_2v8k1q", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile/mob_2v8k1q`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 重命名、开启或关闭自动续费，或设置自动轮换

`PATCH /v1/mobile/{portId}`

重命名端口、开启或关闭自动续费，或设置自动轮换间隔（每 2 分钟至每 24 小时一次）：`"rotation": { "mode": "interval", "intervalMinutes": 10 }`（2–1440 分钟）；`"mode": "manual"` 可关闭自动轮换。否则，端口会一直使用当前 IP，直到你手动轮换；不过运营商有时也可能自行更换 IP。

身份验证：在 `Authorization: Bearer API_KEY` 请求头中提供 API 密钥。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `portId` | path | string | 是 | — |

**请求正文**

| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `label` | string | 否 | 最多 60 个字符 |
| `autoRenew` | boolean | 否 | — |
| `rotation` | object | 否 | 自动轮换间隔：`{ "mode": "interval", "intervalMinutes": 2–1440 }`（每 2 分钟至每 24 小时一次）；或使用 `{ "mode": "manual", "intervalMinutes": null }`，仅按需轮换。 |

*示例: 自动轮换*

```json
{
  "rotation": {
    "mode": "interval",
    "intervalMinutes": 10
  }
}
```

*示例: 手动*

```json
{
  "rotation": {
    "mode": "manual",
    "intervalMinutes": null
  }
}
```

**响应** `200 OK`

```json
{
  "id": "mob_2v8k1q",
  "label": "US Verizon #1",
  "status": "active",
  "country": "US",
  "city": null,
  "carrier": "verizon",
  "carrierName": "Verizon",
  "networkType": "4G",
  "currentIp": "203.0.113.201",
  "ipChangedAt": "2026-10-05T14:03:11Z",
  "endpoint": {
    "host": "gw.localserpproxy.com",
    "httpPort": 7777,
    "socksPort": 7778
  },
  "username": "USERNAME",
  "password": "PASSWORD",
  "rotation": {
    "mode": "interval",
    "intervalMinutes": 10
  },
  "minRotationIntervalSeconds": 30,
  "rotationLink": "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/rotate?key=API_KEY",
  "planId": "mob-us-30d",
  "autoRenew": false,
  "createdAt": "2026-10-05T14:03:11Z",
  "expiresAt": "2026-11-04T14:03:11Z"
}
```

*curl*

```bash
curl -s -X PATCH "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rotation":{"mode":"interval","intervalMinutes":10}}'
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.patch(f"{API}/mobile/mob_2v8k1q", headers=HEADERS, json={"rotation": {"mode": "interval", "intervalMinutes": 10}}, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile/mob_2v8k1q`, {
  method: 'PATCH',
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ rotation: { mode: 'interval', intervalMinutes: 10 } }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 立即更换 IP

`POST /v1/mobile/{portId}/rotate`

每次轮换都会重新连接运营商以获取新 IP，通常需要 5–15 秒；运营商偶尔可能分配相同的 IP，只需再次轮换即可。每个端口每 30 秒最多轮换一次（`minRotationIntervalSeconds`）：过早发起的轮换请求会返回 `429 rotation_too_soon`，并附带 `Retry-After`（需等待的秒数）。

身份验证：在 `Authorization: Bearer API_KEY` 请求头中提供 API 密钥。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `portId` | path | string | 是 | — |

**响应** `200 OK`

```json
{
  "ip": "203.0.113.201",
  "previousIp": "203.0.113.77",
  "rotatedAt": "2026-10-05T14:03:11Z",
  "nextRotationAvailableAt": "2026-10-05T14:03:41Z"
}
```

*curl*

```bash
curl -s -X POST "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/rotate" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.post(f"{API}/mobile/mob_2v8k1q/rotate", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile/mob_2v8k1q/rotate`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 轮换链接（在查询字符串中使用 API 密钥进行 GET 请求）

`GET /v1/mobile/{portId}/rotate`

与 `POST` 相同，适用于脚本和书签：`GET https://localserpproxy.com/api/v1/mobile/{portId}/rotate?key=API_KEY`。密钥需要具备 `proxies` 权限范围。`format=text` 会以 `text/plain` 格式返回新 IP。

身份验证：在 `key` 查询参数中提供 API 密钥（权限范围 `proxies`），因此链接可通过书签打开。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `key` | query | string | 是 | 你的 API 密钥（权限范围 `proxies`）。 |
| `portId` | path | string | 是 | — |
| `format` | query | `json` · `text` | 否 | 默认 `json` |

**响应** `200 OK`

```json
{
  "ip": "203.0.113.201",
  "previousIp": "203.0.113.77",
  "rotatedAt": "2026-10-05T14:03:11Z",
  "nextRotationAvailableAt": "2026-10-05T14:03:41Z"
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/rotate?key=$API_KEY&format=text"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"

r = requests.get(f"{API}/mobile/mob_2v8k1q/rotate", params={"key": os.environ["API_KEY"], "format": "text"}, timeout=30)
r.raise_for_status()
print(r.text)
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile/mob_2v8k1q/rotate?key=${process.env.API_KEY}&format=text`);
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.text());
```

## 为端口生成新代理密码

`POST /v1/mobile/{portId}/reset-password`

身份验证：在 `Authorization: Bearer API_KEY` 请求头中提供 API 密钥。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `portId` | path | string | 是 | — |

**响应** `200 OK`

```json
{
  "id": "mob_2v8k1q",
  "label": "US Verizon #1",
  "status": "active",
  "country": "US",
  "city": null,
  "carrier": "verizon",
  "carrierName": "Verizon",
  "networkType": "4G",
  "currentIp": "203.0.113.201",
  "ipChangedAt": "2026-10-05T14:03:11Z",
  "endpoint": {
    "host": "gw.localserpproxy.com",
    "httpPort": 7777,
    "socksPort": 7778
  },
  "username": "USERNAME",
  "password": "PASSWORD",
  "rotation": {
    "mode": "interval",
    "intervalMinutes": 10
  },
  "minRotationIntervalSeconds": 30,
  "rotationLink": "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/rotate?key=API_KEY",
  "planId": "mob-us-30d",
  "autoRenew": false,
  "createdAt": "2026-10-05T14:03:11Z",
  "expiresAt": "2026-11-04T14:03:11Z"
}
```

*curl*

```bash
curl -s -X POST "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/reset-password" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.post(f"{API}/mobile/mob_2v8k1q/reset-password", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile/mob_2v8k1q/reset-password`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 端口每日流量（仅供参考：流量不限，但须遵守公平使用政策）

`GET /v1/mobile/{portId}/usage`

仅供参考。您的专用端口流量不限，但须遵守公平使用政策：运营商可能会降低网速或暂停服务，以应对极高流量。

身份验证：在 `Authorization: Bearer API_KEY` 请求头中提供 API 密钥。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `portId` | path | string | 是 | — |
| `from` | query | string (date) | 否 | 首日（UTC），包含当天。默认值 = `to` 前 29 天。 |
| `to` | query | string (date) | 否 | 末日（UTC），包含当天。默认值 = 今天。最长范围为 366 天。 |

**响应** `200 OK`

```json
{
  "from": "2026-10-04",
  "to": "2026-10-05",
  "totalBytes": 2350000000,
  "totalRequests": 48210,
  "points": [
    {
      "date": "2026-10-04",
      "bytes": 1200000000,
      "requests": 24800
    },
    {
      "date": "2026-10-05",
      "bytes": 1150000000,
      "requests": 23410
    }
  ],
  "byCountry": [
    {
      "country": "US",
      "bytes": 2350000000
    }
  ]
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/mobile/mob_2v8k1q/usage" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/mobile/mob_2v8k1q/usage", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/mobile/mob_2v8k1q/usage`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 国家/地区中提供 4G/5G 端口的移动运营商

`GET /v1/catalog/countries/{countryCode}/carriers`

公开接口：无需 API 密钥。

**参数**

| 名称 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `countryCode` | path | string | 是 | ISO 3166-1 alpha-2，使用大写字母。 |

**响应** `200 OK`

```json
{
  "data": [
    {
      "id": "verizon",
      "name": "Verizon",
      "networkTypes": [
        "4G",
        "5G"
      ],
      "available": true,
      "cities": []
    }
  ]
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/catalog/countries/US/carriers"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"

r = requests.get(f"{API}/catalog/countries/US/carriers", timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/catalog/countries/US/carriers`);
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

---

LocalSERP Proxy: LocalSERP Proxy 是一项美国住宅代理服务，用于逐个城市检查本地搜索结果、广告和价格，支持加密货币支付，无需上传身份证件。
