开发者API文档
基础信息
- 基础URL:
https://unicoder.cloud/api/
- 所有请求/响应均为 JSON 格式,UTF-8 编码。
- 认证方式(任选其一):
- - HTTP 请求头:
Authorization: Bearer {api_key}
- - URL 参数:
?api_key={api_key}
- - POST JSON 字段:
"api_key": "{api_key}"
GET /user/profile.php
https://unicoder.cloud/api/user/profile.php?api_key=你的API Key
获取当前用户的详细信息,包括套餐、配额、已用次数等。
请求参数
| 参数 | 位置 | 必填 | 说明 |
| api_key | URL/Header | 是 | 用户API Key |
成功响应示例
{
"success": true,
"user": {
"id": 42,
"username": "devuser",
"email": "dev@example.com",
"api_key": "a1b2c3d4e5f67890abcdef1234567890",
"plan": "advanced",
"daily_quota_static": 666,
"used_today_static": 0,
"api_monthly_quota": 6666,
"api_used_month": 0,
"live_count": 3,
"extra_live_slots": 0,
"extra_retention_days": 0
}
}
POST /developer/generate.php
https://unicoder.cloud/api/developer/generate.php
消耗API月配额
生成静态码或动态码。动态码内容可后续修改,静态码内容固定。
请求参数
| 参数 | 类型 | 必填 | 说明 |
| api_key | string | 是 | 用户API Key |
| type | string | 是 | static 或 live |
| sub_type | string | 是 | 可选值:wifi, text, url, email, card, geo, tel, sms |
| params | object | 是 | 根据子类型不同,包含不同字段(详见下表) |
| remark | string | 否 | 备注信息 |
子类型参数说明
| sub_type | params 字段 |
| wifi | ssid, password, encryption (WPA/WEP/nopass) |
| text | text |
| url | url |
| email | email, subject (可选), body (可选) |
| card | name, company, title, phone, email, address (全部可选) |
| geo | latitude, longitude |
| tel | phone |
| sms | phone, body (可选) |
请求示例(生成URL动态码)
{
"api_key": "你的api_key",
"type": "live",
"sub_type": "url",
"params": {"url": "https://www.example.com"},
"remark": "测试动态码"
}
成功响应
{
"success": true,
"message": "动态码生成成功",
"data": {
"image_url": "https://unicoder.cloud/uploads/qrcodes/2026/03/04/xxx.png",
"file_path": "/uploads/qrcodes/2026/03/04/xxx.png",
"record_id": 12345,
"type": "live",
"sub_type": "url",
"params": {"url": "https://www.example.com"},
"remark": "测试动态码"
}
}
GET /qrcode/list.php
https://unicoder.cloud/api/qrcode/list.php?api_key=你的API Key&page=1&limit=20
分页获取当前用户的二维码记录,支持筛选和搜索。
请求参数
| 参数 | 类型 | 必填 | 说明 |
| api_key | string | 是 | 用户API Key |
| page | int | 否 | 页码,默认1 |
| limit | int | 否 | 每页条数,默认20,最大100 |
| type | string | 否 | 筛选类型:static 或 live |
| sub_type | string | 否 | 筛选子类型,如 url |
| search | string | 否 | 按备注模糊搜索 |
成功响应示例
{
"success": true,
"data": {
"records": [
{
"id": 123,
"type": "live",
"sub_type": "url",
"content": {"url": "..."},
"live_data": {"url": "..."},
"remark": "备注",
"file_path": "/uploads/qrcodes/2026/03/04/xxx.png",
"image_url": "https://unicoder.cloud/uploads/qrcodes/2026/03/04/xxx.png",
"created_at": "2026-03-04 10:00:00"
}
],
"pagination": {
"total": 50,
"page": 1,
"limit": 20,
"pages": 3
}
}
}
GET /qrcode/detail.php
https://unicoder.cloud/api/qrcode/detail.php?api_key=你的API Key&id=记录ID
获取指定二维码的详细信息。
请求参数
| 参数 | 位置 | 必填 | 说明 |
| api_key | URL/Header | 是 | 用户API Key |
| id | URL | 是 | 记录ID(可通过列表接口获得) |
成功响应示例
{
"success": true,
"data": {
"id": 123,
"type": "live",
"sub_type": "url",
"content": {"url": "https://old.example.com"},
"live_data": {"url": "https://new.example.com"},
"remark": "备注",
"file_path": "/uploads/qrcodes/2026/03/04/xxx.png",
"image_url": "https://unicoder.cloud/uploads/qrcodes/2026/03/04/xxx.png",
"created_at": "2026-03-04 10:00:00"
}
}
POST /qrcode/update_live.php
https://unicoder.cloud/api/qrcode/update_live.php
修改已生成的动态码内容(仅限动态码)。
请求参数
| 参数 | 类型 | 必填 | 说明 |
| api_key | string | 是 | 用户API Key |
| record_id | int | 是 | 要修改的动态码记录ID |
| params | object | 是 | 新的目标参数,与生成时的 params 结构一致 |
请求示例
{
"api_key": "你的api_key",
"record_id": 123,
"params": {"url": "https://updated.example.com"}
}
成功响应
{
"success": true,
"message": "动态码更新成功",
"data": {
"record_id": 123,
"new_params": {"url": "https://updated.example.com"}
}
}
POST /qrcode/update_remark.php
https://unicoder.cloud/api/qrcode/update_remark.php
修改二维码的备注信息(所有类型均可)。
请求参数
| 参数 | 类型 | 必填 | 说明 |
| api_key | string | 是 | 用户API Key |
| qr_id | int | 是 | 记录ID |
| remark | string | 否 | 新的备注内容(可为空) |
请求示例
{
"api_key": "你的api_key",
"qr_id": 123,
"remark": "新备注"
}
成功响应
{
"success": true,
"message": "备注已更新",
"remark": "新备注"
}
POST /qrcode/delete.php
https://unicoder.cloud/api/qrcode/delete.php
删除指定二维码记录(同时删除服务器上的图片文件)。
请求参数
| 参数 | 类型 | 必填 | 说明 |
| api_key | string | 是 | 用户API Key |
| record_id | int | 是 | 要删除的记录ID |
请求示例
{
"api_key": "你的api_key",
"record_id": 123
}
成功响应
{
"success": true,
"message": "删除成功",
"record_id": 123
}
配额与限制
| 项目 | 基础版 | 进阶版 |
| API月配额 | 66 次 | 6666 次 |
| 动态码槽位 | 6 个 | 66 个 |
| 静态码每日次数 | 366 次 | 666 次 |
| 频率限制 | 10 次/秒(基于API Key) |
错误码参考
| HTTP状态码 | 错误信息 | 说明 |
| 400 | 参数错误 | 请求参数缺失或格式错误 |
| 401 | API Key 无效 | 提供的 api_key 不存在或已失效 |
| 403 | 本月API调用次数已用完 | 当月配额已耗尽 |
| 403 | 动态码槽位已满 | 当前动态码数量已达上限 |
| 403 | 今日静态码次数已达上限 | 当日静态码生成次数用完 |
| 404 | 记录不存在 | 指定的记录ID不存在或不属于当前用户 |
| 429 | 请求过于频繁 | 触发频率限制,请稍后再试 |
| 500 | 服务器内部错误 | 请稍后重试或联系管理员 |
命令行调用示例(以生成二维码为例)
curl -X POST https://unicoder.cloud/api/developer/generate.php \
-H "Content-Type: application/json" \
-d '{
"api_key": "你的api_key",
"type": "static",
"sub_type": "url",
"params": {"url": "https://www.example.com"}
}'
注意事项:
- 所有接口都需要提供有效的
api_key,且只能操作自己名下的记录。
- 开发者接口
/developer/generate.php 会消耗 API 月配额,其余接口不消耗。
- 频率限制适用于所有接口,超过限制会返回 429 状态码。
- 二维码图片的
image_url 可直接用于显示或下载。
- 记录ID(
id)可通过列表接口返回的 id 字段获取。