简体中文
简体中文
Appearance
简体中文
简体中文
Appearance
创建并管理徽章颁发(assertion)— 即发给具体接收者的徽章。
所有端点都需要通过 X-Api-Key 头进行认证。参阅 认证。
向接收者发放一枚徽章。
POST /awards| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
badgeId | string | 是 | 要颁发的徽章 ID |
recipient | object | 是 | 接收者详情(见下) |
recipient.name | string | 是 | 接收者全名(至少 5 个字符) |
recipient.email | string | 是 | 接收者邮箱地址 |
issuedOn | string | 是 | 颁发日期,ISO 8601 格式(例如 2025-01-15) |
expires | string | 否 | 到期日期,ISO 8601 格式 |
blockchain | string | 否 | 用于链上验证的区块链。仅支持 matchain。Pro 套餐可用。 |
curl -X POST https://api.badges.ninja/awards \
-H "X-Api-Key: bws_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"parameters": {
"badgeId": "b1c2d3e4-f5a6-7890-bcde-f12345678901",
"recipient": {
"name": "Jane Smith",
"email": "jane@example.com"
},
"issuedOn": "2025-01-15"
}
}'{
"statusCode": 200,
"info": {
"awardId": "https://api.badges.ninja/certify-badge/award/c1d2e3f4-a5b6-7890-cdef-123456789012"
}
}blockchain 参数仅 Pro 套餐可用。可选地按筛选与分页获取颁发。
GET /awards| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
filter | JSON string | 否 | 过滤对象(见下) |
lastEvaluatedKey | string | 否 | 上一次响应中的分页 token |
filter 参数接收包含以下字段的 JSON 字符串:
| 字段 | 类型 | 说明 |
|---|---|---|
badgeId | string | 按徽章 ID 过滤。 |
search | string | 在接收者姓名或邮箱中查找的子串(参见 searchField)。 |
searchField | string | name(默认)或 email — 搜索哪一列。 |
通过 lastEvaluatedKey 的分页在有或没有过滤器时均可用。每页大小为 50。
curl -X GET https://api.badges.ninja/awards \
-H "X-Api-Key: bws_your_api_key_here"curl -X GET "https://api.badges.ninja/awards?filter=%7B%22badgeId%22%3A%22b1c2d3e4%22%7D" \
-H "X-Api-Key: bws_your_api_key_here"{
"statusCode": 200,
"info": {
"awards": [
{
"id": "https://api.badges.ninja/certify-badge/award/c1d2e3f4-...",
"badge": {
"id": "https://api.badges.ninja/certify-badge/badge/b1c2d3e4-...",
"name": "JavaScript Fundamentals",
"image": "https://ipfs.ninja/ipfs/Qm..."
},
"recipient": {
"name": "Jane Smith",
"email": "jane@example.com"
},
"issuedOn": "2025-01-15T00:00:00.000Z",
"timestamp": "2025-01-15T10:30:00.000Z"
}
],
"lastEvaluatedKey": "eyJ..."
}
}如果响应中存在 lastEvaluatedKey,说明还有更多结果。将其作为下一次请求的 query 参数即可获取下一页。
向接收者发送关于其颁发的邮件通知。
POST /awards/{awardId}/send| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
awardId | string | 是 | 颁发 ID(路径参数与请求体) |
email | string | 是 | 接收者邮箱地址 |
curl -X POST https://api.badges.ninja/awards/c1d2e3f4-a5b6-7890-cdef-123456789012/send \
-H "X-Api-Key: bws_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"parameters": {
"awardId": "c1d2e3f4-a5b6-7890-cdef-123456789012",
"email": "jane@example.com"
}
}'{
"statusCode": 200,
"info": {
"sent": true
}
}通过邮件与多位接收者分享某条颁发。
POST /awards/{awardId}/share| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
awardId | string | 是 | 颁发 ID(路径参数与请求体) |
recipients | string | 是 | 以逗号分隔的邮箱列表 |
subject | string | 是 | 邮件主题 |
message | string | 是 | 邮件正文 |
curl -X POST https://api.badges.ninja/awards/c1d2e3f4-a5b6-7890-cdef-123456789012/share \
-H "X-Api-Key: bws_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"parameters": {
"awardId": "c1d2e3f4-a5b6-7890-cdef-123456789012",
"recipients": "manager@example.com,hr@example.com",
"subject": "Check out my new badge!",
"message": "I just earned the JavaScript Fundamentals badge."
}
}'{
"statusCode": 200,
"info": {
"shared": true
}
}为颁发生成可打印的 A4 PDF 证书。
GET /awards/{awardGuid}/pdf无需认证 — 该端点公开,以便接收者可下载自己的证书。
curl -OJ https://api.badges.ninja/awards/c1d2e3f4-a5b6-7890-cdef-123456789012/pdf响应是带有 Content-Type: application/pdf 头的二进制 PDF。
记录一次互动事件(浏览、分享、下载、LinkedIn 添加)。公开颁发页用它来填充互动统计。无需认证。
POST /awards/{awardGuid}/event| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
kind | string | 是 | view、share、download、linkedin_add 之一。 |
network | string | 否 | 当 kind=share 时,社交网络:linkedin、twitter、facebook、whatsapp、telegram、email、copy。 |
按 IP 去重:相同 kind 自同一 IP 每 24 小时仅计 1 次。
curl -X POST https://api.badges.ninja/awards/c1d2e3f4-a5b6-7890-cdef-123456789012/event \
-H "Content-Type: application/json" \
-d '{"parameters": {"kind": "share", "network": "linkedin"}}'获取某条颁发的累计互动计数。
GET /awards/{awardGuid}/stats无需认证。
{
"statusCode": 200,
"info": {
"stats": {
"views": 142,
"shares": { "linkedin": 8, "twitter": 2, "email": 1, "copy": 5 },
"downloads": 3,
"linkedin_adds": 4
}
}
}