cURL
curl "https://api.ruseo.cn/api/color?color=FF5733&action=convert&to=hsl&percent=20&count=5&color2=00FF00"
支持HEX/RGB/HSL/HSV/CMYK格式互转、互补色、调色板生成、亮度/饱和度调整、颜色混合等11种操作
https://api.ruseo.cn/api/color
接口调用前需要确认的核心配置。
/api/colorcolor必填参数必须传入,示例值可直接用于联调。
免费API不强制要求API Key,但如果您希望统计个人调用次数,请在请求时附加参数 key=您的API_KEY。
注册账号后即可获得API Key。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
否 | string | 可选参数:携带此参数可统计您的个人调用次数。请注册账号获取API Key。 | YOUR_API_KEY |
color |
是 | string | 颜色值,支持HEX(#FF5733)、RGB(rgb(255,87,51))、HSL(hsl(11,100%,60%))、HSV、CMYK、颜色名(red/blue等50+种) | FF5733 |
action |
否 | string | 操作类型:convert=格式转换 complement=互补色 analogous=类似色 triadic=三角色 split_complement=分裂互补 tetradic=四角色 lighten=加亮 darken=加暗 saturate=增饱和度 desaturate=减饱和度 mix=混合颜色 | convert |
to |
否 | string | 目标格式(action=convert时使用):hex/rgb/hsl/hsv/cmyk | hsl |
percent |
否 | number | 百分比(lighten/darken/saturate/desaturate时使用),范围0-100 | 20 |
count |
否 | number | 生成数量(analogous时使用),范围2-10,默认5 | 5 |
color2 |
否 | string | 第二个颜色(mix时使用),格式同color | 00FF00 |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/color?color=FF5733&action=convert&to=hsl&percent=20&count=5&color2=00FF00
curl "https://api.ruseo.cn/api/color?color=FF5733&action=convert&to=hsl&percent=20&count=5&color2=00FF00"
$url = 'https://api.ruseo.cn/api/color?color=FF5733&action=convert&to=hsl&percent=20&count=5&color2=00FF00';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/color?color=FF5733&action=convert&to=hsl&percent=20&count=5&color2=00FF00')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "color",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
original |
object | 原始颜色信息 | |
original.hex |
string | HEX格式 #FF5733 | #FF5733 |
original.rgb |
string | RGB格式 rgb(255,87,51) | rgb(255,87,51) |
original.hsl |
string | HSL格式 | hsl(11,100%,60%) |
original.hsv |
string | HSV格式 | hsv(11,100%,100%) |
original.cmyk |
string | CMYK格式 | cmyk(0,66,80,0) |
converted |
object | 转换结果(action=convert时) | |
all_formats |
object | 所有格式(action=convert时) | |
complement |
object | 互补色(action=complement时) | |
analogous |
array | 类似色列表(action=analogous时) | |
triadic |
array | 三角色(action=triadic时) | |
split_complement |
array | 分裂互补色(action=split_complement时) | |
tetradic |
array | 四角色(action=tetradic时) | |
lightened |
object | 加亮结果(action=lighten时) | |
darkened |
object | 加暗结果(action=darken时) | |
saturated |
object | 增饱和度结果(action=saturate时) | |
desaturated |
object | 减饱和度结果(action=desaturate时) | |
mixed |
object | 混合结果(action=mix时) | |
percent |
number | 使用的百分比值 | 20 |
点击左侧“发送请求”查看结果...