本页端点
GET /v1/api-keys:列出 API 密钥POST /v1/api-keys:创建 API 密钥DELETE /v1/api-keys/{keyId}:撤销 API 密钥GET /v1/ip-whitelist:列出 IP 允许列表POST /v1/ip-whitelist:将 IP 或 IP 段添加到允许列表DELETE /v1/ip-whitelist/{entryId}:从允许列表中移除条目
基础 URL https://localserpproxy.com/api/v1。身份验证、错误和限制:请参阅 API 概览。
列出 API 密钥
GET/v1/api-keys
身份验证:在 Authorization: Bearer API_KEY 请求头中提供 API 密钥。
响应 200 OK
{
"data": [
{
"id": "key_5n2v8q",
"name": "Rotation script",
"prefix": "pk_4f9a2c",
"scopes": [
"read",
"proxies"
],
"createdAt": "2026-10-05T14:03:11Z",
"lastUsedAt": null
}
],
"limit": 20
}代码示例
curl -s "https://localserpproxy.com/api/v1/api-keys" \
-H "Authorization: Bearer $API_KEY"import os
import requests
API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
r = requests.get(f"{API}/api-keys", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';
const res = await fetch(`${API}/api-keys`, {
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 密钥
POST/v1/api-keys
全额 secret 将退还一次。
身份验证:在 Authorization: Bearer API_KEY 请求头中提供 API 密钥。
请求正文
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 最多 60 个字符 |
scopes | array of read · proxies · billing | 是 | — |
{
"name": "Rotation script",
"scopes": [
"read",
"proxies"
]
}响应 201 Created
{
"id": "key_5n2v8q",
"name": "Rotation script",
"prefix": "pk_4f9a2c",
"scopes": [
"read",
"proxies"
],
"createdAt": "2026-10-05T14:03:11Z",
"lastUsedAt": null,
"secret": "pk_4f9a2c8e1b7d3f6a9c2e5b8d1f4a7c0e"
}代码示例
curl -s -X POST "https://localserpproxy.com/api/v1/api-keys" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Rotation script","scopes":["read","proxies"]}'import os
import requests
API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
r = requests.post(f"{API}/api-keys", headers=HEADERS, json={"name": "Rotation script", "scopes": ["read", "proxies"]}, timeout=30)
r.raise_for_status()
print(r.json())// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';
const res = await fetch(`${API}/api-keys`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Rotation script', scopes: ['read', 'proxies'] }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());撤销 API 密钥
DELETE/v1/api-keys/{keyId}
身份验证:在 Authorization: Bearer API_KEY 请求头中提供 API 密钥。
参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
keyId | path | string | 是 | — |
响应 204 No Content
无请求正文:状态码即为答案。
代码示例
curl -s -X DELETE "https://localserpproxy.com/api/v1/api-keys/key_5n2v8q" \
-H "Authorization: Bearer $API_KEY"import os
import requests
API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
r = requests.delete(f"{API}/api-keys/key_5n2v8q", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.status_code) # 204: done// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';
const res = await fetch(`${API}/api-keys/key_5n2v8q`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(res.status); // 204: done查看 IP 允许列表
GET/v1/ip-whitelist
身份验证:在 Authorization: Bearer API_KEY 请求头中提供 API 密钥。
响应 200 OK
{
"data": [
{
"id": "ipw_8c1k2m",
"cidr": "203.0.113.24",
"label": "Office server",
"createdAt": "2026-10-05T14:03:11Z"
}
],
"limit": 10
}代码示例
curl -s "https://localserpproxy.com/api/v1/ip-whitelist" \
-H "Authorization: Bearer $API_KEY"import os
import requests
API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
r = requests.get(f"{API}/ip-whitelist", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';
const res = await fetch(`${API}/ip-whitelist`, {
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());将 IP 或 IP 范围添加到允许列表
POST/v1/ip-whitelist
支持 IPv4 地址、/24 至 /32 的 IPv4 CIDR、IPv6 地址或 /48 至 /128 的 IPv6 CIDR。拒绝私有、环回和保留地址范围(422)。60 秒内在网关生效。
身份验证:在 Authorization: Bearer API_KEY 请求头中提供 API 密钥。
请求正文
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
cidr | string | 是 | — |
label | string | 否 | 最多 60 个字符 |
{
"cidr": "203.0.113.24",
"label": "Office server"
}响应 201 Created
{
"id": "ipw_8c1k2m",
"cidr": "203.0.113.24",
"label": "Office server",
"createdAt": "2026-10-05T14:03:11Z"
}代码示例
curl -s -X POST "https://localserpproxy.com/api/v1/ip-whitelist" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"cidr":"203.0.113.24","label":"Office server"}'import os
import requests
API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
r = requests.post(f"{API}/ip-whitelist", headers=HEADERS, json={"cidr": "203.0.113.24", "label": "Office server"}, timeout=30)
r.raise_for_status()
print(r.json())// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';
const res = await fetch(`${API}/ip-whitelist`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ cidr: '203.0.113.24', label: 'Office server' }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());从允许列表中移除条目
DELETE/v1/ip-whitelist/{entryId}
身份验证:在 Authorization: Bearer API_KEY 请求头中提供 API 密钥。
参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
entryId | path | string | 是 | — |
响应 204 No Content
无请求正文:状态码即为答案。
代码示例
curl -s -X DELETE "https://localserpproxy.com/api/v1/ip-whitelist/ipw_8c1k2m" \
-H "Authorization: Bearer $API_KEY"import os
import requests
API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
r = requests.delete(f"{API}/ip-whitelist/ipw_8c1k2m", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.status_code) # 204: done// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';
const res = await fetch(`${API}/ip-whitelist/ipw_8c1k2m`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(res.status); // 204: done