cURL
curl "https://api.ruseo.cn/api/avatar?name=%E5%BC%A0%E4%B8%89&size=128&background=random&color=ffffff&rounded=true&bold=true&length=2&format=url"
根据文字自动生成字母头像,支持自定义尺寸/配色/圆角/加粗,可返回URL或Base64
https://api.ruseo.cn/api/avatar
接口调用前需要确认的核心配置。
/api/avataravatar必填参数必须传入,示例值可直接用于联调。
免费API不强制要求API Key,但如果您希望统计个人调用次数,请在请求时附加参数 key=您的API_KEY。
注册账号后即可获得API Key。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
否 | string | 可选参数:携带此参数可统计您的个人调用次数。请注册账号获取API Key。 | YOUR_API_KEY |
name |
是 | string | 展示文字(用户名/昵称/姓名) | 张三 |
size |
否 | integer | 头像尺寸,16-512px | 128 |
background |
否 | string | 背景色,HEX去#或random | random |
color |
否 | string | 文字颜色,HEX去# | ffffff |
rounded |
否 | string | 圆形头像,true/false | true |
bold |
否 | string | 文字加粗,true/false | true |
length |
否 | integer | 显示字符数,1-10 | 2 |
format |
否 | string | 返回格式:url/base64 | url |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/avatar?name=%E5%BC%A0%E4%B8%89&size=128&background=random&color=ffffff&rounded=true&bold=true&length=2&format=url
curl "https://api.ruseo.cn/api/avatar?name=%E5%BC%A0%E4%B8%89&size=128&background=random&color=ffffff&rounded=true&bold=true&length=2&format=url"
$url = 'https://api.ruseo.cn/api/avatar?name=%E5%BC%A0%E4%B8%89&size=128&background=random&color=ffffff&rounded=true&bold=true&length=2&format=url';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/avatar?name=%E5%BC%A0%E4%B8%89&size=128&background=random&color=ffffff&rounded=true&bold=true&length=2&format=url')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "avatar",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
code |
integer | 状态码,0=成功 | |
data.url |
string | 头像图片URL | |
data.base64 |
string | Base64编码图片(format=base64时) | |
data.size |
integer | 图片字节数(format=base64时) | |
点击左侧“发送请求”查看结果...