获取Gravatar头像
通过邮箱地址获取 Gravatar 全球通用头像链接和用户资料,支持自定义尺寸和默认头像样式。
GET
https://api.tinyaii.cn/v1/gravatar
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| string | 必填 | 邮箱地址 | test@example.com | |
| size | integer | 可选 | 头像尺寸(1-2048像素,默认200) | 200 |
| default | string | 可选 | 未注册时的默认头像样式:404(返回404)/ mp(简约)/ identicon(几何图案)/ monsterid(怪物)/ wavatar(卡通)/ retro(像素风)/ robohash(机器人)/ blank(空白) | identicon |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| email_hash | string | 邮箱 MD5 哈希值 |
| avatar_url | string | Gravatar 头像图片链接 |
| size | integer | 头像尺寸(像素) |
| profile.display_name | string | 用户显示名称(可能为空) |
| profile.location | string | 用户所在位置(可能为空) |
返回示例
{
"code": 200,
"message": "success",
"data": {
"email_hash": "55502f40dc8b7c769880b10874abc9d0",
"avatar_url": "https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=200",
"size": 200,
"profile": {
"display_name": "Test User",
"location": "Beijing, China"
}
}
}
调用示例
curl "https://api.tinyaii.cn/v1/gravatar?email=test@example.com" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch("https://api.tinyaii.cn/v1/gravatar?email=test@example.com", {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
console.log(await res.json());import requests
resp = requests.get(
"https://api.tinyaii.cn/v1/gravatar",
params={"email": "test@example.com"},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=10,
)
print(resp.json())把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。