📚 API 文档

XBin REST API 参考

基础 URL

https://xbin.pages.dev/api

身份验证

无需 API 密钥。受密码保护的粘贴板需要提供密码参数。

接口列表

POST/paste

创建新的粘贴板

请求体

{ "content": "string (必需) - 粘贴板内容", "customId": "string (可选) - 自定义ID", "password": "string (可选) - 密码保护", "expiresIn": "number (可选) - 过期时间(秒)" }

响应

{ "id": "粘贴板ID", "url": "https://xbin.pages.dev/粘贴板ID", "success": true }

示例

curl -X POST https://xbin.pages.dev/api/paste \ -H "Content-Type: application/json" \ -d '{ "content": "你好,世界!", "customId": "my-paste", "password": "secret123", "expiresIn": 3600 }'

GET/paste/{id}

获取粘贴板内容

参数

  • password (查询参数, 可选) - 受密码保护的粘贴板需要提供

响应

{ "content": "粘贴板内容", "createdAt": 1234567890, "expiresAt": 1234567890, "views": 5, "hasPassword": false }

示例

curl https://xbin.pages.dev/api/paste/my-paste?password=secret123

PUT/paste/{id}

更新粘贴板内容

请求体

{ "content": "string (必需) - 新的内容", "password": "string (可选, 受密码保护的粘贴板需要提供)" }

响应

{ "success": true }

示例

curl -X PUT https://xbin.pages.dev/api/paste/my-paste \ -H "Content-Type: application/json" \ -d '{ "content": "更新后的内容", "password": "secret123" }'

DELETE/paste/{id}

删除粘贴板

参数

  • password (查询参数, 可选) - 受密码保护的粘贴板需要提供

响应

{ "success": true }

示例

curl -X DELETE https://xbin.pages.dev/api/paste/my-paste?password=secret123

GET/stats

获取系统统计信息

响应

{ "totalPastes": 1234, "totalViews": 5678, "todayPastes": 42, "success": true }

响应字段说明

  • totalPastes - 总粘贴板数量
  • totalViews - 总查看次数
  • todayPastes - 今日新增粘贴板数量

示例

curl https://xbin.pages.dev/api/stats

错误响应

{ "error": "错误信息" }

状态码

← 返回首页