2. 封禁管理模块

2.1 申请添加封禁

添加新的封禁记录(支持在线/离线两种模式)。

接口: POST /bans/add

请求参数:

JSON
{ "token": "aBcD1234EfGh5678IjKlMnOpQrSt", "player_id": "player123", "ip": "192.168.1.1", "ipv6": "2001:db8::1", "online": true, "mcuuid": "550e8400-e29b-41d4-a716-446655440000" }
ParameterTypeRequiredDescription
tokenstringYes认证 Token(需具备上传权限)
player_idstringConditional玩家标识符(与 ip 至少提供一个)
ipstringConditionalIPv4 地址(与 player_id 至少提供一个)
ipv6stringNoIPv6 地址
onlinebooleanNo数据存储模式(true=online,默认false=offline)
mcuuidstringNoMinecraft UUID(online 模式下可选)

请求示例:

cURL - Offline 模式:

Bash
curl -X POST https://api.ndpreforged.com/bans/add \ -H "Content-Type: application/json" \ -d '{ "token": "aBcD1234EfGh5678IjKlMnOpQrSt", "player_id": "player123", "ip": "192.168.1.1", "online": false }'

cURL - Online 模式:

Bash
curl -X POST https://api.ndpreforged.com/bans/add \ -H "Content-Type: application/json" \ -d '{ "token": "aBcD1234EfGh5678IjKlMnOpQrSt", "player_id": "player123", "ip": "192.168.1.1", "ipv6": "2001:db8::1", "online": true, "mcuuid": "550e8400-e29b-41d4-a716-446655440000" }'

Python:

Python
import requests response = requests.post( "https://api.ndpreforged.com/bans/add", json={ "token": "aBcD1234EfGh5678IjKlMnOpQrSt", "player_id": "player123", "ip": "192.168.1.1", "online": False } )

响应示例:

Success (200 OK):

JSON
{ "message": "Added" }

Error Responses:

Status CodeError MessageDescription
400Missing token缺少认证 Token
400Invalid token formatToken 格式无效
400Token not foundToken 不存在
403No permission缺乏上传权限
400Missing player_id or ip缺少必要的标识参数
400Invalid IP formatIPv4 格式无效
400Invalid IPv6 formatIPv6 格式无效
400Invalid MCUUID formatMCUUID 格式无效
400Already banned离线模式:记录已存在
400Already exists在线模式:记录已存在
500Server error服务器内部错误

导航