开发者API文档

基础信息

GET /user/profile.php
https://unicoder.cloud/api/user/profile.php?api_key=你的API Key

获取当前用户的详细信息,包括套餐、配额、已用次数等。

请求参数

参数位置必填说明
api_keyURL/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_keystring用户API Key
typestringstaticlive
sub_typestring可选值:wifi, text, url, email, card, geo, tel, sms
paramsobject根据子类型不同,包含不同字段(详见下表)
remarkstring备注信息

子类型参数说明

sub_typeparams 字段
wifissid, password, encryption (WPA/WEP/nopass)
texttext
urlurl
emailemail, subject (可选), body (可选)
cardname, company, title, phone, email, address (全部可选)
geolatitude, longitude
telphone
smsphone, 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_keystring用户API Key
pageint页码,默认1
limitint每页条数,默认20,最大100
typestring筛选类型:staticlive
sub_typestring筛选子类型,如 url
searchstring按备注模糊搜索

成功响应示例

{
    "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_keyURL/Header用户API Key
idURL记录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_keystring用户API Key
record_idint要修改的动态码记录ID
paramsobject新的目标参数,与生成时的 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_keystring用户API Key
qr_idint记录ID
remarkstring新的备注内容(可为空)

请求示例

{
    "api_key": "你的api_key",
    "qr_id": 123,
    "remark": "新备注"
}

成功响应

{
    "success": true,
    "message": "备注已更新",
    "remark": "新备注"
}
POST /qrcode/delete.php
https://unicoder.cloud/api/qrcode/delete.php

删除指定二维码记录(同时删除服务器上的图片文件)。

请求参数

参数类型必填说明
api_keystring用户API Key
record_idint要删除的记录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参数错误请求参数缺失或格式错误
401API 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"}
  }'
注意事项: