## API 参考
**关于 Smart Shield 的说明:** Argo 智能路由正在集成到 Cloudflare 的 Smart Shield 产品中。API 端点保持稳定;现有集成无需更改即可继续工作。
### 基础端点
https://api.cloudflare.com/client/v4
### 身份验证
使用具有 Zone:Argo Smart Routing:Edit 权限的 API 令牌:
bash
# 需要的请求头
X-Auth-Email:
[email protected]
Authorization: Bearer YOUR_API_TOKEN
### 获取 Argo 智能路由状态
**端点:** `GET /zones/{zone_id}/argo/smart_routing`
**描述:** 获取当前 Argo 智能路由的启用状态。
**cURL 示例:**
bash
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/argo/smart_routing"
-H "Authorization: Bearer YOUR_API_TOKEN"
-H "Content-Type: application/json"
**响应:**
{
"result": {
"id": "smart_routing",
"value": "on",
"editable": true,
"modified_on": "2024-01-11T12:00:00Z"
},
"success": true,
"errors": [],
"messages": []
}
**TypeScript SDK 示例:**
typescript
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env.CLOUDFLARE_API_TOKEN
});
const status = await client.argo.smartRouting.get({ zone_id: 'your-zone-id' });
console.log(`Argo 状态: ${status.value}, 可编辑: ${status.editable}`);
**Python SDK 示例:**
python
from cloudflare import Cloudflare
client = Cloudflare(api_token=os.environ.get('CLOUDFLARE_API_TOKEN'))
status = client.argo.smart_routing.get(zone_id='your-zone-id')
print(f"Argo 状态: {status.value}, 可编辑: {status.editable}")
### 更新 Argo 智能路由状态
**端点:** `PATCH /zones/{zone_id}/argo/smart_routing`
**描述:** 为域名启用或禁用 Argo 智能路由。
**请求体:**
{
"value": "on" // 或 "off"
}
**cURL 示例:**
bash
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/{zone_id}/argo/smart_routing"
-H "Authorization: Bearer YOUR_API_TOKEN"
-H "Content-Type: application/json"
-d '{"value": "on"}'
**TypeScript SDK 示例:**
typescript
const result = await client.argo.smartRouting.edit({
zone_id: 'your-zone-id',
value: 'on',
});
console.log(`已更新: ${result.value} 于 ${result.modified_on}`);
**Python SDK 示例:**
python
result = client.argo.smart_routing.edit(
zone_id='your-zone-id',
value='on'
)
print(f"已更新: {result.value} 于 {result.modified_on}")
## 检查 Ed